ruby2d-rpeck-windows 0.11.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 (289) hide show
  1. checksums.yaml +7 -0
  2. data/assets/README.md +22 -0
  3. data/assets/Rakefile +85 -0
  4. data/assets/app.icns +0 -0
  5. data/assets/include/SDL2/SDL.h +138 -0
  6. data/assets/include/SDL2/SDL_assert.h +293 -0
  7. data/assets/include/SDL2/SDL_atomic.h +295 -0
  8. data/assets/include/SDL2/SDL_audio.h +859 -0
  9. data/assets/include/SDL2/SDL_bits.h +121 -0
  10. data/assets/include/SDL2/SDL_blendmode.h +123 -0
  11. data/assets/include/SDL2/SDL_clipboard.h +71 -0
  12. data/assets/include/SDL2/SDL_config.h +55 -0
  13. data/assets/include/SDL2/SDL_config_android.h +182 -0
  14. data/assets/include/SDL2/SDL_config_iphoneos.h +207 -0
  15. data/assets/include/SDL2/SDL_config_macosx.h +266 -0
  16. data/assets/include/SDL2/SDL_config_minimal.h +85 -0
  17. data/assets/include/SDL2/SDL_config_os2.h +188 -0
  18. data/assets/include/SDL2/SDL_config_pandora.h +135 -0
  19. data/assets/include/SDL2/SDL_config_psp.h +165 -0
  20. data/assets/include/SDL2/SDL_config_windows.h +288 -0
  21. data/assets/include/SDL2/SDL_config_winrt.h +243 -0
  22. data/assets/include/SDL2/SDL_config_wiz.h +149 -0
  23. data/assets/include/SDL2/SDL_copying.h +20 -0
  24. data/assets/include/SDL2/SDL_cpuinfo.h +299 -0
  25. data/assets/include/SDL2/SDL_egl.h +1676 -0
  26. data/assets/include/SDL2/SDL_endian.h +263 -0
  27. data/assets/include/SDL2/SDL_error.h +112 -0
  28. data/assets/include/SDL2/SDL_events.h +827 -0
  29. data/assets/include/SDL2/SDL_filesystem.h +136 -0
  30. data/assets/include/SDL2/SDL_gamecontroller.h +541 -0
  31. data/assets/include/SDL2/SDL_gesture.h +87 -0
  32. data/assets/include/SDL2/SDL_haptic.h +1247 -0
  33. data/assets/include/SDL2/SDL_hints.h +1578 -0
  34. data/assets/include/SDL2/SDL_image.h +161 -0
  35. data/assets/include/SDL2/SDL_joystick.h +499 -0
  36. data/assets/include/SDL2/SDL_keyboard.h +217 -0
  37. data/assets/include/SDL2/SDL_keycode.h +351 -0
  38. data/assets/include/SDL2/SDL_loadso.h +81 -0
  39. data/assets/include/SDL2/SDL_locale.h +101 -0
  40. data/assets/include/SDL2/SDL_log.h +211 -0
  41. data/assets/include/SDL2/SDL_main.h +180 -0
  42. data/assets/include/SDL2/SDL_messagebox.h +146 -0
  43. data/assets/include/SDL2/SDL_metal.h +117 -0
  44. data/assets/include/SDL2/SDL_misc.h +75 -0
  45. data/assets/include/SDL2/SDL_mixer.h +651 -0
  46. data/assets/include/SDL2/SDL_mouse.h +302 -0
  47. data/assets/include/SDL2/SDL_mutex.h +251 -0
  48. data/assets/include/SDL2/SDL_name.h +33 -0
  49. data/assets/include/SDL2/SDL_opengl.h +2183 -0
  50. data/assets/include/SDL2/SDL_opengl_glext.h +11180 -0
  51. data/assets/include/SDL2/SDL_opengles.h +39 -0
  52. data/assets/include/SDL2/SDL_opengles2.h +52 -0
  53. data/assets/include/SDL2/SDL_opengles2_gl2.h +621 -0
  54. data/assets/include/SDL2/SDL_opengles2_gl2ext.h +2050 -0
  55. data/assets/include/SDL2/SDL_opengles2_gl2platform.h +30 -0
  56. data/assets/include/SDL2/SDL_opengles2_khrplatform.h +282 -0
  57. data/assets/include/SDL2/SDL_pixels.h +479 -0
  58. data/assets/include/SDL2/SDL_platform.h +198 -0
  59. data/assets/include/SDL2/SDL_power.h +75 -0
  60. data/assets/include/SDL2/SDL_quit.h +58 -0
  61. data/assets/include/SDL2/SDL_rect.h +174 -0
  62. data/assets/include/SDL2/SDL_render.h +1158 -0
  63. data/assets/include/SDL2/SDL_revision.h +2 -0
  64. data/assets/include/SDL2/SDL_rwops.h +283 -0
  65. data/assets/include/SDL2/SDL_scancode.h +413 -0
  66. data/assets/include/SDL2/SDL_sensor.h +267 -0
  67. data/assets/include/SDL2/SDL_shape.h +144 -0
  68. data/assets/include/SDL2/SDL_stdinc.h +647 -0
  69. data/assets/include/SDL2/SDL_surface.h +563 -0
  70. data/assets/include/SDL2/SDL_system.h +325 -0
  71. data/assets/include/SDL2/SDL_syswm.h +354 -0
  72. data/assets/include/SDL2/SDL_test.h +69 -0
  73. data/assets/include/SDL2/SDL_test_assert.h +105 -0
  74. data/assets/include/SDL2/SDL_test_common.h +218 -0
  75. data/assets/include/SDL2/SDL_test_compare.h +69 -0
  76. data/assets/include/SDL2/SDL_test_crc32.h +124 -0
  77. data/assets/include/SDL2/SDL_test_font.h +81 -0
  78. data/assets/include/SDL2/SDL_test_fuzzer.h +384 -0
  79. data/assets/include/SDL2/SDL_test_harness.h +134 -0
  80. data/assets/include/SDL2/SDL_test_images.h +78 -0
  81. data/assets/include/SDL2/SDL_test_log.h +67 -0
  82. data/assets/include/SDL2/SDL_test_md5.h +129 -0
  83. data/assets/include/SDL2/SDL_test_memory.h +63 -0
  84. data/assets/include/SDL2/SDL_test_random.h +115 -0
  85. data/assets/include/SDL2/SDL_thread.h +366 -0
  86. data/assets/include/SDL2/SDL_timer.h +115 -0
  87. data/assets/include/SDL2/SDL_touch.h +102 -0
  88. data/assets/include/SDL2/SDL_ttf.h +294 -0
  89. data/assets/include/SDL2/SDL_types.h +29 -0
  90. data/assets/include/SDL2/SDL_version.h +162 -0
  91. data/assets/include/SDL2/SDL_video.h +1282 -0
  92. data/assets/include/SDL2/SDL_vulkan.h +276 -0
  93. data/assets/include/SDL2/begin_code.h +166 -0
  94. data/assets/include/SDL2/close_code.h +40 -0
  95. data/assets/include/glew.h +23686 -0
  96. data/assets/ios/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
  97. data/assets/ios/Assets.xcassets/Contents.json +6 -0
  98. data/assets/ios/Base.lproj/LaunchScreen.storyboard +27 -0
  99. data/assets/ios/Info.plist +43 -0
  100. data/assets/ios/MRuby.framework/Headers/mrbconf.h +143 -0
  101. data/assets/ios/MRuby.framework/Headers/mruby/array.h +280 -0
  102. data/assets/ios/MRuby.framework/Headers/mruby/boxing_nan.h +102 -0
  103. data/assets/ios/MRuby.framework/Headers/mruby/boxing_no.h +56 -0
  104. data/assets/ios/MRuby.framework/Headers/mruby/boxing_word.h +144 -0
  105. data/assets/ios/MRuby.framework/Headers/mruby/class.h +97 -0
  106. data/assets/ios/MRuby.framework/Headers/mruby/common.h +77 -0
  107. data/assets/ios/MRuby.framework/Headers/mruby/compile.h +195 -0
  108. data/assets/ios/MRuby.framework/Headers/mruby/data.h +75 -0
  109. data/assets/ios/MRuby.framework/Headers/mruby/debug.h +67 -0
  110. data/assets/ios/MRuby.framework/Headers/mruby/dump.h +196 -0
  111. data/assets/ios/MRuby.framework/Headers/mruby/error.h +75 -0
  112. data/assets/ios/MRuby.framework/Headers/mruby/gc.h +91 -0
  113. data/assets/ios/MRuby.framework/Headers/mruby/hash.h +215 -0
  114. data/assets/ios/MRuby.framework/Headers/mruby/irep.h +75 -0
  115. data/assets/ios/MRuby.framework/Headers/mruby/istruct.h +47 -0
  116. data/assets/ios/MRuby.framework/Headers/mruby/khash.h +274 -0
  117. data/assets/ios/MRuby.framework/Headers/mruby/numeric.h +161 -0
  118. data/assets/ios/MRuby.framework/Headers/mruby/object.h +44 -0
  119. data/assets/ios/MRuby.framework/Headers/mruby/opcode.h +69 -0
  120. data/assets/ios/MRuby.framework/Headers/mruby/ops.h +117 -0
  121. data/assets/ios/MRuby.framework/Headers/mruby/proc.h +131 -0
  122. data/assets/ios/MRuby.framework/Headers/mruby/range.h +49 -0
  123. data/assets/ios/MRuby.framework/Headers/mruby/re.h +16 -0
  124. data/assets/ios/MRuby.framework/Headers/mruby/string.h +444 -0
  125. data/assets/ios/MRuby.framework/Headers/mruby/throw.h +55 -0
  126. data/assets/ios/MRuby.framework/Headers/mruby/value.h +309 -0
  127. data/assets/ios/MRuby.framework/Headers/mruby/variable.h +136 -0
  128. data/assets/ios/MRuby.framework/Headers/mruby/version.h +110 -0
  129. data/assets/ios/MRuby.framework/Headers/mruby.h +1282 -0
  130. data/assets/ios/MRuby.framework/Info.plist +20 -0
  131. data/assets/ios/MRuby.framework/MRuby +0 -0
  132. data/assets/ios/MyApp.xcodeproj/project.pbxproj +368 -0
  133. data/assets/ios/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  134. data/assets/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  135. data/assets/ios/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +30 -0
  136. data/assets/ios/main.c +1 -0
  137. data/assets/macos/lib/libFLAC.a +0 -0
  138. data/assets/macos/lib/libSDL2.a +0 -0
  139. data/assets/macos/lib/libSDL2_image.a +0 -0
  140. data/assets/macos/lib/libSDL2_mixer.a +0 -0
  141. data/assets/macos/lib/libSDL2_ttf.a +0 -0
  142. data/assets/macos/lib/libfreetype.a +0 -0
  143. data/assets/macos/lib/libjpeg.a +0 -0
  144. data/assets/macos/lib/libmodplug.a +0 -0
  145. data/assets/macos/lib/libmpg123.a +0 -0
  146. data/assets/macos/lib/libogg.a +0 -0
  147. data/assets/macos/lib/libpng16.a +0 -0
  148. data/assets/macos/lib/libtiff.a +0 -0
  149. data/assets/macos/lib/libvorbis.a +0 -0
  150. data/assets/macos/lib/libvorbisfile.a +0 -0
  151. data/assets/macos/lib/libwebp.a +0 -0
  152. data/assets/mingw/bin/SDL2.dll +0 -0
  153. data/assets/mingw/bin/SDL2_image.dll +0 -0
  154. data/assets/mingw/bin/SDL2_mixer.dll +0 -0
  155. data/assets/mingw/bin/SDL2_ttf.dll +0 -0
  156. data/assets/mingw/bin/glew32.dll +0 -0
  157. data/assets/mingw/bin/libFLAC-8.dll +0 -0
  158. data/assets/mingw/bin/libfreetype-6.dll +0 -0
  159. data/assets/mingw/bin/libjpeg-9.dll +0 -0
  160. data/assets/mingw/bin/libmodplug-1.dll +0 -0
  161. data/assets/mingw/bin/libmpg123-0.dll +0 -0
  162. data/assets/mingw/bin/libogg-0.dll +0 -0
  163. data/assets/mingw/bin/libopus-0.dll +0 -0
  164. data/assets/mingw/bin/libopusfile-0.dll +0 -0
  165. data/assets/mingw/bin/libpng16-16.dll +0 -0
  166. data/assets/mingw/bin/libtiff-5.dll +0 -0
  167. data/assets/mingw/bin/libvorbis-0.dll +0 -0
  168. data/assets/mingw/bin/libvorbisfile-3.dll +0 -0
  169. data/assets/mingw/bin/libwebp-7.dll +0 -0
  170. data/assets/mingw/bin/libwinpthread-1.dll +0 -0
  171. data/assets/mingw/bin/zlib1.dll +0 -0
  172. data/assets/mingw/lib/libSDL2.a +0 -0
  173. data/assets/mingw/lib/libSDL2.dll.a +0 -0
  174. data/assets/mingw/lib/libSDL2_image.a +0 -0
  175. data/assets/mingw/lib/libSDL2_image.dll.a +0 -0
  176. data/assets/mingw/lib/libSDL2_mixer.a +0 -0
  177. data/assets/mingw/lib/libSDL2_mixer.dll.a +0 -0
  178. data/assets/mingw/lib/libSDL2_test.a +0 -0
  179. data/assets/mingw/lib/libSDL2_ttf.a +0 -0
  180. data/assets/mingw/lib/libSDL2_ttf.dll.a +0 -0
  181. data/assets/mingw/lib/libSDL2main.a +0 -0
  182. data/assets/mingw/lib/libglew32.a +0 -0
  183. data/assets/mingw/lib/libglew32.dll.a +0 -0
  184. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +16 -0
  185. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Back.imagestacklayer/Contents.json +6 -0
  186. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Contents.json +17 -0
  187. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +16 -0
  188. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Front.imagestacklayer/Contents.json +6 -0
  189. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +16 -0
  190. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Large.imagestack/Middle.imagestacklayer/Contents.json +6 -0
  191. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Content.imageset/Contents.json +16 -0
  192. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Back.imagestacklayer/Contents.json +6 -0
  193. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Contents.json +17 -0
  194. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Content.imageset/Contents.json +16 -0
  195. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Front.imagestacklayer/Contents.json +6 -0
  196. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Content.imageset/Contents.json +16 -0
  197. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/App Icon - Small.imagestack/Middle.imagestacklayer/Contents.json +6 -0
  198. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Contents.json +32 -0
  199. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image Wide.imageset/Contents.json +16 -0
  200. data/assets/tvos/Assets.xcassets/App Icon & Top Shelf Image.brandassets/Top Shelf Image.imageset/Contents.json +16 -0
  201. data/assets/tvos/Assets.xcassets/Contents.json +6 -0
  202. data/assets/tvos/Assets.xcassets/LaunchImage.launchimage/Contents.json +22 -0
  203. data/assets/tvos/Info.plist +30 -0
  204. data/assets/tvos/MRuby.framework/Headers/mrbconf.h +143 -0
  205. data/assets/tvos/MRuby.framework/Headers/mruby/array.h +280 -0
  206. data/assets/tvos/MRuby.framework/Headers/mruby/boxing_nan.h +102 -0
  207. data/assets/tvos/MRuby.framework/Headers/mruby/boxing_no.h +56 -0
  208. data/assets/tvos/MRuby.framework/Headers/mruby/boxing_word.h +144 -0
  209. data/assets/tvos/MRuby.framework/Headers/mruby/class.h +97 -0
  210. data/assets/tvos/MRuby.framework/Headers/mruby/common.h +77 -0
  211. data/assets/tvos/MRuby.framework/Headers/mruby/compile.h +195 -0
  212. data/assets/tvos/MRuby.framework/Headers/mruby/data.h +75 -0
  213. data/assets/tvos/MRuby.framework/Headers/mruby/debug.h +67 -0
  214. data/assets/tvos/MRuby.framework/Headers/mruby/dump.h +196 -0
  215. data/assets/tvos/MRuby.framework/Headers/mruby/error.h +75 -0
  216. data/assets/tvos/MRuby.framework/Headers/mruby/gc.h +91 -0
  217. data/assets/tvos/MRuby.framework/Headers/mruby/hash.h +215 -0
  218. data/assets/tvos/MRuby.framework/Headers/mruby/irep.h +75 -0
  219. data/assets/tvos/MRuby.framework/Headers/mruby/istruct.h +47 -0
  220. data/assets/tvos/MRuby.framework/Headers/mruby/khash.h +274 -0
  221. data/assets/tvos/MRuby.framework/Headers/mruby/numeric.h +161 -0
  222. data/assets/tvos/MRuby.framework/Headers/mruby/object.h +44 -0
  223. data/assets/tvos/MRuby.framework/Headers/mruby/opcode.h +69 -0
  224. data/assets/tvos/MRuby.framework/Headers/mruby/ops.h +117 -0
  225. data/assets/tvos/MRuby.framework/Headers/mruby/proc.h +131 -0
  226. data/assets/tvos/MRuby.framework/Headers/mruby/range.h +49 -0
  227. data/assets/tvos/MRuby.framework/Headers/mruby/re.h +16 -0
  228. data/assets/tvos/MRuby.framework/Headers/mruby/string.h +444 -0
  229. data/assets/tvos/MRuby.framework/Headers/mruby/throw.h +55 -0
  230. data/assets/tvos/MRuby.framework/Headers/mruby/value.h +309 -0
  231. data/assets/tvos/MRuby.framework/Headers/mruby/variable.h +136 -0
  232. data/assets/tvos/MRuby.framework/Headers/mruby/version.h +110 -0
  233. data/assets/tvos/MRuby.framework/Headers/mruby.h +1282 -0
  234. data/assets/tvos/MRuby.framework/Info.plist +20 -0
  235. data/assets/tvos/MRuby.framework/MRuby +0 -0
  236. data/assets/tvos/MyApp.xcodeproj/project.pbxproj +350 -0
  237. data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  238. data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  239. data/assets/tvos/MyApp.xcodeproj/project.xcworkspace/xcshareddata/MyApp.xcscmblueprint +30 -0
  240. data/assets/tvos/main.c +1 -0
  241. data/bin/ruby2d +142 -0
  242. data/ext/ruby2d/common.c +185 -0
  243. data/ext/ruby2d/controllers.c +110 -0
  244. data/ext/ruby2d/extconf.rb +147 -0
  245. data/ext/ruby2d/font.c +35 -0
  246. data/ext/ruby2d/gl.c +398 -0
  247. data/ext/ruby2d/gl2.c +86 -0
  248. data/ext/ruby2d/gl3.c +305 -0
  249. data/ext/ruby2d/gles.c +249 -0
  250. data/ext/ruby2d/image.c +58 -0
  251. data/ext/ruby2d/input.c +48 -0
  252. data/ext/ruby2d/music.c +127 -0
  253. data/ext/ruby2d/ruby2d.c +1374 -0
  254. data/ext/ruby2d/ruby2d.h +656 -0
  255. data/ext/ruby2d/shapes.c +154 -0
  256. data/ext/ruby2d/sound.c +118 -0
  257. data/ext/ruby2d/text.c +22 -0
  258. data/ext/ruby2d/window.c +414 -0
  259. data/lib/ruby2d/circle.rb +43 -0
  260. data/lib/ruby2d/cli/build.rb +237 -0
  261. data/lib/ruby2d/cli/colorize.rb +10 -0
  262. data/lib/ruby2d/cli/console.rb +65 -0
  263. data/lib/ruby2d/cli/enable_console.rb +5 -0
  264. data/lib/ruby2d/cli/launch.rb +50 -0
  265. data/lib/ruby2d/color.rb +136 -0
  266. data/lib/ruby2d/dsl.rb +46 -0
  267. data/lib/ruby2d/entity.rb +17 -0
  268. data/lib/ruby2d/exceptions.rb +6 -0
  269. data/lib/ruby2d/font.rb +96 -0
  270. data/lib/ruby2d/image.rb +58 -0
  271. data/lib/ruby2d/line.rb +89 -0
  272. data/lib/ruby2d/music.rb +67 -0
  273. data/lib/ruby2d/pixel.rb +17 -0
  274. data/lib/ruby2d/quad.rb +96 -0
  275. data/lib/ruby2d/rectangle.rb +65 -0
  276. data/lib/ruby2d/renderable.rb +40 -0
  277. data/lib/ruby2d/ruby2d.so +0 -0
  278. data/lib/ruby2d/sound.rb +55 -0
  279. data/lib/ruby2d/sprite.rb +232 -0
  280. data/lib/ruby2d/square.rb +37 -0
  281. data/lib/ruby2d/text.rb +76 -0
  282. data/lib/ruby2d/texture.rb +28 -0
  283. data/lib/ruby2d/tileset.rb +87 -0
  284. data/lib/ruby2d/triangle.rb +82 -0
  285. data/lib/ruby2d/version.rb +5 -0
  286. data/lib/ruby2d/vertices.rb +84 -0
  287. data/lib/ruby2d/window.rb +673 -0
  288. data/lib/ruby2d.rb +69 -0
  289. metadata +346 -0
