Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. from python.common.polygon import Polygon
  2. from python.common.svg import Svg
  3. from python.less9.transformations import *
  4.  
  5.  
  6. def transform(transformation, polygon, repeats, name="trans"):
  7. _svg = Svg()
  8. for i in range(repeats):
  9. for _line in polygon.lines():
  10. _svg.add_line(_line)
  11. polygon.apply_transformation(transformation)
  12. _svg.save(name)
  13.  
  14.  
  15. def uk1():
  16. pol = Polygon([(0, 1), (1, 1), (1, 0), (0, 0), (0, 1)])
  17. pol.apply_transformation(scaling(300, 300))
  18. trans = combine(translation(5, 10), scaling(1.1, 1.1), rotation(20))
  19. transform(trans, pol, 11, "uk1")
  20.  
  21.  
  22. def uk2():
  23. pol = Polygon([(-1, 1), (1, 1), (1, -1), (-1, -1), (-1, 1)])
  24. pol.apply_transformation(scaling(300, 300))
  25. trans = combine(scaling(1.1, 0.8), rotation(10))
  26. transform(trans, pol, 15, "uk2")
  27.  
  28.  
  29. def uk3():
  30. pol = Polygon([(-1, 1), (1, 1), (1, -1), (-1, -1), (-1, 1)])
  31. pol.apply_transformation(scaling(50, 50))
  32. trans = combine(translation(50, 50), scaling(0.9, 0.9), rotation(10), shear(1.3))
  33. transform(trans, pol, 25, "uk3")
  34.  
  35.  
  36. uk1()
  37. uk2()
  38. uk3()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement