Skip to content

Instantly share code, notes, and snippets.

@deltheil
Created October 27, 2010 12:43
Show Gist options
  • Save deltheil/648951 to your computer and use it in GitHub Desktop.
Save deltheil/648951 to your computer and use it in GitHub Desktop.
Speech bubble PNG icon generator - mimicks the Facebook for iPhone comments toolbar button
require 'rubygems'
require 'Rmagick'
include Magick
# In pixels
SQUARE_SIZE = 20
CORNER = 2
SPIKE_OFFSET, SPIKE_WIDTH, SPIKE_HEIGHT = 7, 4, 6
bubble = Image.new(SQUARE_SIZE, SQUARE_SIZE + SPIKE_HEIGHT) do
self.background_color = 'transparent'
end
gc = Draw.new
# Rounded square
gc.fill('white')
gc.fill_opacity(1)
gc.roundrectangle(0, 0, SQUARE_SIZE - 1, SQUARE_SIZE - 1, CORNER, CORNER)
# Triangle
gc.polygon(SPIKE_OFFSET, SQUARE_SIZE,
SPIKE_OFFSET + SPIKE_WIDTH, SQUARE_SIZE,
SPIKE_OFFSET, SQUARE_SIZE + SPIKE_HEIGHT - 1)
gc.draw(bubble)
bubble.write("bubble.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment