vector_salad 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/Gemfile +9 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +89 -0
  6. data/Rakefile +2 -0
  7. data/bin/vector_salad +72 -0
  8. data/examples/birthday.png +0 -0
  9. data/examples/birthday.rb +45 -0
  10. data/examples/birthday.svg +630 -0
  11. data/examples/boolean_operations.png +0 -0
  12. data/examples/boolean_operations.rb +23 -0
  13. data/examples/boolean_operations.svg +151 -0
  14. data/examples/bp_logo.png +0 -0
  15. data/examples/bp_logo.rb +18 -0
  16. data/examples/bp_logo.svg +25 -0
  17. data/examples/bunny_card.png +0 -0
  18. data/examples/bunny_card.rb +219 -0
  19. data/examples/bunny_card.svg +134 -0
  20. data/examples/chill.png +0 -0
  21. data/examples/chill.rb +16 -0
  22. data/examples/chill.svg +86 -0
  23. data/examples/circle_line_segments.png +0 -0
  24. data/examples/circle_line_segments.rb +11 -0
  25. data/examples/circle_line_segments.svg +28 -0
  26. data/examples/circles.png +0 -0
  27. data/examples/circles.rb +14 -0
  28. data/examples/circles.svg +11 -0
  29. data/examples/clip_operations.png +0 -0
  30. data/examples/clip_operations.rb +14 -0
  31. data/examples/clip_operations.svg +8 -0
  32. data/examples/cog_menu.png +0 -0
  33. data/examples/cog_menu.rb +32 -0
  34. data/examples/cog_menu.svg +37 -0
  35. data/examples/cubic_bezier_handles.png +0 -0
  36. data/examples/cubic_bezier_handles.rb +21 -0
  37. data/examples/cubic_bezier_handles.svg +14 -0
  38. data/examples/cubic_circle.png +0 -0
  39. data/examples/cubic_circle.rb +26 -0
  40. data/examples/cubic_circle.svg +29 -0
  41. data/examples/face.png +0 -0
  42. data/examples/face.rb +4 -0
  43. data/examples/face.svg +10 -0
  44. data/examples/flower.png +0 -0
  45. data/examples/flower.rb +23 -0
  46. data/examples/flower.svg +207 -0
  47. data/examples/fox.png +0 -0
  48. data/examples/fox.rb +110 -0
  49. data/examples/fox.svg +31 -0
  50. data/examples/fresh_vector_salad_gui.png +0 -0
  51. data/examples/galaxies.png +0 -0
  52. data/examples/galaxies.rb +60 -0
  53. data/examples/galaxies.svg +5806 -0
  54. data/examples/gold_stars.png +0 -0
  55. data/examples/gold_stars.rb +9 -0
  56. data/examples/gold_stars.svg +12 -0
  57. data/examples/paths.png +0 -0
  58. data/examples/paths.rb +87 -0
  59. data/examples/paths.svg +13 -0
  60. data/examples/pepsi_logo.png +0 -0
  61. data/examples/pepsi_logo.rb +21 -0
  62. data/examples/pepsi_logo.svg +10 -0
  63. data/examples/polygons.png +0 -0
  64. data/examples/polygons.rb +9 -0
  65. data/examples/polygons.svg +13 -0
  66. data/examples/quadratic_bezier_handle.png +0 -0
  67. data/examples/quadratic_bezier_handle.rb +18 -0
  68. data/examples/quadratic_bezier_handle.svg +13 -0
  69. data/examples/rects.png +0 -0
  70. data/examples/rects.rb +10 -0
  71. data/examples/rects.svg +11 -0
  72. data/examples/simple_path.png +0 -0
  73. data/examples/simple_path.rb +29 -0
  74. data/examples/simple_path.svg +8 -0
  75. data/examples/space.png +0 -0
  76. data/examples/space.rb +171 -0
  77. data/examples/space.svg +46453 -0
  78. data/examples/spiro_nodes.png +0 -0
  79. data/examples/spiro_nodes.rb +20 -0
  80. data/examples/spiro_nodes.svg +13 -0
  81. data/examples/squares.png +0 -0
  82. data/examples/squares.rb +14 -0
  83. data/examples/squares.svg +11 -0
  84. data/examples/stars.png +0 -0
  85. data/examples/stars.rb +3 -0
  86. data/examples/stars.svg +30006 -0
  87. data/examples/transforms.png +0 -0
  88. data/examples/transforms.rb +58 -0
  89. data/examples/transforms.svg +121 -0
  90. data/examples/triangles.png +0 -0
  91. data/examples/triangles.rb +8 -0
  92. data/examples/triangles.svg +9 -0
  93. data/lib/contracts_contracts.rb +32 -0
  94. data/lib/vector_salad.rb +5 -0
  95. data/lib/vector_salad/canvas.rb +27 -0
  96. data/lib/vector_salad/dsl.rb +41 -0
  97. data/lib/vector_salad/export_with_magic.rb +29 -0
  98. data/lib/vector_salad/exporters/base_exporter.rb +92 -0
  99. data/lib/vector_salad/exporters/svg_exporter.rb +174 -0
  100. data/lib/vector_salad/interpolate.rb +57 -0
  101. data/lib/vector_salad/magic.rb +17 -0
  102. data/lib/vector_salad/mixins/at.rb +28 -0
  103. data/lib/vector_salad/shape_proxy.rb +14 -0
  104. data/lib/vector_salad/standard_shapes/basic_shape.rb +29 -0
  105. data/lib/vector_salad/standard_shapes/circle.rb +64 -0
  106. data/lib/vector_salad/standard_shapes/clip.rb +51 -0
  107. data/lib/vector_salad/standard_shapes/custom.rb +28 -0
  108. data/lib/vector_salad/standard_shapes/difference.rb +28 -0
  109. data/lib/vector_salad/standard_shapes/exclusion.rb +28 -0
  110. data/lib/vector_salad/standard_shapes/flip.rb +24 -0
  111. data/lib/vector_salad/standard_shapes/hexagon.rb +15 -0
  112. data/lib/vector_salad/standard_shapes/intersection.rb +28 -0
  113. data/lib/vector_salad/standard_shapes/iso_tri.rb +39 -0
  114. data/lib/vector_salad/standard_shapes/jitter.rb +33 -0
  115. data/lib/vector_salad/standard_shapes/move.rb +24 -0
  116. data/lib/vector_salad/standard_shapes/multi_path.rb +82 -0
  117. data/lib/vector_salad/standard_shapes/n.rb +112 -0
  118. data/lib/vector_salad/standard_shapes/oval.rb +51 -0
  119. data/lib/vector_salad/standard_shapes/path.rb +249 -0
  120. data/lib/vector_salad/standard_shapes/pentagon.rb +15 -0
  121. data/lib/vector_salad/standard_shapes/polygon.rb +37 -0
  122. data/lib/vector_salad/standard_shapes/rect.rb +34 -0
  123. data/lib/vector_salad/standard_shapes/rotate.rb +24 -0
  124. data/lib/vector_salad/standard_shapes/scale.rb +34 -0
  125. data/lib/vector_salad/standard_shapes/square.rb +34 -0
  126. data/lib/vector_salad/standard_shapes/transform.rb +20 -0
  127. data/lib/vector_salad/standard_shapes/triangle.rb +15 -0
  128. data/lib/vector_salad/standard_shapes/union.rb +28 -0
  129. data/lib/vector_salad/version.rb +3 -0
  130. data/vector_salad.gemspec +34 -0
  131. metadata +262 -0
