Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #######################################################
- # Lindenmayer System in ruby-processing by Martin Prout
- # Demonstrates export to PDF format
- #######################################################
- require 'snake_kolam'
- class Kolam_Test < Processing::App
- load_libraries :grammar, :pdf
- import "processing.pdf.PGraphicsPDF"
- attr_reader :snake, :my_font
- def setup
- size 900, 900, P2D
- @snake = SnakeKolam.new
- snake.create_grammar 4
- background(255)
- hint(ENABLE_NATIVE_FONTS)
- @my_font = create_font("/usr/share/fonts/truetype/freefont/FreeSans.ttf", 18) # for the benefit linux users
- # @my_font = create_font(Any suitable ttf font, 18)
- background 255
- stroke 0
- render_to_PDF
- end
- def render_to_PDF
- begin_record PDF, "/home/tux/kolam.pdf" # requires an absolute address for output file
- snake.render # render kolam (NB text does not appear in frame)
- fill 0 # font fill
- text_mode(SHAPE) # fonts as shape
- textFont(my_font, 18)
- text("Snake Kolam", 300, 40) # title
- text(snake.to_string, 100, 780) # lsystem values
- end_record
- end
- end
Add Comment
Please, Sign In to add comment