@@ -0,0 +1,43 @@
1
+ # Ruby2D::Circle
2
+
3
+ module Ruby2D
4
+ class Circle
5
+ include Renderable
6
+
7
+ attr_accessor :x, :y, :radius, :sectors
8
+
9
+ def initialize(opts = {})
10
+ @x = opts[:x] || 25
11
+ @y = opts[:y] || 25
12
+ @z = opts[:z] || 0
13
+ @radius = opts[:radius] || 50
14
+ @sectors = opts[:sectors] || 30
15
+ self.color = opts[:color] || 'white'
16
+ self.color.opacity = opts[:opacity] if opts[:opacity]
17
+ add
18
+ end
19
+
20
+ def contains?(x, y)
21
+ Math.sqrt((x - @x)**2 + (y - @y)**2) <= @radius
22
+ end
23
+
24
+ def self.draw(opts = {})
25
+ Window.render_ready_check
26
+
27
+ ext_draw([
28
+ opts[:x], opts[:y], opts[:radius], opts[:sectors],
29
+ opts[:color][0], opts[:color][1], opts[:color][2], opts[:color][3]
30
+ ])
31
+ end
32
+
33
+ private
34
+
35
+ def render
36
+ self.class.ext_draw([
37
+ @x, @y, @radius, @sectors,
38
+ @color.r, @color.g, @color.b, @color.a
39
+ ])
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,237 @@
1
+ # Build a Ruby 2D app natively and for the web
2
+
3
+ require 'fileutils'
4
+
5
+ # The installed gem directory
6
+ @gem_dir = "#{Gem::Specification.find_by_name('ruby2d').gem_dir}"
7
+
8
+ # The Ruby 2D library files
9
+ @lib_files = [
10
+ 'cli/colorize',
11
+ 'exceptions',
12
+ 'renderable',
13
+ 'color',
14
+ 'window',
15
+ 'dsl',
16
+ 'quad',
17
+ 'line',
18
+ 'circle',
19
+ 'rectangle',
20
+ 'square',
21
+ 'triangle',
22
+ 'image',
23
+ 'sprite',
24
+ 'font',
25
+ 'text',
26
+ 'sound',
27
+ 'music',
28
+ 'texture',
29
+ 'vertices',
30
+ '../ruby2d'
31
+ ]
32
+
33
+
34
+ # Check if source file provided is good
35
+ def check_build_src_file(rb_file)
36
+ if !rb_file
37
+ puts "Please provide a Ruby file to build"
38
+ exit
39
+ elsif !File.exist? rb_file
40
+ puts "Can't find file: #{rb_file}"
41
+ exit
42
+ end
43
+ end
44
+
45
+
46
+ # Assemble the Ruby 2D library in one `.rb` file
47
+ def make_lib
48
+ FileUtils.mkdir_p 'build'
49
+
50
+ lib_dir = "#{@gem_dir}/lib/ruby2d/"
51
+
52
+ lib = ''
53
+ @lib_files.each do |f|
54
+ lib << File.read("#{lib_dir + f}.rb") + "\n\n"
55
+ end
56
+
57
+ File.write('build/lib.rb', lib)
58
+ end
59
+
60
+
61
+ # Remove `require 'ruby2d'` from source file
62
+ def strip_require(file)
63
+ output = ''
64
+ File.foreach(file) do |line|
65
+ output << line if line !~ /require ('|")ruby2d('|")/ && line !~ /require/
66
+
67
+ if line !~ /require ('|")ruby2d('|")/ && line =~ /require/ && line !~ /require_relative/
68
+ output << File.read(eval(line.gsub("require", "")) + ".rb")
69
+ output << " "
70
+ end
71
+ end
72
+ return output
73
+ end
74
+
75
+
76
+ # Build a native version of the provided Ruby application
77
+ def build_native(rb_file)
78
+ check_build_src_file(rb_file)
79
+
80
+ # Check if MRuby exists; if not, quit
81
+ if `#{RUBY_PLATFORM =~ /mingw/ ? 'where' : 'which'} mruby`.empty?
82
+ puts "#{'Error:'.error} Can't find MRuby, which is needed to build native Ruby 2D applications.\n"
83
+ exit
84
+ end
85
+
86
+ # Add debugging information to produce backtrace
87
+ if @debug then debug_flag = '-g' end
88
+
89
+ # Assemble the Ruby 2D library in one `.rb` file and compile to bytecode
90
+ make_lib
91
+ `mrbc #{debug_flag} -Bruby2d_lib -obuild/lib.c build/lib.rb`
92
+
93
+ # Read the provided Ruby source file, copy to build dir and compile to bytecode
94
+ File.open('build/src.rb', 'w') { |file| file << strip_require(rb_file) }
95
+ `mrbc #{debug_flag} -Bruby2d_app -obuild/src.c build/src.rb`
96
+
97
+ # Combine contents of C source files and bytecode into one file
98
+ open('build/app.c', 'w') do |f|
99
+ f << "#define MRUBY 1" << "\n\n"
100
+ f << File.read("build/lib.c") << "\n\n"
101
+ f << File.read("build/src.c") << "\n\n"
102
+ f << File.read("#{@gem_dir}/ext/ruby2d/ruby2d.c")
103
+ end
104
+
105
+ # Icon
106
+ if RUBY_PLATFORM =~ /mingw/
107
+ open('build/icon.rc', 'w') do |f|
108
+ f << 'id ICON "icon.ico"'
109
+ end
110
+ `windres build/icon.rc build/icon.o`
111
+ end
112
+
113
+ # Compile to a native executable
114
+ `cc build/icon.o build/app.c #{@gem_dir}/ext/ruby2d/common.c #{@gem_dir}/ext/ruby2d/controllers.c #{@gem_dir}/ext/ruby2d/gl.c #{@gem_dir}/ext/ruby2d/gl2.c #{@gem_dir}/ext/ruby2d/gl3.c #{@gem_dir}/ext/ruby2d/gles.c #{@gem_dir}/ext/ruby2d/font.c #{@gem_dir}/ext/ruby2d/image.c #{@gem_dir}/ext/ruby2d/input.c #{@gem_dir}/ext/ruby2d/music.c #{@gem_dir}/ext/ruby2d/shapes.c #{@gem_dir}/ext/ruby2d/sound.c #{@gem_dir}/ext/ruby2d/text.c #{@gem_dir}/ext/ruby2d/window.c -I#{@gem_dir}/ext/ruby2d -I#{@gem_dir}/assets/include -LC:/Dev/mruby-3.0.0/build/host/lib -IC:/MSYS2/mingw64/include/ruby-3.0.0 -IC:/MSYS2/mingw64/include/ruby-3.0.0/x64-mingw32 -IC:/Dev/mruby-3.0.0/include -lmruby -lws2_32 -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lopengl32 -lglew32 -o build/app`
115
+
116
+ # Clean up
117
+ clean_up unless @debug
118
+
119
+ # Success!
120
+ puts "Native app created at `build/app`"
121
+ end
122
+
123
+
124
+ # Build a web-based version of the provided Ruby application
125
+ def build_web(rb_file)
126
+ puts "Warning: ".warn + "This feature is currently disabled while it's being upgraded."
127
+ end
128
+
129
+
130
+ # Build an app bundle for macOS
131
+ def build_macos(rb_file)
132
+
133
+ # Build native app for macOS
134
+ build_native(rb_file)
135
+
136
+ # Property list source for the bundle
137
+ info_plist = %(
138
+ <?xml version="1.0" encoding="UTF-8"?>
139
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
140
+ <plist version="1.0">
141
+ <dict>
142
+ <key>CFBundleExecutable</key>
143
+ <string>app</string>
144
+ <key>CFBundleIconFile</key>
145
+ <string>app.icns</string>
146
+ <key>CFBundleInfoDictionaryVersion</key>
147
+ <string>6.0</string>
148
+ <key>CFBundlePackageType</key>
149
+ <string>APPL</string>
150
+ <key>CFBundleVersion</key>
151
+ <string>1</string>
152
+ <key>NSHighResolutionCapable</key>
153
+ <string>True</string>
154
+ </dict>
155
+ </plist>
156
+ )
157
+
158
+ # Create directories
159
+ FileUtils.mkpath 'build/App.app/Contents/MacOS'
160
+ FileUtils.mkpath 'build/App.app/Contents/Resources'
161
+
162
+ # Create Info.plist and copy over assets
163
+ File.open('build/App.app/Contents/Info.plist', 'w') { |f| f.write(info_plist) }
164
+ FileUtils.cp 'build/app', 'build/App.app/Contents/MacOS/'
165
+ # Consider using an icon:
166
+ # FileUtils.cp "#{@gem_dir}/assets/app.icns", 'build/App.app/Contents/Resources'
167
+
168
+ # Clean up
169
+ FileUtils.rm_f 'build/app' unless @debug
170
+
171
+ # Success!
172
+ puts 'macOS app bundle created: `build/App.app`'
173
+ end
174
+
175
+
176
+ # Build an iOS or tvOS app
177
+ def build_ios_tvos(rb_file, device)
178
+ check_build_src_file(rb_file)
179
+
180
+ # Check if MRuby exists; if not, quit
181
+ if `which mruby`.empty?
182
+ puts "#{'Error:'.error} Can't find MRuby, which is needed to build native Ruby 2D applications.\n"
183
+ exit
184
+ end
185
+
186
+ # Add debugging information to produce backtrace
187
+ if @debug then debug_flag = '-g' end
188
+
189
+ # Assemble the Ruby 2D library in one `.rb` file and compile to bytecode
190
+ make_lib
191
+ `mrbc #{debug_flag} -Bruby2d_lib -obuild/lib.c build/lib.rb`
192
+
193
+ # Read the provided Ruby source file, copy to build dir and compile to bytecode
194
+ File.open('build/src.rb', 'w') { |file| file << strip_require(rb_file) }
195
+ `mrbc #{debug_flag} -Bruby2d_app -obuild/src.c build/src.rb`
196
+
197
+ # Copy over iOS project
198
+ FileUtils.cp_r "#{@gem_dir}/assets/#{device}", "build"
199
+
200
+ # Combine contents of C source files and bytecode into one file
201
+ File.open("build/#{device}/main.c", 'w') do |f|
202
+ f << "#define RUBY2D_IOS_TVOS 1" << "\n\n"
203
+ f << "#define MRUBY 1" << "\n\n"
204
+ f << File.read("build/lib.c") << "\n\n"
205
+ f << File.read("build/src.c") << "\n\n"
206
+ f << File.read("#{@gem_dir}/ext/ruby2d/ruby2d.c")
207
+ end
208
+
209
+ # TODO: Need add this functionality to the gem
210
+ # Build the Xcode project
211
+ `simple2d build --#{device} build/#{device}/MyApp.xcodeproj`
212
+
213
+ # Clean up
214
+ clean_up unless @debug
215
+
216
+ # Success!
217
+ puts "App created: `build/#{device}`"
218
+ end
219
+
220
+
221
+ # Clean up unneeded build files
222
+ def clean_up(cmd = nil)
223
+ FileUtils.rm(
224
+ Dir.glob('build/{src,lib}.{rb,c,js}') +
225
+ Dir.glob('build/app.c') +
226
+ Dir.glob('build/*{o,rc}')
227
+ )
228
+ if cmd == :all
229
+ puts "cleaning up..."
230
+ FileUtils.rm_f 'build/app'
231
+ FileUtils.rm_f 'build/app.js'
232
+ FileUtils.rm_f 'build/app.html'
233
+ FileUtils.rm_rf 'build/App.app'
234
+ FileUtils.rm_rf 'build/ios'
235
+ FileUtils.rm_rf 'build/tvos'
236
+ end
237
+ end
@@ -0,0 +1,10 @@
1
+ # String#ruby2d_colorize
2
+
3
+ # Extend `String` to include some fancy colors
4
+ class String
5
+ def ruby2d_colorize(c); "\e[#{c}m#{self}\e[0m" end
6
+ def bold; ruby2d_colorize('1') end
7
+ def info; ruby2d_colorize('1;34') end
8
+ def warn; ruby2d_colorize('1;33') end
9
+ def error; ruby2d_colorize('1;31') end
10
+ end
@@ -0,0 +1,65 @@
1
+ # Interactive Ruby 2D console
2
+
3
+ # Save the Ruby file from the command-line arguments
4
+ rb_file = ARGV[1]
5
+
6
+ # Check if source file provided is good
7
+ if !rb_file
8
+ puts "Provide a Ruby file to run"
9
+ exit 1
10
+ elsif !File.exist? rb_file
11
+ puts "Can't find file: #{rb_file}"
12
+ exit 1
13
+ end
14
+
15
+ # Add libraries
16
+ require 'open3'
17
+ require 'readline'
18
+ require 'io/wait'
19
+
20
+ line = 1 # the current line number
21
+
22
+ # Open a new process for the Ruby file
23
+ stdin, stdout, stderr, wait_thr = Open3.popen3("ruby -r 'ruby2d/cli/enable_console' #{rb_file}")
24
+
25
+ # Request input and send commands
26
+ loop do
27
+
28
+ # Read the next command
29
+ cmd = Readline.readline("ruby2d:#{line}> ", true)
30
+
31
+ # Quit if command is 'exit'
32
+ if cmd == 'exit'
33
+ Process.kill 'INT', wait_thr.pid
34
+ wait_thr.value
35
+ exit
36
+ end
37
+
38
+ # Try sending commands
39
+ begin
40
+
41
+ # Skip if command is an empty string
42
+ unless cmd.empty?
43
+
44
+ # Send command to the Ruby file
45
+ stdin.puts cmd
46
+
47
+ # Read and print output from the Ruby file
48
+ puts stdout.gets
49
+ while stdout.ready? do
50
+ puts stdout.gets
51
+ end
52
+
53
+ end
54
+
55
+ # Increment the line number
56
+ line += 1
57
+
58
+ # Rescue exception if can't send commands to the Ruby 2D window
59
+ rescue Errno::EPIPE
60
+ puts "Can't connect to the window (was it closed?)",
61
+ "For help, see: ruby2d.com/learn/console"
62
+ exit 1
63
+ end
64
+
65
+ end
@@ -0,0 +1,5 @@
1
+ # Enable the interactive console
2
+
3
+ require 'io/wait'
4
+
5
+ $ruby2d_console_mode = true
@@ -0,0 +1,50 @@
1
+ # Launch a built Ruby 2D app
2
+
3
+ # Launch a native app
4
+ def launch_native
5
+ if !File.exist? 'build/app'
6
+ puts "No native app built!"
7
+ exit
8
+ end
9
+ `( cd build && ./app )`
10
+ end
11
+
12
+
13
+ # Launch a web app
14
+ def launch_web
15
+ if !File.exist? 'build/app.html'
16
+ puts "No web app built!"
17
+ exit
18
+ end
19
+ open_cmd = 'open'
20
+ case RUBY_PLATFORM
21
+ when /linux/
22
+ open_cmd = "xdg-#{open_cmd}"
23
+ when /mingw/
24
+ open_cmd = "start"
25
+ end
26
+ system "#{open_cmd} build/app.html"
27
+ end
28
+
29
+
30
+ # Launch an iOS or tvOS app in a simulator
31
+ def launch_apple(device)
32
+ case device
33
+ when 'ios'
34
+ if !File.exist? 'build/ios/build/Release-iphonesimulator/MyApp.app'
35
+ puts "No iOS app built!"
36
+ exit
37
+ end
38
+ puts `simple2d simulator --open "iPhone X" &&
39
+ simple2d simulator --install "build/ios/build/Release-iphonesimulator/MyApp.app" &&
40
+ simple2d simulator --launch "Ruby2D.MyApp"`
41
+ when 'tvos'
42
+ if !File.exist? 'build/tvos/build/Release-appletvsimulator/MyApp.app'
43
+ puts "No tvOS app built!"
44
+ exit
45
+ end
46
+ puts `simple2d simulator --open "Apple TV 4K" &&
47
+ simple2d simulator --install "build/tvos/build/Release-appletvsimulator/MyApp.app" &&
48
+ simple2d simulator --launch "Ruby2D.MyApp"`
49
+ end
50
+ end
@@ -0,0 +1,136 @@
1
+ # Ruby2D::Color
2
+
3
+ module Ruby2D
4
+ class Color
5
+
6
+ # Color::Set represents an array of colors
7
+ class Set
8
+ def initialize(colors)
9
+ @colors = colors.map { |c| Color.new(c) }
10
+ end
11
+
12
+ def [](i)
13
+ @colors[i]
14
+ end
15
+
16
+ def length
17
+ @colors.length
18
+ end
19
+
20
+ def opacity; @colors[0].opacity end
21
+
22
+ def opacity=(opacity)
23
+ @colors.each do |color|
24
+ color.opacity = opacity
25
+ end
26
+ end
27
+ end
28
+
29
+ attr_accessor :r, :g, :b, :a
30
+
31
+ # Based on clrs.cc
32
+ @@colors = {
33
+ 'navy' => '#001F3F',
34
+ 'blue' => '#0074D9',
35
+ 'aqua' => '#7FDBFF',
36
+ 'teal' => '#39CCCC',
37
+ 'olive' => '#3D9970',
38
+ 'green' => '#2ECC40',
39
+ 'lime' => '#01FF70',
40
+ 'yellow' => '#FFDC00',
41
+ 'orange' => '#FF851B',
42
+ 'red' => '#FF4136',
43
+ 'brown' => '#663300',
44
+ 'fuchsia' => '#F012BE',
45
+ 'purple' => '#B10DC9',
46
+ 'maroon' => '#85144B',
47
+ 'white' => '#FFFFFF',
48
+ 'silver' => '#DDDDDD',
49
+ 'gray' => '#AAAAAA',
50
+ 'black' => '#111111',
51
+ 'random' => ''
52
+ }
53
+
54
+ def initialize(c)
55
+ if !self.class.is_valid? c
56
+ raise Error, "`#{c}` is not a valid color"
57
+ else
58
+ case c
59
+ when String
60
+ if c == 'random'
61
+ @r, @g, @b, @a = rand, rand, rand, 1.0
62
+ elsif self.class.is_hex?(c)
63
+ @r, @g, @b, @a = hex_to_f(c)
64
+ else
65
+ @r, @g, @b, @a = hex_to_f(@@colors[c])
66
+ end
67
+ when Array
68
+ @r, @g, @b, @a = [c[0], c[1], c[2], c[3]]
69
+ when Color
70
+ @r, @g, @b, @a = [c.r, c.g, c.b, c.a]
71
+ end
72
+ end
73
+ end
74
+
75
+ # Return a color set if an array of valid colors
76
+ def self.set(colors)
77
+ # If a valid array of colors, return a `Color::Set` with those colors
78
+ if colors.is_a?(Array) && colors.all? { |el| Color.is_valid? el }
79
+ Color::Set.new(colors)
80
+ # Otherwise, return single color
81
+ else
82
+ Color.new(colors)
83
+ end
84
+ end
85
+
86
+ # Check if string is a proper hex value
87
+ def self.is_hex?(s)
88
+ # MRuby doesn't support regex, otherwise we'd do:
89
+ # !(/^#[0-9A-F]{6}$/i.match(a).nil?)
90
+ s.class == String && s[0] == '#' && s.length == 7
91
+ end
92
+
93
+ # Check if the color is valid
94
+ def self.is_valid?(c)
95
+ c.is_a?(Color) || # color object
96
+ @@colors.key?(c) || # keyword
97
+ self.is_hex?(c) || # hexadecimal value
98
+
99
+ # Array of Floats from 0.0..1.0
100
+ c.class == Array && c.length == 4 &&
101
+ c.all? { |el| el.is_a?(Numeric) }
102
+ end
103
+
104
+ # Convenience methods to alias `opacity` to `@a`
105
+ def opacity; @a end
106
+ def opacity=(opacity); @a = opacity end
107
+
108
+ private
109
+
110
+ # Convert from Fixnum (0..255) to Float (0.0..1.0)
111
+ def to_f(a)
112
+ b = []
113
+ a.each do |n|
114
+ b.push(n / 255.0)
115
+ end
116
+ return b
117
+ end
118
+
119
+ # Convert from hex value (e.g. #FFF000) to Float (0.0..1.0)
120
+ def hex_to_f(h)
121
+ h = (h[1..-1]).chars.each_slice(2).map(&:join)
122
+ a = []
123
+
124
+ h.each do |el|
125
+ a.push(el.to_i(16))
126
+ end
127
+
128
+ a.push(255)
129
+ return to_f(a)
130
+ end
131
+
132
+ end
133
+
134
+ # Allow British English spelling of color
135
+ Colour = Color
136
+ end
data/lib/ruby2d/dsl.rb ADDED
@@ -0,0 +1,46 @@
1
+ # Ruby2D::DSL
2
+
3
+ module Ruby2D::DSL
4
+
5
+ @window = Ruby2D::Window.new
6
+
7
+ def self.window; @window end
8
+ def self.window=(w); @window = w end
9
+
10
+ def get(sym, opts = nil)
11
+ DSL.window.get(sym, opts)
12
+ end
13
+
14
+ def set(opts)
15
+ DSL.window.set(opts)
16
+ end
17
+
18
+ def on(event, &proc)
19
+ DSL.window.on(event, &proc)
20
+ end
21
+
22
+ def off(event_descriptor)
23
+ DSL.window.off(event_descriptor)
24
+ end
25
+
26
+ def update(&proc)
27
+ DSL.window.update(&proc)
28
+ end
29
+
30
+ def render(&proc)
31
+ DSL.window.render(&proc)
32
+ end
33
+
34
+ def clear
35
+ DSL.window.clear
36
+ end
37
+
38
+ def show
39
+ DSL.window.show
40
+ end
41
+
42
+ def close
43
+ DSL.window.close
44
+ end
45
+
46
+ end
@@ -0,0 +1,17 @@
1
+ # Ruby2D::Entity
2
+
3
+ module Ruby2D
4
+ class Entity
5
+
6
+ # Add the entity to the window
7
+ def add
8
+ Window.add(self)
9
+ end
10
+
11
+ # Remove the entity from the window
12
+ def remove
13
+ Window.remove(self)
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ # Ruby2D::Error
2
+
3
+ module Ruby2D
4
+ class Error < StandardError
5
+ end
6
+ end