Created
October 27, 2010 12:43
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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