shoes4
shoes4 copied to clipboard
Add text to an image
When you have in image, it'd be preferrable to be able to add text to the image somewhere - we should have a clear way to do this :)
This came in from the mailing list:
Example image:
def img_octagon(resp_rgb,orig_rgb,border_rgb)
@img = image 60,60 do
translate(5,5)
strokewidth 0
fill resp_rgb
rect(0,0,50,50)
strokewidth 1
� �
fill orig_rgb
lw = 12 #line length for each side of the octagon
lws = lw*Math.sin(45)
lwx = (50-(lw+2*lws))/2
shape do
move_to( lwx, lwx+lws)
line_to( lwx+lws, lwx)
line_to( lwx+lws+lw, lwx)
line_to( lwx+2*lws+lw, lwx+lws)
line_to( lwx+2*lws+lw, lwx+lws+lw)
line_to( lwx+lws+lw, lwx+2*lws+lw)
line_to( lwx+lws, lwx+2*lws+lw)
line_to( lwx, lwx+lws+lw)
line_to( lwx, lwx+lws)
end
nofill
strokewidth 3
stroke border_rgb
rect(0,0,50,50)
### WOULD LIKE TO ADD TEXT TO THE IMAGE HERE.
end
return @img
end
This would require Imagemagick/Rmagick gem to happen, right? unless there is a way in swt that i'm not aware of...
@h1k3n I don't think necessarily, I'd just make an SWT text label positioned over the image so it looks like the image has text. Upside is also, that you could still mark the text.