Binary file
@@ -0,0 +1,23 @@
1
+ square(210, fill: :none)
2
+
3
+ # A rectangle to "show through" the clipped shape
4
+ rect(200, 40, fill: "purple")[5, 90]
5
+
6
+ # Subtract subsequent shapes from the first square, draw the result
7
+ shape = difference(fill: "blue") do
8
+ square(200)[5, 5]
9
+ square(60)[120, 105]
10
+
11
+ # Result of this difference will be used in outer difference
12
+ difference do # (it will be a donut)
13
+ circle(60)[60, 60]
14
+ circle(20)[60, 60]
15
+ end
16
+ end
17
+
18
+ # Draw circles to show the resultant clipped nodes
19
+ shape.shape.to_path.paths.each do |path|
20
+ path.nodes.each do |node|
21
+ circle(3, fill: :green)[*node.at]
22
+ end
23
+ end
@@ -0,0 +1,151 @@
1
+ <svg version="1.1"
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ width="210"
4
+ height="210">
5
+
6
+ <rect x="0" y="0" width="210" height="210" fill="none"/>
7
+ <rect x="5" y="90" width="200" height="40" fill="purple"/>
8
+ <path d=" M 5.0 205.0 L 5.0 83.95208263397217 L 5.187272071838379 84.4041976928711 L 6.539608001708984 87.23942947387695 L 8.038475036621094 90.0 L 9.679765701293945 92.67834186553955 L 11.458979606628418 95.26711463928223 L 13.371241569519043 97.75922298431396 L 15.411310195922852 100.14783573150635 L 17.57359218597412 102.42640686035156 L 19.852163314819336 104.58868885040283 L 22.24077606201172 106.62875747680664 L 24.732884407043457 108.54101943969727 L 27.321657180786133 110.32023334503174 L 30.0 111.96152400970459 L 32.76056957244873 113.4603910446167 L 35.59580135345459 114.8127269744873 L 38.49792289733887 116.01482486724854 L 41.45897960662842 117.06339073181152 L 44.47085666656494 117.9555492401123 L 47.52529811859131 118.68885517120361 L 50.61393165588379 119.2613000869751 L 53.728291511535645 119.67131328582764 L 56.85984230041504 119.9177713394165 L 60.0 120.0 L 63.140156745910645 119.9177713394165 L 66.27170753479004 119.67131328582764 L 69.3860673904419 119.2613000869751 L 72.47470092773438 118.68885517120361 L 75.52914237976074 117.9555492401123 L 78.54101943969727 117.06339073181152 L 81.50207614898682 116.01482486724854 L 84.4041976928711 114.8127269744873 L 87.23942947387695 113.4603910446167 L 90.0 111.96152400970459 L 92.67834186553955 110.32023334503174 L 95.26711463928223 108.54101943969727 L 97.75922298431396 106.62875747680664 L 100.14783573150635 104.58868885040283 L 102.42640686035156 102.42640686035156 L 104.58868885040283 100.14783573150635 L 106.62875747680664 97.75922298431396 L 108.54101943969727 95.26711463928223 L 110.32023334503174 92.67834186553955 L 111.96152400970459 90.0 L 113.4603910446167 87.23942947387695 L 114.8127269744873 84.4041976928711 L 116.01482486724854 81.50207614898682 L 117.06339073181152 78.54101943969727 L 117.9555492401123 75.52914237976074 L 118.68885517120361 72.47470092773438 L 119.2613000869751 69.3860673904419 L 119.67131328582764 66.27170753479004 L 119.9177713394165 63.140156745910645 L 120.0 60.0 L 119.9177713394165 56.85984230041504 L 119.67131328582764 53.728291511535645 L 119.2613000869751 50.61393165588379 L 118.68885517120361 47.52529811859131 L 117.9555492401123 44.47085666656494 L 117.06339073181152 41.45897960662842 L 116.01482486724854 38.49792289733887 L 114.8127269744873 35.59580135345459 L 113.4603910446167 32.76056957244873 L 111.96152400970459 29.999999046325684 L 110.32023334503174 27.321657180786133 L 108.54101943969727 24.732884407043457 L 106.62875747680664 22.24077606201172 L 104.58868885040283 19.852163314819336 L 102.42640686035156 17.57359218597412 L 100.14783573150635 15.411310195922852 L 97.75922298431396 13.371241569519043 L 95.26711463928223 11.458979606628418 L 92.67834186553955 9.679765701293945 L 89.99999904632568 8.038475036621094 L 87.23942947387695 6.539608001708984 L 84.4041976928711 5.187272071838379 L 83.95208263397217 5.0 L 205.0 5.0 L 205.0 205.0 Z M 120.0 165.0 L 180.0 165.0 L 180.0 105.0 L 120.0 105.0 Z M 60.0 80.0 L 56.871310234069824 79.75376605987549 L 53.81965923309326 79.0211296081543 L 50.92018985748291 77.82013034820557 L 48.24429416656494 76.18033981323242 L 45.857863426208496 74.14213562011719 L 43.81965923309326 71.75570487976074 L 42.17986869812012 69.07980918884277 L 40.97886943817139 66.18033981323242 L 40.246232986450195 63.12868881225586 L 40.0 60.0 L 40.246232986450195 56.871310234069824 L 40.97886943817139 53.81965923309326 L 42.17986869812012 50.92018985748291 L 43.81965923309326 48.24429416656494 L 45.857863426208496 45.857863426208496 L 48.24429416656494 43.81965923309326 L 50.92018985748291 42.17986869812012 L 53.81965923309326 40.97886943817139 L 56.871310234069824 40.246232986450195 L 59.999999046325684 40.0 L 63.12868881225586 40.246232986450195 L 66.18033981323242 40.97886943817139 L 69.07980918884277 42.17986869812012 L 71.75570487976074 43.81965923309326 L 74.14213562011719 45.857863426208496 L 76.18033981323242 48.24429416656494 L 77.82013034820557 50.92018985748291 L 79.0211296081543 53.81965923309326 L 79.75376605987549 56.871310234069824 L 80.0 60.0 L 79.75376605987549 63.12868881225586 L 79.0211296081543 66.18033981323242 L 77.82013034820557 69.07980918884277 L 76.18033981323242 71.75570487976074 L 74.14213562011719 74.14213562011719 L 71.75570487976074 76.18033981323242 L 69.07980918884277 77.82013034820557 L 66.18033981323242 79.0211296081543 L 63.12868881225586 79.75376605987549 Z M 5.0 36.047916412353516 L 5.0 5.0 L 36.047916412353516 5.0 L 35.59580135345459 5.187272071838379 L 32.76056957244873 6.539608001708984 L 29.999999046325684 8.038475036621094 L 27.321657180786133 9.679765701293945 L 24.732884407043457 11.458979606628418 L 22.24077606201172 13.371241569519043 L 19.852163314819336 15.411310195922852 L 17.57359218597412 17.57359218597412 L 15.411310195922852 19.852163314819336 L 13.371241569519043 22.24077606201172 L 11.458979606628418 24.732884407043457 L 9.679765701293945 27.321657180786133 L 8.038475036621094 30.0 L 6.539608001708984 32.76056957244873 L 5.187272071838379 35.59580135345459 Z" fill="blue"/>
9
+ <circle cx="5.0" cy="205.0" r="3" fill="green"/>
10
+ <circle cx="5.0" cy="83.95208263397217" r="3" fill="green"/>
11
+ <circle cx="5.187272071838379" cy="84.4041976928711" r="3" fill="green"/>
12
+ <circle cx="6.539608001708984" cy="87.23942947387695" r="3" fill="green"/>
13
+ <circle cx="8.038475036621094" cy="90.0" r="3" fill="green"/>
14
+ <circle cx="9.679765701293945" cy="92.67834186553955" r="3" fill="green"/>
15
+ <circle cx="11.458979606628418" cy="95.26711463928223" r="3" fill="green"/>
16
+ <circle cx="13.371241569519043" cy="97.75922298431396" r="3" fill="green"/>
17
+ <circle cx="15.411310195922852" cy="100.14783573150635" r="3" fill="green"/>
18
+ <circle cx="17.57359218597412" cy="102.42640686035156" r="3" fill="green"/>
19
+ <circle cx="19.852163314819336" cy="104.58868885040283" r="3" fill="green"/>
20
+ <circle cx="22.24077606201172" cy="106.62875747680664" r="3" fill="green"/>
21
+ <circle cx="24.732884407043457" cy="108.54101943969727" r="3" fill="green"/>
22
+ <circle cx="27.321657180786133" cy="110.32023334503174" r="3" fill="green"/>
23
+ <circle cx="30.0" cy="111.96152400970459" r="3" fill="green"/>
24
+ <circle cx="32.76056957244873" cy="113.4603910446167" r="3" fill="green"/>
25
+ <circle cx="35.59580135345459" cy="114.8127269744873" r="3" fill="green"/>
26
+ <circle cx="38.49792289733887" cy="116.01482486724854" r="3" fill="green"/>
27
+ <circle cx="41.45897960662842" cy="117.06339073181152" r="3" fill="green"/>
28
+ <circle cx="44.47085666656494" cy="117.9555492401123" r="3" fill="green"/>
29
+ <circle cx="47.52529811859131" cy="118.68885517120361" r="3" fill="green"/>
30
+ <circle cx="50.61393165588379" cy="119.2613000869751" r="3" fill="green"/>
31
+ <circle cx="53.728291511535645" cy="119.67131328582764" r="3" fill="green"/>
32
+ <circle cx="56.85984230041504" cy="119.9177713394165" r="3" fill="green"/>
33
+ <circle cx="60.0" cy="120.0" r="3" fill="green"/>
34
+ <circle cx="63.140156745910645" cy="119.9177713394165" r="3" fill="green"/>
35
+ <circle cx="66.27170753479004" cy="119.67131328582764" r="3" fill="green"/>
36
+ <circle cx="69.3860673904419" cy="119.2613000869751" r="3" fill="green"/>
37
+ <circle cx="72.47470092773438" cy="118.68885517120361" r="3" fill="green"/>
38
+ <circle cx="75.52914237976074" cy="117.9555492401123" r="3" fill="green"/>
39
+ <circle cx="78.54101943969727" cy="117.06339073181152" r="3" fill="green"/>
40
+ <circle cx="81.50207614898682" cy="116.01482486724854" r="3" fill="green"/>
41
+ <circle cx="84.4041976928711" cy="114.8127269744873" r="3" fill="green"/>
42
+ <circle cx="87.23942947387695" cy="113.4603910446167" r="3" fill="green"/>
43
+ <circle cx="90.0" cy="111.96152400970459" r="3" fill="green"/>
44
+ <circle cx="92.67834186553955" cy="110.32023334503174" r="3" fill="green"/>
45
+ <circle cx="95.26711463928223" cy="108.54101943969727" r="3" fill="green"/>
46
+ <circle cx="97.75922298431396" cy="106.62875747680664" r="3" fill="green"/>
47
+ <circle cx="100.14783573150635" cy="104.58868885040283" r="3" fill="green"/>
48
+ <circle cx="102.42640686035156" cy="102.42640686035156" r="3" fill="green"/>
49
+ <circle cx="104.58868885040283" cy="100.14783573150635" r="3" fill="green"/>
50
+ <circle cx="106.62875747680664" cy="97.75922298431396" r="3" fill="green"/>
51
+ <circle cx="108.54101943969727" cy="95.26711463928223" r="3" fill="green"/>
52
+ <circle cx="110.32023334503174" cy="92.67834186553955" r="3" fill="green"/>
53
+ <circle cx="111.96152400970459" cy="90.0" r="3" fill="green"/>
54
+ <circle cx="113.4603910446167" cy="87.23942947387695" r="3" fill="green"/>
55
+ <circle cx="114.8127269744873" cy="84.4041976928711" r="3" fill="green"/>
56
+ <circle cx="116.01482486724854" cy="81.50207614898682" r="3" fill="green"/>
57
+ <circle cx="117.06339073181152" cy="78.54101943969727" r="3" fill="green"/>
58
+ <circle cx="117.9555492401123" cy="75.52914237976074" r="3" fill="green"/>
59
+ <circle cx="118.68885517120361" cy="72.47470092773438" r="3" fill="green"/>
60
+ <circle cx="119.2613000869751" cy="69.3860673904419" r="3" fill="green"/>
61
+ <circle cx="119.67131328582764" cy="66.27170753479004" r="3" fill="green"/>
62
+ <circle cx="119.9177713394165" cy="63.140156745910645" r="3" fill="green"/>
63
+ <circle cx="120.0" cy="60.0" r="3" fill="green"/>
64
+ <circle cx="119.9177713394165" cy="56.85984230041504" r="3" fill="green"/>
65
+ <circle cx="119.67131328582764" cy="53.728291511535645" r="3" fill="green"/>
66
+ <circle cx="119.2613000869751" cy="50.61393165588379" r="3" fill="green"/>
67
+ <circle cx="118.68885517120361" cy="47.52529811859131" r="3" fill="green"/>
68
+ <circle cx="117.9555492401123" cy="44.47085666656494" r="3" fill="green"/>
69
+ <circle cx="117.06339073181152" cy="41.45897960662842" r="3" fill="green"/>
70
+ <circle cx="116.01482486724854" cy="38.49792289733887" r="3" fill="green"/>
71
+ <circle cx="114.8127269744873" cy="35.59580135345459" r="3" fill="green"/>
72
+ <circle cx="113.4603910446167" cy="32.76056957244873" r="3" fill="green"/>
73
+ <circle cx="111.96152400970459" cy="29.999999046325684" r="3" fill="green"/>
74
+ <circle cx="110.32023334503174" cy="27.321657180786133" r="3" fill="green"/>
75
+ <circle cx="108.54101943969727" cy="24.732884407043457" r="3" fill="green"/>
76
+ <circle cx="106.62875747680664" cy="22.24077606201172" r="3" fill="green"/>
77
+ <circle cx="104.58868885040283" cy="19.852163314819336" r="3" fill="green"/>
78
+ <circle cx="102.42640686035156" cy="17.57359218597412" r="3" fill="green"/>
79
+ <circle cx="100.14783573150635" cy="15.411310195922852" r="3" fill="green"/>
80
+ <circle cx="97.75922298431396" cy="13.371241569519043" r="3" fill="green"/>
81
+ <circle cx="95.26711463928223" cy="11.458979606628418" r="3" fill="green"/>
82
+ <circle cx="92.67834186553955" cy="9.679765701293945" r="3" fill="green"/>
83
+ <circle cx="89.99999904632568" cy="8.038475036621094" r="3" fill="green"/>
84
+ <circle cx="87.23942947387695" cy="6.539608001708984" r="3" fill="green"/>
85
+ <circle cx="84.4041976928711" cy="5.187272071838379" r="3" fill="green"/>
86
+ <circle cx="83.95208263397217" cy="5.0" r="3" fill="green"/>
87
+ <circle cx="205.0" cy="5.0" r="3" fill="green"/>
88
+ <circle cx="205.0" cy="205.0" r="3" fill="green"/>
89
+ <circle cx="120.0" cy="165.0" r="3" fill="green"/>
90
+ <circle cx="180.0" cy="165.0" r="3" fill="green"/>
91
+ <circle cx="180.0" cy="105.0" r="3" fill="green"/>
92
+ <circle cx="120.0" cy="105.0" r="3" fill="green"/>
93
+ <circle cx="60.0" cy="80.0" r="3" fill="green"/>
94
+ <circle cx="56.871310234069824" cy="79.75376605987549" r="3" fill="green"/>
95
+ <circle cx="53.81965923309326" cy="79.0211296081543" r="3" fill="green"/>
96
+ <circle cx="50.92018985748291" cy="77.82013034820557" r="3" fill="green"/>
97
+ <circle cx="48.24429416656494" cy="76.18033981323242" r="3" fill="green"/>
98
+ <circle cx="45.857863426208496" cy="74.14213562011719" r="3" fill="green"/>
99
+ <circle cx="43.81965923309326" cy="71.75570487976074" r="3" fill="green"/>
100
+ <circle cx="42.17986869812012" cy="69.07980918884277" r="3" fill="green"/>
101
+ <circle cx="40.97886943817139" cy="66.18033981323242" r="3" fill="green"/>
102
+ <circle cx="40.246232986450195" cy="63.12868881225586" r="3" fill="green"/>
103
+ <circle cx="40.0" cy="60.0" r="3" fill="green"/>
104
+ <circle cx="40.246232986450195" cy="56.871310234069824" r="3" fill="green"/>
105
+ <circle cx="40.97886943817139" cy="53.81965923309326" r="3" fill="green"/>
106
+ <circle cx="42.17986869812012" cy="50.92018985748291" r="3" fill="green"/>
107
+ <circle cx="43.81965923309326" cy="48.24429416656494" r="3" fill="green"/>
108
+ <circle cx="45.857863426208496" cy="45.857863426208496" r="3" fill="green"/>
109
+ <circle cx="48.24429416656494" cy="43.81965923309326" r="3" fill="green"/>
110
+ <circle cx="50.92018985748291" cy="42.17986869812012" r="3" fill="green"/>
111
+ <circle cx="53.81965923309326" cy="40.97886943817139" r="3" fill="green"/>
112
+ <circle cx="56.871310234069824" cy="40.246232986450195" r="3" fill="green"/>
113
+ <circle cx="59.999999046325684" cy="40.0" r="3" fill="green"/>
114
+ <circle cx="63.12868881225586" cy="40.246232986450195" r="3" fill="green"/>
115
+ <circle cx="66.18033981323242" cy="40.97886943817139" r="3" fill="green"/>
116
+ <circle cx="69.07980918884277" cy="42.17986869812012" r="3" fill="green"/>
117
+ <circle cx="71.75570487976074" cy="43.81965923309326" r="3" fill="green"/>
118
+ <circle cx="74.14213562011719" cy="45.857863426208496" r="3" fill="green"/>
119
+ <circle cx="76.18033981323242" cy="48.24429416656494" r="3" fill="green"/>
120
+ <circle cx="77.82013034820557" cy="50.92018985748291" r="3" fill="green"/>
121
+ <circle cx="79.0211296081543" cy="53.81965923309326" r="3" fill="green"/>
122
+ <circle cx="79.75376605987549" cy="56.871310234069824" r="3" fill="green"/>
123
+ <circle cx="80.0" cy="60.0" r="3" fill="green"/>
124
+ <circle cx="79.75376605987549" cy="63.12868881225586" r="3" fill="green"/>
125
+ <circle cx="79.0211296081543" cy="66.18033981323242" r="3" fill="green"/>
126
+ <circle cx="77.82013034820557" cy="69.07980918884277" r="3" fill="green"/>
127
+ <circle cx="76.18033981323242" cy="71.75570487976074" r="3" fill="green"/>
128
+ <circle cx="74.14213562011719" cy="74.14213562011719" r="3" fill="green"/>
129
+ <circle cx="71.75570487976074" cy="76.18033981323242" r="3" fill="green"/>
130
+ <circle cx="69.07980918884277" cy="77.82013034820557" r="3" fill="green"/>
131
+ <circle cx="66.18033981323242" cy="79.0211296081543" r="3" fill="green"/>
132
+ <circle cx="63.12868881225586" cy="79.75376605987549" r="3" fill="green"/>
133
+ <circle cx="5.0" cy="36.047916412353516" r="3" fill="green"/>
134
+ <circle cx="5.0" cy="5.0" r="3" fill="green"/>
135
+ <circle cx="36.047916412353516" cy="5.0" r="3" fill="green"/>
136
+ <circle cx="35.59580135345459" cy="5.187272071838379" r="3" fill="green"/>
137
+ <circle cx="32.76056957244873" cy="6.539608001708984" r="3" fill="green"/>
138
+ <circle cx="29.999999046325684" cy="8.038475036621094" r="3" fill="green"/>
139
+ <circle cx="27.321657180786133" cy="9.679765701293945" r="3" fill="green"/>
140
+ <circle cx="24.732884407043457" cy="11.458979606628418" r="3" fill="green"/>
141
+ <circle cx="22.24077606201172" cy="13.371241569519043" r="3" fill="green"/>
142
+ <circle cx="19.852163314819336" cy="15.411310195922852" r="3" fill="green"/>
143
+ <circle cx="17.57359218597412" cy="17.57359218597412" r="3" fill="green"/>
144
+ <circle cx="15.411310195922852" cy="19.852163314819336" r="3" fill="green"/>
145
+ <circle cx="13.371241569519043" cy="22.24077606201172" r="3" fill="green"/>
146
+ <circle cx="11.458979606628418" cy="24.732884407043457" r="3" fill="green"/>
147
+ <circle cx="9.679765701293945" cy="27.321657180786133" r="3" fill="green"/>
148
+ <circle cx="8.038475036621094" cy="30.0" r="3" fill="green"/>
149
+ <circle cx="6.539608001708984" cy="32.76056957244873" r="3" fill="green"/>
150
+ <circle cx="5.187272071838379" cy="35.59580135345459" r="3" fill="green"/>
151
+ </svg>
Binary file
@@ -0,0 +1,18 @@
1
+ square(600, fill: "none") # background
2
+
3
+ def petal(radius, **options)
4
+ width = radius / 4.6
5
+ path(
6
+ N.n(0, 0),
7
+ N.s(-width, radius/2.0),
8
+ N.n(0, radius),
9
+ N.s(width, radius/2.0),
10
+ **options
11
+ )
12
+ end
13
+
14
+ (repeats = 18).times do |repeat|
15
+ angle = 360.0 / repeats
16
+ petal(250, fill: 'rgb(50, 155, 0)', opacity: 0.6)
17
+ .rotate(angle * repeat).move(300, 300)
18
+ end
@@ -0,0 +1,25 @@
1
+ <svg version="1.1"
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ width="600"
4
+ height="600">
5
+
6
+ <rect x="0" y="0" width="600" height="600" fill="none"/>
7
+ <path d="M 300.0 300.0 C 265.45776045126786 331.65325224102, 245.0 378.14816235753784, 245.0 425.0 C 245.0 471.85183764246216, 265.45776045126786 518.34674775898, 300.0 550.0 C 333.98206155644914 518.0090355317843, 354.0 471.67121506060175, 354.0 425.0 C 354.0 378.32878493939825, 333.98206155644914 331.99096446821574, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
8
+ <path d="M 300.0 300.0 C 257.0262491312171 317.93012183466186, 222.1247681135892 354.3167722572952, 206.0 398.0 C 189.81967049259805 441.8337477999563, 192.79212991955075 492.36555805815254, 214.0 534.0 C 256.9737508687829 516.0698781653382, 291.8752318864108 479.6832277427048, 308.0 436.0 C 324.18032950740195 392.1662522000437, 321.20787008044925 341.6344419418474, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
9
+ <path d="M 300.0 300.0 C 253.4291718237913 302.14595875918235, 208.1299535476503 324.4242628294156, 178.0 360.0 C 147.6992931974004 395.7773529118596, 133.20136696610234 444.4755153810916, 139.0 491.0 C 185.6889916891148 488.44224826570024, 230.9404035990913 465.81654231071195, 261.0 430.0 C 290.90175694247404 394.37152620377924, 305.3518482017605 346.2045553394911, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
10
+ <path d="M 300.0 300.0 C 255.21257774498042 285.9679552659953, 204.65275623667128 291.54440616764697, 164.0 315.0 C 123.41641875440484 338.41568164326077, 93.31429132219901 379.2951139586021, 83.0 425.0 C 127.68489039988634 438.103595292568, 177.61607792155922 432.185824919629, 218.0 409.0 C 258.52705935617405 385.731994952979, 288.87713984838706 345.38859527430554, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
11
+ <path d="M 300.0 300.0 C 262.5419107707812 271.7800421910465, 213.19501618525857 259.9071051479133, 167.0 268.0 C 120.92546577836609 276.0717876430476, 78.65076851102403 303.88408847682535, 53.0 343.0 C 90.4580892292188 371.2199578089535, 139.80498381474146 383.0928948520867, 186.0 375.0 C 232.0745342216339 366.9282123569524, 274.349231488976 339.1159115231747, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
12
+ <path d="M 300.0 300.0 C 274.6266380369102 260.44813233303415, 232.26840167838762 232.20930809401912, 186.0 224.0 C 139.80878096050648 215.80438626410017, 90.40798381730241 227.69029234366806, 53.0 256.0 C 78.76423650755285 295.01673135536663, 120.97162915665423 322.7847528350386, 167.0 331.0 C 213.0663011718155 339.2220170553077, 262.3164432512567 327.74266063077624, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
13
+ <path d="M 300.0 300.0 C 289.3357249589069 254.17126253116035, 258.8743774605265 213.30847930162568, 218.0 190.0 C 177.5580684757833 166.93812157114073, 127.51790650800979 161.37810357472142, 83.0 175.0 C 93.77028688632355 220.26829753626632, 123.76305868885427 260.6289410730052, 164.0 284.0 C 204.5937482448365 307.57830519376154, 255.04251534827924 313.5134542647548, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
14
+ <path d="M 300.0 300.0 C 305.6090603034777 253.47851380672907, 291.1403623310798 204.87852830970036, 261.0 169.0 C 230.9255250939143 133.19990285900755, 185.6847626564454 110.57952164027311, 139.0 108.0 C 133.39093969652228 154.52148619327093, 147.85963766892013 203.12147169029964, 178.0 239.0 C 208.0744749060857 274.8000971409925, 253.3152373435546 297.4204783597269, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
15
+ <path d="M 300.0 300.0 C 321.4072429318363 258.0727523037565, 324.38177412466587 207.13390562655022, 308.0 163.0 C 291.8003941728442 119.35687140341469, 256.93056963059826 83.0032245402221, 214.0 65.0 C 192.95674889595486 106.69115004384497, 189.98980270181286 157.129235344259, 206.0 201.0 C 222.0453599262387 244.96711645898222, 256.9226700002277 281.69960260073657, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
16
+ <path d="M 300.0 300.0 C 334.0818140538851 268.0896795494267, 354.1270939392744 221.68856870361822, 354.0 175.0 C 353.87251044408583 128.16609962461646, 333.4428826679359 81.73512740609397, 299.0 50.0 C 264.9181859461149 81.91032045057331, 244.8729060607256 128.31143129638178, 245.0 175.0 C 245.12748955591417 221.83390037538354, 265.5571173320641 268.26487259390603, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
17
+ <path d="M 300.0 300.0 C 342.67121925475203 281.4121125295603, 377.112730878092 244.74856789826288, 393.0 201.0 C 408.937352200684 157.11351897421497, 405.9727509954265 106.71529848483735, 385.0 65.0 C 341.9855123463699 82.86097401537124, 307.0539836627555 119.27895072807559, 291.0 163.0 C 274.75751039778766 207.23442200483453, 278.11025303182674 258.27061543409593, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
18
+ <path d="M 300.0 300.0 C 346.3421397751762 297.1433762934502, 391.1434677322181 274.55758286056135, 421.0 239.0 C 451.1309767951961 203.1155679281293, 465.59797399456653 154.52129528409012, 460.0 108.0 C 413.2797885447531 110.39590827975626, 367.9488534969531 133.06137580365623, 338.0 169.0 C 308.0511465030469 204.93862419634377, 293.9316749307813 253.61364461652244, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
19
+ <path d="M 300.0 300.0 C 344.6508447877039 313.3261869320647, 394.70121192339525 307.39429156783456, 435.0 284.0 C 475.50629565391864 260.4852459319784, 505.5681610918445 219.66049039899264, 516.0 174.0 C 471.3491552122961 160.67381306793533, 421.29878807660475 166.60570843216544, 381.0 190.0 C 340.49370434608136 213.51475406802163, 310.4318389081555 254.33950960100736, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
20
+ <path d="M 300.0 300.0 C 337.3844890029483 327.5785800785554, 386.24726995820316 339.05393015138037, 432.0 331.0 C 478.0627513114916 322.8914962822055, 520.3201786428607 295.09055724841, 546.0 256.0 C 508.6701353390723 227.5509644603414, 459.18502565531634 215.64477265673096, 413.0 224.0 C 367.0354812751456 232.31533593888778, 325.03392232565346 260.56417204651086, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
21
+ <path d="M 300.0 300.0 C 325.3118029839557 339.0008355028341, 367.23009229692195 366.8227089406435, 413.0 375.0 C 459.1890649980282 383.2521780620285, 508.6196639486906 371.3591016227714, 546.0 343.0 C 520.435033814044 303.80937037079303, 478.10918492111705 275.96341715176214, 432.0 268.0 C 386.1183627191818 260.0758821068281, 337.1593616350771 271.9447308544898, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
22
+ <path d="M 300.0 300.0 C 310.7203195509563 345.2876224553791, 340.7301411286196 385.67120951667914, 381.0 409.0 C 421.31493297381724 432.3549024271281, 471.3426649482325 438.28411510557726, 516.0 425.0 C 505.738535372788 379.2752390783272, 475.61824055806665 338.3711350089525, 435.0 315.0 C 394.62603708207206 291.7694187331326, 344.4886280029006 286.19859550211356, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
23
+ <path d="M 300.0 300.0 C 294.1896104768875 346.0708136027688, 308.29082976098 394.3118269430853, 338.0 430.0 C 367.93256782894514 465.9565296547463, 413.27523557883586 488.6278635296917, 460.0 491.0 C 465.78921878521083 444.4756524249758, 451.2927505257625 395.78238724580314, 421.0 360.0 C 391.0884573307376 324.6679029030174, 346.2296690126371 302.4238756378436, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
24
+ <path d="M 300.0 300.0 C 278.31019149359963 341.43736638983484, 274.9597808729586 392.06579354618736, 291.0 436.0 C 306.97731108453803 479.7619011439502, 341.9415026158778 516.2139306127938, 385.0 534.0 C 406.1378029719539 492.3413662858577, 409.10790934359267 441.84955796799795, 393.0 398.0 C 377.0338252472004 354.5362772774384, 342.56884023984713 318.21833608689406, 300.0 300.0 Z" fill="rgb(50, 155, 0)" opacity="0.6"/>
25
+ </svg>
Binary file
@@ -0,0 +1,219 @@
1
+ def grass(width, height, at: [0, 0], **options)
2
+ x_jit = width * 4
3
+ y_jit = height / 3
4
+
5
+ x_tip = at[0] + width / 2 + Random.rand(-x_jit..x_jit)
6
+ y_tip = at[1] - height + Random.rand(-y_jit..y_jit)
7
+ x_mid = at[0] - (at[0] - x_tip) / 2
8
+ y_mid = at[1] - (at[1] - y_tip) / 2
9
+ path(
10
+ N.n(at[0], at[1]),
11
+ N.n(at[0] + width, at[1]),
12
+ N.s(x_mid + width, y_mid),
13
+ N.n(x_tip, y_tip),
14
+ N.s(x_mid, y_mid),
15
+ **options
16
+ )
17
+ end
18
+
19
+ width = 600
20
+ height = 800
21
+
22
+ # Sky
23
+ rect(width, height, fill: "skyblue")
24
+
25
+ # Sun
26
+ circle(width / 3, fill: "yellow")
27
+
28
+ # Grass
29
+ grass_w = 8
30
+ grass_h = height / 3
31
+ (width / grass_w).times do |i|
32
+ grass(grass_w, grass_h, at: [i * grass_w, height], fill: "green")
33
+ end
34
+
35
+ def bunny(u, at: [0, 0], **options)
36
+ stroke = "#222"
37
+ outline = u / 4
38
+ detail = outline * 0.85
39
+ # Bunny outline
40
+ path(
41
+ N.n(at[0], at[1]+u*1),
42
+ N.r(at[0], at[1]-u*4),
43
+ N.g(at[0]+u, at[1]-u*6),
44
+ N.l(at[0]+u*2, at[1]-u*4),
45
+ N.r(at[0]+u*2, at[1]-u*3),
46
+ N.g(at[0]+u*3, at[1]-u*1), #mid ear dip
47
+ N.l(at[0]+u*4, at[1]-u*3),
48
+ N.r(at[0]+u*4, at[1]-u*4),
49
+ N.g(at[0]+u*5, at[1]-u*6),
50
+ N.l(at[0]+u*6, at[1]-u*4),
51
+ N.n(at[0]+u*6, at[1]+u*1),
52
+ N.s(at[0]+u*3, at[1]+u*4), #chin
53
+ fill: "white",
54
+ stroke: stroke,
55
+ stroke_width: outline
56
+ )
57
+ # Bunny left ear
58
+ path(
59
+ N.n(at[0]+u*0.5, at[1]-u*2),
60
+ N.r(at[0]+u*0.5, at[1]-u*4),
61
+ N.s(at[0]+u, at[1]-u*5.5),
62
+ N.l(at[0]+u*1.5, at[1]-u*4),
63
+ N.n(at[0]+u*1.5, at[1]-u*2),
64
+ closed: false,
65
+ fill: "lightpink"
66
+ )
67
+ # Bunny right ear
68
+ path(
69
+ N.n(at[0]+u*4.5, at[1]-u*2),
70
+ N.r(at[0]+u*4.5, at[1]-u*4),
71
+ N.s(at[0]+u*5, at[1]-u*5.5),
72
+ N.l(at[0]+u*5.5, at[1]-u*4),
73
+ N.n(at[0]+u*5.5, at[1]-u*2),
74
+ closed: false,
75
+ fill: "lightpink"
76
+ )
77
+ # Bunny eyes
78
+ circle(u / 4)[at[0] + u * 2, at[1] + u * 0.5]
79
+ circle(u / 4)[at[0] + u * 4, at[1] + u * 0.5]
80
+ # Bunny nose
81
+ circle(u / 3)[at[0] + u * 3, at[1] + u * 1.5]
82
+ path(
83
+ N.n(at[0]+u*3.7, at[1]+u*2.4),
84
+ N.s(at[0]+u*3.2, at[1]+u*2.2),
85
+ N.n(at[0]+u*3, at[1]+u*1.5),
86
+ N.s(at[0]+u*2.8, at[1]+u*2.2),
87
+ N.n(at[0]+u*2.3, at[1]+u*2.4),
88
+ closed: false,
89
+ fill: "none",
90
+ stroke: "black",
91
+ stroke_width: detail,
92
+ stroke_linecap: "round"
93
+ )
94
+ # Puff tail
95
+ circle(u,
96
+ fill: "white",
97
+ stroke: stroke,
98
+ stroke_width: outline
99
+ )[at[0] + u * 3, at[1] + u * 10]
100
+ # Bunny body
101
+ path(
102
+ N.g(at[0]+u*3, at[1]+u*4),
103
+ N.l(at[0], at[1]+u*7),
104
+ N.r(at[0], at[1]+u*10),
105
+ N.s(at[0]-u, at[1]+u*11),
106
+ N.s(at[0]-u*3, at[1]+u*12), #toe left
107
+ N.l(at[0]-u, at[1]+u*13),
108
+ N.r(at[0], at[1]+u*13),
109
+ N.l(at[0]+u*2, at[1]+u*11),
110
+ N.r(at[0]+u*2, at[1]+u*10.5), #midleft
111
+ N.g(at[0]+u*3, at[1]+u*9), #midleft
112
+ N.l(at[0]+u*4, at[1]+u*10.5), #midright
113
+ N.r(at[0]+u*4, at[1]+u*11),
114
+ N.l(at[0]+u*6, at[1]+u*13),
115
+ N.r(at[0]+u*7, at[1]+u*13),
116
+ N.s(at[0]+u*9, at[1]+u*12), #toe right
117
+ N.s(at[0]+u*7, at[1]+u*11),
118
+ N.l(at[0]+u*6, at[1]+u*10),
119
+ N.r(at[0]+u*6, at[1]+u*7),
120
+ fill: "white",
121
+ stroke: stroke,
122
+ stroke_width: outline
123
+ )
124
+ # Feet
125
+ path(
126
+ N.n(at[0]-u*2.9, at[1]+u*11.7),
127
+ N.n(at[0]-u*2, at[1]+u*11.7),
128
+ closed: false,
129
+ fill: "none",
130
+ stroke: stroke,
131
+ stroke_linecap: "round",
132
+ stroke_width: outline
133
+ )
134
+ path(
135
+ N.n(at[0]-u*2.9, at[1]+u*12.3),
136
+ N.n(at[0]-u*2, at[1]+u*12.3),
137
+ closed: false,
138
+ fill: "none",
139
+ stroke: stroke,
140
+ stroke_linecap: "round",
141
+ stroke_width: outline
142
+ )
143
+ path(
144
+ N.n(at[0]+u*8.9, at[1]+u*11.7),
145
+ N.n(at[0]+u*8, at[1]+u*11.7),
146
+ closed: false,
147
+ fill: "none",
148
+ stroke: stroke,
149
+ stroke_linecap: "round",
150
+ stroke_width: outline
151
+ )
152
+ path(
153
+ N.n(at[0]+u*8.9, at[1]+u*12.3),
154
+ N.n(at[0]+u*8, at[1]+u*12.3),
155
+ closed: false,
156
+ fill: "none",
157
+ stroke: stroke,
158
+ stroke_linecap: "round",
159
+ stroke_width: outline
160
+ )
161
+ # Paws
162
+ path(
163
+ N.n(at[0]+u*1.5, at[1]+u*6),
164
+ N.r(at[0]+u*1.5, at[1]+u*7),
165
+ N.l(at[0]+u*3, at[1]+u*7),
166
+ N.n(at[0]+u*3, at[1]+u*6),
167
+ N.r(at[0]+u*3, at[1]+u*7),
168
+ N.l(at[0]+u*4.5, at[1]+u*7),
169
+ N.n(at[0]+u*4.5, at[1]+u*6),
170
+ closed: false,
171
+ fill: "none",
172
+ stroke: "black",
173
+ stroke_width: detail
174
+ )
175
+ path(
176
+ N.n(at[0]+u*2, at[1]+u*7.5),
177
+ N.n(at[0]+u*2, at[1]+u*8),
178
+ closed: false,
179
+ fill: "none",
180
+ stroke: "black",
181
+ stroke_linecap: "round",
182
+ stroke_width: detail
183
+ )
184
+ path(
185
+ N.n(at[0]+u*2.5, at[1]+u*7.5),
186
+ N.n(at[0]+u*2.5, at[1]+u*8),
187
+ closed: false,
188
+ fill: "none",
189
+ stroke: "black",
190
+ stroke_linecap: "round",
191
+ stroke_width: detail
192
+ )
193
+ path(
194
+ N.n(at[0]+u*4, at[1]+u*7.5),
195
+ N.n(at[0]+u*4, at[1]+u*8),
196
+ closed: false,
197
+ fill: "none",
198
+ stroke: "black",
199
+ stroke_linecap: "round",
200
+ stroke_width: detail
201
+ )
202
+ path(
203
+ N.n(at[0]+u*3.5, at[1]+u*7.5),
204
+ N.n(at[0]+u*3.5, at[1]+u*8),
205
+ closed: false,
206
+ fill: "none",
207
+ stroke: "black",
208
+ stroke_linecap: "round",
209
+ stroke_width: detail
210
+ )
211
+ end
212
+ bunny(width/18, at: [width/3, height*0.47])
213
+
214
+ # Grass
215
+ grass_w = 9
216
+ grass_h = height / 7
217
+ (width/grass_w/2).times do |i|
218
+ grass(grass_w, grass_h, at: [i*grass_w*2-Random.rand(0..grass_w), height], fill: "green")
219
+ end