Text Spirograph
July 2, 2008 | textText can be positioned and scaled arbitrarily on the canvas, rendered using any font that is installed on your system.
#!/usr/local/bin/macruby framework 'cocoa' require 'rubygems' require 'hotcocoa/graphics' include HotCocoa include Graphics # set up the canvas and font canvas = Canvas.new :type => :image, :filename => 'spiro.png', :size => [400,400] canvas.background(Color.beige) canvas.fill(Color.black) canvas.font('Book Antiqua') canvas.fontsize(12) canvas.translate(200,200) # rotate, draw text, repeat for frame in 1..180 canvas.push canvas.rotate((frame*2) + 120) canvas.translate(70,0) canvas.text("Going ...", 80, 0) canvas.rotate(frame * 6) canvas.text("Around and", 20, 0) canvas.pop end # save the canvas canvas.save