Guest User

Untitled

a guest
Jul 16th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #######################################################
  2. # Lindenmayer System in ruby-processing by Martin Prout
  3. # Demonstrates export to PDF format
  4. #######################################################
  5.  
  6. require 'snake_kolam'
  7.  
  8. class Kolam_Test < Processing::App
  9. load_libraries :grammar, :pdf
  10. import "processing.pdf.PGraphicsPDF"
  11. attr_reader :snake, :my_font
  12.  
  13. def setup
  14. size 900, 900, P2D
  15. @snake = SnakeKolam.new
  16. snake.create_grammar 4
  17. background(255)
  18. hint(ENABLE_NATIVE_FONTS)
  19. @my_font = create_font("/usr/share/fonts/truetype/freefont/FreeSans.ttf", 18) # for the benefit linux users
  20. # @my_font = create_font(Any suitable ttf font, 18)
  21. background 255
  22. stroke 0
  23. render_to_PDF
  24. end
  25.  
  26. def render_to_PDF
  27. begin_record PDF, "/home/tux/kolam.pdf" # requires an absolute address for output file
  28. snake.render # render kolam (NB text does not appear in frame)
  29. fill 0 # font fill
  30. text_mode(SHAPE) # fonts as shape
  31. textFont(my_font, 18)
  32. text("Snake Kolam", 300, 40) # title
  33. text(snake.to_string, 100, 780) # lsystem values
  34. end_record
  35. end
  36.  
  37. end
Add Comment
Please, Sign In to add comment