stylet 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.travis.yml +4 -0
  4. data/.yardopts +2 -0
  5. data/Gemfile +16 -0
  6. data/README.org +19 -0
  7. data/Rakefile +17 -0
  8. data/bin/setup +63 -0
  9. data/bin/stylet +8 -0
  10. data/examples/.ruby-version +1 -0
  11. data/examples/00100_lib_hello_world.rb +8 -0
  12. data/examples/00110_lib_sge_check.rb +6 -0
  13. data/examples/00120_lib_/343/202/254/343/203/263/343/203/236/345/200/244/343/201/256/345/244/211/346/233/264.rb +22 -0
  14. data/examples/00130_lib_window_title.rb +8 -0
  15. data/examples/00140_lib_callbacks.rb +8 -0
  16. data/examples/00150_lib_vector.rb +5 -0
  17. data/examples/00160_lib_run.rb +4 -0
  18. data/examples/00170_lib_frame.rb +4 -0
  19. data/examples/00180_lib_config/347/242/272/350/252/215.rb +7 -0
  20. data/examples/00190_lib_/343/201/231/343/201/271/343/201/246/345/220/214/343/201/230/343/202/252/343/203/226/343/202/270/343/202/247/343/202/257/343/203/210.rb +10 -0
  21. data/examples/00200_lib_/343/203/254/343/202/267/343/203/274/343/203/220/343/203/274/343/202/222/347/234/201/347/225/245/343/201/231/343/202/213/346/226/271/346/263/225/343/201/256/343/203/206/343/202/271/343/203/210.rb +28 -0
  22. data/examples/00210_lib_delegators.rb +7 -0
  23. data/examples/00220_lib_template_method.rb +13 -0
  24. data/examples/00230_lib_/350/203/214/346/231/257/347/224/273/345/203/217/350/241/250/347/244/272.rb +9 -0
  25. data/examples/00240_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2171_/351/273/222/343/201/256/344/270/212/343/201/253/350/203/214/346/231/257.rb +18 -0
  26. data/examples/00250_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2172_/350/203/214/346/231/257/343/201/256/344/270/212/343/201/253/351/273/222.rb +17 -0
  27. data/examples/00260_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2173_/350/203/214/346/231/257/343/201/256/344/270/212/343/201/253/351/273/222_/347/224/273/351/235/242/343/202/265/343/202/244/343/202/272/343/203/225/343/202/243/343/203/203/343/203/210_/351/207/215/343/201/204.rb +27 -0
  28. data/examples/00270_lib_/350/203/214/346/231/257/347/224/273/345/203/217/343/202/222/346/232/227/343/201/2173_/350/203/214/346/231/257/343/201/256/344/270/212/343/201/253/351/273/222_/347/224/273/351/235/242/343/202/265/343/202/244/343/202/272/343/203/225/343/202/243/343/203/203/343/203/210_/351/253/230/351/200/237/345/214/226.rb +44 -0
  29. data/examples/00280_lib_/347/211/271/345/256/232/343/201/256/343/202/250/343/203/252/343/202/242/343/201/240/343/201/221/345/276/220/343/200/205/343/201/253/346/266/210/343/201/231.rb +26 -0
  30. data/examples/00290_lib_/350/203/214/346/231/257/350/211/262/345/244/211/346/233/264.rb +5 -0
  31. data/examples/00300_lib_/343/202/255/343/203/243/343/203/251/343/202/257/343/202/277/347/224/273/345/203/217/343/202/222/350/241/250/347/244/272/343/201/231/343/202/213/344/276/213.rb +17 -0
  32. data/examples/00310_lib_/343/202/255/343/203/243/343/203/251/343/202/257/343/202/277/347/224/273/345/203/217/343/201/256/343/202/242/343/203/213/343/203/241/343/203/274/343/202/267/343/203/247/343/203/263.rb +18 -0
  33. data/examples/00320_lib_/343/202/255/343/203/243/343/203/251/343/202/257/343/202/277/346/213/241/345/244/247/347/270/256/345/260/217/345/233/236/350/273/242.rb +21 -0
  34. data/examples/00330_joystick.rb +5 -0
  35. data/examples/00340_joystick_PS3/343/202/242/343/203/212/343/203/255/343/202/260/343/203/254/343/203/220/343/203/274/343/201/256/345/213/225/343/201/215/343/201/214/345/206/205/351/203/250/343/201/247/343/201/257/345/233/233/350/247/222.rb +30 -0
  36. data/examples/00350_joystick_PS3/343/202/242/343/203/212/343/203/255/343/202/260/343/203/254/343/203/220/343/203/274/343/201/256/350/252/277/346/225/264/346/270/210/343/201/277/343/203/231/343/202/257/343/203/210/343/203/253.rb +12 -0
  37. data/examples/00360_lib_mouse.rb +5 -0
  38. data/examples/00370_lib_input.rb +29 -0
  39. data/examples/00380_lib_vputs_align.rb +8 -0
  40. data/examples/00390_/343/203/225/343/202/251/343/203/263/343/203/210/344/270/200/350/246/247.rb +15 -0
  41. data/examples/00400_lib_draw_circle.rb +8 -0
  42. data/examples/00410_SDL/343/201/256draw_rect/343/201/2571/343/203/224/343/202/257/343/202/273/343/203/253/344/275/231/345/210/206/343/201/253/346/217/217/347/224/273/343/201/225/343/202/214/343/202/213/343/201/256/343/201/247/346/263/250/346/204/217.rb +7 -0
  43. data/examples/00420_circle_on_circle.rb +10 -0
  44. data/examples/00430_rotate.rb +16 -0
  45. data/examples/00440_draw_triangle.rb +7 -0
  46. data/examples/00450_parabora_triangle.rb +37 -0
  47. data/examples/00460_ice_hockey.rb +88 -0
  48. data/examples/00470_collision_block_vs_block.rb +120 -0
  49. data/examples/00480_simple_circle_controll.rb +37 -0
  50. data/examples/00490_/347/255/211/351/200/237/347/247/273/345/213/225_uniform_velocity_rain.rb +51 -0
  51. data/examples/00500_/345/212/240/351/200/237/346/224/276/347/211/251/347/267/232_parabora_volcano.rb +94 -0
  52. data/examples/00510_3d.rb +53 -0
  53. data/examples/00520_/343/203/210/343/203/253/343/203/215/343/201/256/343/203/241/343/203/213/343/203/245/343/203/274/351/242/250/343/201/256/345/213/225/343/201/215.rb +77 -0
  54. data/examples/00530_curve_2/346/254/241/343/203/231/343/202/270/343/202/247/346/233/262/347/267/232/343/201/250/347/233/264/347/267/232/343/201/250/343/201/256/344/272/244/347/202/271.rb +43 -0
  55. data/examples/00540_curve_3/346/254/241/343/203/231/343/202/270/343/202/247/346/233/262/347/267/232.rb +40 -0
  56. data/examples/00550_curve_N/346/254/241/343/203/231/343/202/270/343/202/247/346/233/262/347/267/232.rb +92 -0
  57. data/examples/00560_curve_/343/202/271/343/203/227/343/203/251/343/202/244/343/203/263/346/233/262/347/267/232.rb +113 -0
  58. data/examples/00570_/345/206/206/351/201/213/345/213/225_circle_jet_coaster.rb +52 -0
  59. data/examples/00580_/345/206/206/343/202/222/346/212/274/343/201/231/343/201/262/343/201/243/343/201/261/343/202/213_collision_circle_vs_circle_push_or_pull.rb +56 -0
  60. data/examples/00590_/350/212/213/350/231/253/343/202/264/343/203/240/347/264/220/343/203/207/343/203/242_collision_demo_circle_worm.rb +104 -0
  61. data/examples/00600_/346/214/257/343/202/212/345/255/220_swing.rb +145 -0
  62. data/examples/00610_/345/206/205/347/251/215/343/201/250/345/244/226/347/251/215_inner_product.rb +36 -0
  63. data/examples/00620_/346/263/225/347/267/232/343/203/231/343/202/257/343/203/210/343/203/253.rb +23 -0
  64. data/examples/00630_/345/206/206/343/201/250/345/206/206/343/201/256/345/217/215/345/260/204_collision_reflect_circle_vs_circle.rb +222 -0
  65. data/examples/00640_/347/202/271/343/201/250/347/267/232/345/210/206/343/201/256/344/272/244/345/267/256/345/210/244/345/256/232_collision_ray_circle_vs_line.rb +261 -0
  66. data/examples/00650_/345/206/206/343/201/250/347/202/271/343/201/256/345/217/215/345/260/204_collision_circle_vs_dot.rb +36 -0
  67. data/examples/00660_/345/206/206/343/201/250/345/206/206/343/201/250/347/267/232/345/210/206/343/201/256/345/217/215/345/260/204/343/203/207/343/203/242_collision_demo.rb +305 -0
  68. data/examples/00670_/343/203/251/343/202/244/343/203/225/343/202/262/343/203/274/343/203/240.rb +86 -0
  69. data/examples/00680_2/347/202/271/343/202/222/351/200/232/343/202/213/347/233/264/347/267/232/343/201/256/346/226/271/347/250/213/345/274/217.rb +81 -0
  70. data/examples/00690_/343/203/222/343/203/253/343/203/231/343/203/253/343/203/210/346/233/262/347/267/232.rb +77 -0
  71. data/examples/00700_/343/202/263/343/203/203/343/203/233/346/233/262/347/267/232.rb +79 -0
  72. data/examples/00710_/343/202/267/343/202/260/343/203/242/343/202/244/343/203/211/346/233/262/347/267/232.rb +40 -0
  73. data/examples/00720_/343/202/267/343/203/200/346/244/215/347/211/251.rb +44 -0
  74. data/examples/00730_/343/202/257/343/203/252/343/203/225/343/202/251/343/203/274/343/203/211/343/202/242/343/203/210/343/203/251/343/202/257/343/202/277_/345/237/272/346/234/254.rb +29 -0
  75. data/examples/00740_/343/202/257/343/203/252/343/203/225/343/202/251/343/203/274/343/203/211/343/202/242/343/203/210/343/203/251/343/202/257/343/202/277_/346/224/271/350/211/257_/350/211/262/344/273/230/343/201/215.rb +68 -0
  76. data/examples/00750_/343/202/257/343/203/252/343/203/225/343/202/251/343/203/274/343/203/211/343/202/242/343/203/210/343/203/251/343/202/257/343/202/277_/343/203/211/343/203/274/343/203/212/343/203/204/345/236/213.rb +44 -0
  77. data/examples/00760_/347/201/253/350/212/261.rb +42 -0
  78. data/examples/00770_atan/343/201/247atan2/343/202/222/346/233/270/343/201/217.rb +26 -0
  79. data/examples/00780_/346/250/231/346/272/226/343/203/251/343/202/244/343/203/226/343/203/251/343/203/252/343/201/256atan2_sin_cos/343/202/222/344/275/277/343/201/206.rb +15 -0
  80. data/examples/00790_/350/247/222/345/272/246/343/201/250/343/203/251/343/202/270/343/202/242/343/203/263/343/201/256/347/233/270/344/272/222/345/244/211/346/217/233.rb +22 -0
  81. data/examples/00800_/347/220/203/343/201/214/347/233/264/347/267/232/347/232/204/343/201/253/345/213/225/343/201/204/343/201/246/343/201/204/343/202/213/343/201/240/343/201/221/343/201/247/345/233/236/350/273/242/343/201/227/343/201/246/343/201/204/343/202/213/343/202/210/343/201/206/343/201/253/350/246/213/343/201/210/343/202/213.rb +27 -0
  82. data/examples/00810_/343/202/267/343/203/237/343/203/245/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263_/350/273/212.rb +75 -0
  83. data/examples/00820_/343/202/267/343/203/237/343/203/245/343/203/254/343/203/274/343/202/267/343/203/247/343/203/263_/346/210/246/350/273/212.rb +90 -0
  84. data/examples/00830_/350/247/222/345/272/246/345/267/256.rb +36 -0
  85. data/examples/00840_/346/224/276/347/211/251/347/267/232/343/201/247/347/213/231/346/222/203_/346/231/202/351/226/223/345/233/272/345/256/232.rb +61 -0
  86. data/examples/00850_/346/224/276/347/211/251/347/267/232/343/201/247/347/213/231/346/222/203_/350/247/222/345/272/246/345/233/272/345/256/232.rb +84 -0
  87. data/examples/00860_/346/224/276/347/211/251/347/267/232/343/201/247/347/213/231/346/222/203_/351/200/237/345/272/246/345/233/272/345/256/232.rb +66 -0
  88. data/examples/00870_/350/247/222/345/272/246/350/243/234/346/255/243_/345/212/240/351/200/237/343/203/237/343/202/265/343/202/244/343/203/253.rb +60 -0
  89. data/examples/00880_/345/210/235/351/200/237/343/201/214/351/200/237/343/201/204/343/203/237/343/202/265/343/202/244/343/203/253.rb +51 -0
  90. data/examples/00890_/346/255/243/350/246/217/344/271/261/346/225/260/343/201/250/346/250/231/346/272/226/345/201/217/345/267/256/343/201/256/345/217/257/350/246/226/345/214/226.rb +72 -0
  91. data/examples/00900_/345/220/221/345/277/203/345/212/233/343/201/247/345/233/236/350/273/242/343/200/220/350/247/222/345/272/2460/345/272/246/343/201/213/343/202/211/343/200/221.rb +23 -0
  92. data/examples/00910_/345/220/221/345/277/203/345/212/233/343/201/247/345/233/236/350/273/242/343/200/220/344/273/273/346/204/217/343/201/256/350/247/222/345/272/246/343/201/213/343/202/211/343/200/221.rb +33 -0
  93. data/examples/00920_/343/203/236/343/203/252/343/202/252/343/203/226/343/203/251/343/202/266/343/203/274/343/202/272/351/242/250/343/201/253/347/224/273/351/235/242/344/270/241/347/253/257/343/201/214/347/271/213/343/201/243/343/201/246/343/201/204/343/202/213/344/276/213.rb +29 -0
  94. data/examples/00930_/345/212/271/346/236/234/351/237/263.rb +17 -0
  95. data/examples/00940_/343/203/236/343/203/203/343/203/227/343/203/201/343/203/203/343/203/227/343/201/256/343/203/236/343/203/203/343/203/227/351/205/215/347/275/256.rb +71 -0
  96. data/examples/00950_/343/203/236/343/203/203/343/203/227/343/203/201/343/203/203/343/203/227/343/201/256/350/241/250/347/244/272/344/276/213.rb +28 -0
  97. data/examples/00960_/343/203/236/343/203/203/343/203/227/343/203/201/343/203/203/343/203/227/343/201/250/345/215/230/344/270/200/347/224/273/345/203/217/343/201/256/351/201/225/343/201/204/343/202/222/345/220/270/345/217/216/343/201/231/343/202/213/344/276/213.rb +47 -0
  98. data/examples/00970_observer_/343/201/235/343/201/2561_/347/233/264/346/216/245.rb +28 -0
  99. data/examples/00980_observer_/343/201/235/343/201/2562_/346/231/256/351/200/232/343/201/253Singleton/347/211/210.rb +30 -0
  100. data/examples/00990_observer_/343/201/235/343/201/2563_SimpleDelegator/347/211/210.rb +28 -0
  101. data/examples/01000_observer_/343/201/235/343/201/2564_/351/200/206/343/201/253/343/203/253/343/203/274/343/203/227/344/270/273/345/260/216.rb +28 -0
  102. data/examples/01010_observer_/343/201/235/343/201/2565_/343/201/204/343/202/215/343/202/223/343/201/252/346/211/200/343/201/213/343/202/211/345/221/274/343/202/223/343/201/247/343/201/204/343/202/213/343/201/221/343/201/251Singleton/343/201/252/343/201/256/343/201/247/345/256/211/345/205/250.rb +37 -0
  103. data/examples/01020_observer_/343/201/235/343/201/2566_/343/201/204/343/202/215/343/202/223/343/201/252/346/211/200/343/201/213/343/202/211/345/221/274/343/201/266/345/240/264/345/220/210callbacks/343/202/222/344/275/277/343/202/217/343/201/252/343/201/204/343/202/210/343/201/206/343/201/253.rb +30 -0
  104. data/examples/01030_observer_/343/201/235/343/201/2567_/343/202/250/343/203/225/343/202/247/343/202/257/343/203/210/343/202/277/343/202/271/343/202/257/343/202/222/345/233/236/343/201/231/344/276/213.rb +57 -0
  105. data/examples/01040_/343/203/236/343/202/246/343/202/271/343/201/256/344/275/215/347/275/256/343/201/253/343/203/224/343/202/257/343/202/273/343/203/253/343/202/222/346/211/223/343/201/244.rb +18 -0
  106. data/examples/01050_/343/203/224/343/202/257/343/202/273/343/203/253/345/205/250/344/275/223/343/202/222/346/233/270/343/201/215/350/276/274/343/202/200.rb +27 -0
  107. data/examples/01060_effect_/347/224/273/345/203/217/343/201/256/343/202/263/343/203/263/343/203/234/343/203/252/343/203/245/343/203/274/343/203/210/346/263/225/343/201/253/343/202/210/343/202/213/343/202/250/343/203/225/343/202/247/343/202/257/343/203/210/345/207/246/347/220/206.rb +116 -0
  108. data/examples/01070_effect_FF7/343/201/256/346/210/246/351/227/230/343/201/253/345/205/245/343/202/213/343/201/250/343/201/215/343/201/256/343/202/250/343/203/225/343/202/247/343/202/257/343/203/210.rb +33 -0
  109. data/examples/01080_effect_/350/203/214/346/231/257/343/202/222/347/267/251/343/201/217/346/266/210/343/201/227/343/201/246/343/201/204/343/201/217/343/201/250/343/202/271/343/203/240/343/203/274/343/202/272/343/201/253/343/201/252/343/202/213.rb +16 -0
  110. data/examples/01090_/347/224/273/345/203/217/343/201/256/343/202/257/343/203/255/343/202/271/343/203/225/343/202/247/343/203/274/343/203/211.rb +37 -0
  111. data/examples/01100_/343/202/271/343/202/257/343/203/252/343/203/274/343/203/263/346/203/205/345/240/261.rb +8 -0
  112. data/examples/01110_lib_contrib_menu.rb +19 -0
  113. data/examples/01120_/351/233/233/345/236/213_2P/345/257/276/346/210/246/351/242/250STG.rb +109 -0
  114. data/examples/01130_/351/233/233/345/236/213_/346/210/246/350/273/212/345/257/276/346/210/246.rb +396 -0
  115. data/examples/01140_/351/233/233/345/236/213_2P/345/257/276/346/210/246.rb +60 -0
  116. data/examples/01150_/351/233/233/345/236/213_/343/202/271/343/203/274/343/203/221/343/203/274/343/203/236/343/203/252/343/202/252/351/242/250/343/202/242/343/202/257/343/202/267/343/203/247/343/203/263.rb +1251 -0
  117. data/examples/01160_2D/343/202/242/343/203/225/343/202/243/343/203/263/345/244/211/346/217/233.rb +40 -0
  118. data/examples/01170_stackprof.rb +10 -0
  119. data/examples/01180_sdl_/343/202/242/343/203/253/343/203/225/343/202/241/343/203/226/343/203/254/343/203/263/343/203/207/343/202/243/343/203/263/343/202/260/343/201/247/351/207/215/343/201/255/345/220/210/343/201/233/345/241/227/343/202/212/346/275/260/343/201/227.rb +11 -0
  120. data/examples/01190_/343/203/221/343/203/274/343/203/206/343/202/243/343/202/257/343/203/253/345/220/214/345/243/253/343/201/247/344/270/255/345/244/256/343/201/253/345/220/221/343/201/213/343/201/206.rb +79 -0
  121. data/examples/01200_lib_OpenGL.rb +55 -0
  122. data/examples/bezier.rb +202 -0
  123. data/examples/cursor.rb +50 -0
  124. data/examples/helper.rb +38 -0
  125. data/examples/lifegame_patterns.rb +102 -0
  126. data/examples/movable_point.rb +64 -0
  127. data/examples/mtx33.rb +294 -0
  128. data/examples/setup.rb +5 -0
  129. data/examples/stage_infos.rb +1 -0
  130. data/examples/start.sh +2 -0
  131. data/examples/test_all.rb +5 -0
  132. data/examples/testgl.rb +228 -0
  133. data/examples/trash/__0060_shooting2.rb +37 -0
  134. data/examples/trash/__0090_collision_circle1.rb +50 -0
  135. data/examples/trash/__0125_circle_collision.rb +103 -0
  136. data/examples/trash/__0130_circle_collision2.rb +60 -0
  137. data/examples/trash/__0270_circle_cycle_shift.rb +29 -0
  138. data/examples/trash/__bullet_algos.rb +224 -0
  139. data/examples/trash/gunship.rb +39 -0
  140. data/examples//343/203/227/343/203/255/343/202/270/343/202/247/343/202/257/343/202/277/343/203/274/343/201/253/350/241/250/347/244/272/343/201/231/343/202/213/343/201/250/343/201/215.sh +2 -0
  141. data/lib/stylet.rb +1 -0
  142. data/lib/stylet/application_memory_record.rb +33 -0
  143. data/lib/stylet/audio.rb +455 -0
  144. data/lib/stylet/axis_support.rb +62 -0
  145. data/lib/stylet/base.rb +76 -0
  146. data/lib/stylet/callbacks.rb +62 -0
  147. data/lib/stylet/cli.rb +54 -0
  148. data/lib/stylet/collision_support.rb +56 -0
  149. data/lib/stylet/config.rb +39 -0
  150. data/lib/stylet/contrib/menu.rb +508 -0
  151. data/lib/stylet/contrib/shared_pad.rb +32 -0
  152. data/lib/stylet/contrib/sprity.rb +149 -0
  153. data/lib/stylet/core.rb +118 -0
  154. data/lib/stylet/cpu_stat.rb +58 -0
  155. data/lib/stylet/delegators.rb +54 -0
  156. data/lib/stylet/draw.rb +256 -0
  157. data/lib/stylet/draw_support/arrow.rb +56 -0
  158. data/lib/stylet/draw_support/circle.rb +63 -0
  159. data/lib/stylet/draw_support/polygon.rb +22 -0
  160. data/lib/stylet/font.rb +172 -0
  161. data/lib/stylet/fps_adjust.rb +23 -0
  162. data/lib/stylet/fps_stat.rb +41 -0
  163. data/lib/stylet/input.rb +8 -0
  164. data/lib/stylet/input/base.rb +105 -0
  165. data/lib/stylet/input/hardware_bindings.rb +65 -0
  166. data/lib/stylet/input/key_one.rb +162 -0
  167. data/lib/stylet/input/support.rb +72 -0
  168. data/lib/stylet/joystick.rb +31 -0
  169. data/lib/stylet/joystick_adapter.rb +130 -0
  170. data/lib/stylet/joystick_adapters/buffalo_snes_adapter.rb +47 -0
  171. data/lib/stylet/joystick_adapters/elecom_usb_pad_adapter.rb +30 -0
  172. data/lib/stylet/joystick_adapters/hori_rap_v3_sa_adapter.rb +46 -0
  173. data/lib/stylet/joystick_adapters/ps3_standard_adapter.rb +40 -0
  174. data/lib/stylet/joystick_adapters/unknown_adapter.rb +13 -0
  175. data/lib/stylet/keyboard.rb +15 -0
  176. data/lib/stylet/logger.rb +12 -0
  177. data/lib/stylet/mouse.rb +58 -0
  178. data/lib/stylet/palette.rb +17 -0
  179. data/lib/stylet/rect.rb +113 -0
  180. data/lib/stylet/shortcut.rb +8 -0
  181. data/lib/stylet/state.rb +87 -0
  182. data/lib/stylet/stylet.rb +44 -0
  183. data/lib/stylet/system_pause.rb +24 -0
  184. data/lib/stylet/version.rb +3 -0
  185. data/log/.gitkeep +0 -0
  186. data/stylet.gemspec +31 -0
  187. data/test/test_helper.rb +6 -0
  188. data/test/test_input_base.rb +12 -0
  189. data/test/test_input_key_one.rb +43 -0
  190. data/test/test_input_support.rb +47 -0
  191. data/test/test_sample.rb +13 -0
  192. data/test/test_state.rb +26 -0
  193. data/tips.org +16 -0
  194. metadata +391 -0
@@ -0,0 +1,40 @@
1
+ # アフィン変換
2
+
3
+ require_relative "helper"
4
+ require_relative "mtx33"
5
+
6
+ class App < Stylet::Base
7
+ include Helper::CursorWithObjectCollection
8
+ include Helper::MovablePoint
9
+
10
+ setup do
11
+ end
12
+
13
+ update do
14
+ if true
15
+ # 絶対座標の場合
16
+ p0 = srect.center # オブジェクトの原点
17
+ p1 = p0 + vec2[64, 64] # 絶対座標になっている場合は、
18
+ m1 = Stylet::Mtx33.translate(*(-p0)) # まず原点を引いて
19
+ m2 = Stylet::Mtx33.rotate(frame_counter) # モデル座標の状態にして回転し
20
+ m3 = Stylet::Mtx33.translate(*p0) # 元に戻す
21
+ m = Stylet::Mtx33.transform(m1, m2, m3) # 上の3つの行列を加算
22
+ # m = Stylet::Mtx33.invert(m)
23
+ v = Stylet::Mtx33.vec2_transform_point(*p1, m) # 絶対座標を反映
24
+ draw_triangle(v, :radius => 16)
25
+ draw_dot(p0)
26
+ end
27
+
28
+ if true
29
+ # モデル座標の場合
30
+ p0 = srect.center # オブジェクトの原点
31
+ p1 = vec2[128, 128] # モデル座標
32
+ m = Stylet::Mtx33.rotate(frame_counter) # モデル座標の場合はいきなり回転してよい
33
+ v = Stylet::Mtx33.vec2_transform_point(*p1, m) # モデル座標を反映
34
+ draw_triangle(p0 + v, :radius => 16) # 最後に原点を普通に足す
35
+ draw_dot(p0)
36
+ end
37
+ end
38
+
39
+ run
40
+ end
@@ -0,0 +1,10 @@
1
+ require "./setup"
2
+ require "stackprof"
3
+
4
+ StackProf.run(mode: :cpu, out: "/tmp/stackprof-cpu-myapp.dump") do
5
+ Stylet.run do
6
+ vputs frame_counter
7
+ end
8
+ end
9
+
10
+ # stackprof /tmp/stackprof-cpu-myapp.dump
@@ -0,0 +1,11 @@
1
+ # 重ね合せ塗り潰し アルファブレンディング
2
+ require "./setup"
3
+
4
+ class App < Stylet::Base
5
+ update do
6
+ screen.draw_filled_rect_alpha( 0, 0, 100, 100, [255, 255, 255], 128)
7
+ screen.draw_filled_rect_alpha(50, 50, 100, 100, [255, 255, 255], 128)
8
+ end
9
+
10
+ run
11
+ end
@@ -0,0 +1,79 @@
1
+ require_relative "helper"
2
+
3
+ class Particle
4
+ include Stylet::Delegators
5
+ delegate :objects, :button, :cursor, :to => "Stylet.context"
6
+
7
+ GRAVITY = 2.0
8
+
9
+ attr_reader :p0, :p1, :diameter, :mass
10
+
11
+ def initialize(point, mass)
12
+ @p0 = point.clone
13
+ @p1 = point.clone
14
+
15
+ @speed = vec2[0, 0]
16
+ @accel = vec2[0, 0]
17
+
18
+ @mass = mass # 質量
19
+ @diameter = Math.sqrt(mass) * 20 # 直径
20
+ end
21
+
22
+ def update
23
+ @accel = vec2[0, 0]
24
+ @min_dist = 1000
25
+
26
+ objects.each do |e|
27
+ if e == self
28
+ next
29
+ end
30
+ dist = Math.hypot(*(@p0 - e.p0))
31
+ dir = -angle_of(@p0, e.p0)
32
+ if dist < @min_dist
33
+ @min_dist = dist
34
+ end
35
+ force = (GRAVITY * mass * e.mass) / dist
36
+ if dist > diameter
37
+ @accel.x += force / mass * Math.cos(dir)
38
+ @accel.y += force / mass * Math.sin(dir)
39
+ end
40
+ end
41
+
42
+ # 計算
43
+ @speed += @accel
44
+ @p1 = @p0 + @speed
45
+
46
+ # 描画
47
+ charge_col = 1000.0 / @min_dist / 50.0
48
+ tot_col_1 = 100 + charge_col * 6
49
+ tot_col_2 = 150 + charge_col * charge_col
50
+ tot_col_3 = diameter + 8 + charge_col
51
+
52
+ draw_circle(p1, :radius => diameter / 2)
53
+
54
+ @p0 = p1.clone
55
+ end
56
+
57
+ def angle_of(p1, p2)
58
+ v = p1 - p2
59
+ Math::PI - Math.atan2(v.y, v.x)
60
+ end
61
+ end
62
+
63
+ class App < Stylet::Base
64
+ include Helper::CursorWithObjectCollection
65
+
66
+ setup do
67
+ 3.times do
68
+ objects << Particle.new(srect.center + vec2.rand(-100..+100), rand(0.1..8))
69
+ end
70
+ end
71
+
72
+ update do
73
+ if button.btA.trigger?
74
+ objects << Particle.new(mouse.point, rand(0.1..8))
75
+ end
76
+ end
77
+
78
+ run
79
+ end
@@ -0,0 +1,55 @@
1
+ require_relative "helper"
2
+ require "opengl"
3
+
4
+ Stylet.config.screen_flags |= SDL::OPENGL
5
+
6
+ class App < Stylet::Base
7
+ include Helper::CursorWithObjectCollection
8
+
9
+ setup do
10
+ SDL::GL.set_attr(SDL::GL_RED_SIZE, 5)
11
+ SDL::GL.set_attr(SDL::GL_GREEN_SIZE, 5)
12
+ SDL::GL.set_attr(SDL::GL_BLUE_SIZE, 5)
13
+ SDL::GL.set_attr(SDL::GL_DEPTH_SIZE, 16)
14
+ SDL::GL.set_attr(SDL::GL_DOUBLEBUFFER, 1)
15
+
16
+ GL::Viewport(0, 0, 640, 480)
17
+ GL::MatrixMode(GL::PROJECTION)
18
+ GL::LoadIdentity()
19
+
20
+ GL::MatrixMode(GL::MODELVIEW)
21
+ GL::LoadIdentity()
22
+
23
+ GL::Enable(GL::DEPTH_TEST)
24
+ GL::DepthFunc(GL::LESS)
25
+ GL::ShadeModel(GL::SMOOTH)
26
+ end
27
+
28
+ update do
29
+ GL.ClearColor(0.0, 0.0, 0.2, 0.0) # 背景色の設定(最後の1.0はなんだろう?)
30
+ GL.Clear(GL::COLOR_BUFFER_BIT | GL::DEPTH_BUFFER_BIT)
31
+
32
+ GL::Begin(GL::QUADS) # 4つの点があることを宣言
33
+
34
+ GL::Color([1.0, 0.0, 0.0]) # 右上
35
+ GL::Vertex([0.75, 0.75, -0.75]) # 右上の点の位置(1.0にすると画面最大になる)
36
+ GL::Color([0.0, 1.0, 0.0]) # 右下
37
+ GL::Vertex([0.75, -0.75, -0.75])
38
+ GL::Color([0.0, 0.0, 1.0]) # 左下
39
+ GL::Vertex([-0.75, -0.75, -0.75])
40
+ GL::Color([0.0, 1.0, 1.0]) # 左上
41
+ GL::Vertex([-0.75, 0.75, -0.75])
42
+
43
+ GL::End() # 点の設定を終了
44
+
45
+ GL::MatrixMode(GL::MODELVIEW)
46
+ GL::Rotate(0.5, 0.5, 0.5, 0.5) # ここを有効にするとなんか知らんが回転する
47
+
48
+ SDL::GL.swap_buffers
49
+ end
50
+
51
+ def background_clear
52
+ end
53
+
54
+ run
55
+ end
@@ -0,0 +1,202 @@
1
+
2
+ require_relative "helper"
3
+
4
+ class App < Stylet::Base
5
+ include Helper::CursorWithObjectCollection
6
+ include Helper::MovablePoint
7
+
8
+ setup do
9
+ @line_count = 50 # 軌跡確認用弧線の構成ライン数初期値(確認用)
10
+ @points_count = 0
11
+
12
+ points_switch
13
+ end
14
+
15
+ update do
16
+ if key_down?(SDL::Key::A)
17
+ points_switch
18
+ end
19
+
20
+ if false
21
+ # 構成ライン数の減算
22
+ @line_count += button.btC.repeat
23
+ @line_count -= button.btD.repeat
24
+ @line_count = [2, @line_count].max
25
+ vputs "@line_count = #{@line_count}"
26
+ end
27
+
28
+ # 曲線表示
29
+ if @dragging_current || button.btA.press? || true
30
+ curve_points.each_cons(2) {|points| draw_line(*points) }
31
+ end
32
+
33
+ # ベジェのポイントを動かして表示
34
+ update_movable_points(@points)
35
+ @points.each_with_index {|e, i|vputs("b#{i} #{e}", :vector => e)}
36
+
37
+ unless @points.empty?
38
+ # 物体をいったりきたりさせる
39
+ if false
40
+ # ○の表示
41
+ pos = 0.5 + (Stylet::Magic.rsin(frame_counter / 256.0) * 0.5)
42
+ pt = point_of_t(pos)
43
+ draw_circle(pt, :radius => 64, :vertex => 32)
44
+ vputs(pos)
45
+ else
46
+ # △の表示で進んでいる方向を頂点にする
47
+ t0 = 0.5 + (Stylet::Magic.rsin(1.0 / 256 * frame_counter) * 0.5) # 現在の位置(0.0〜1.0)
48
+ t1 = 0.5 + (Stylet::Magic.rsin(1.0 / 256 * frame_counter.next) * 0.5) # 未来の位置(0.0〜1.0)
49
+ p0 = point_of_t(t0) # 現在の座標
50
+ p1 = point_of_t(t1) # 未来の座標
51
+ draw_triangle(p0, :angle => p0.angle_to(p1), :radius => 64) # 三角の頂点を未来への向きに設定して三角描画
52
+ end
53
+ end
54
+ end
55
+
56
+ def points_switch
57
+ @dragging_current = nil
58
+ @points = collection[@points_count.modulo(collection.size)].tap { @points_count += 1}
59
+ end
60
+
61
+ private
62
+
63
+ def curve_points
64
+ @line_count.next.times.collect {|i| point_of_t(1.0 * i / @line_count) }
65
+ end
66
+
67
+ def point_of_t(t)
68
+ bezier_curve(*@points, t)
69
+ end
70
+
71
+ def bezier_curve(*args)
72
+ raise NotImplementedError, "#{__method__} is not implemented"
73
+ end
74
+ end
75
+
76
+ # 直線との交点
77
+ class App
78
+ module LineCollision
79
+ extend ActiveSupport::Concern
80
+
81
+ included do
82
+ setup do
83
+ @lpoints_count = 0
84
+ lpoints_switch
85
+ end
86
+
87
+ update do
88
+ if key_down?(SDL::Key::S)
89
+ lpoints_switch
90
+ end
91
+
92
+ # 直線のポイント位置のドラッグ
93
+ update_movable_points(@line_ab)
94
+
95
+ # ライン両端の番号とライン表示
96
+ @line_ab.each_with_index {|e, i|vputs("p#{i} #{e}", :vector => e)}
97
+ draw_line(*@line_ab)
98
+
99
+ # 2点から直線 ax+bx+c=0 の a b c を求める
100
+ p0 = @line_ab[0]
101
+ p1 = @line_ab[1]
102
+ a = p0.y - p1.y
103
+ b = -(p0.x - p1.x)
104
+ c = p0.x * p1.y - p1.x * p0.y
105
+
106
+ t = intersection2(*@points, a, b, c)
107
+ t.each do |t|
108
+ xy = point_of_t(t)
109
+ draw_circle(xy, :radius => 3)
110
+ vputs(t, :vector => xy)
111
+ end
112
+ end
113
+ end
114
+
115
+ def lpoints_switch
116
+ @line_ab = []
117
+ if @lpoints_count.modulo(2).zero?
118
+ @line_ab << srect.center + vec2[-srect.w / 8, +srect.h / 3]
119
+ @line_ab << srect.center + vec2[-srect.w / 8, -srect.h / 3]
120
+ else
121
+ @line_ab << srect.center + vec2[-srect.w / 8, 0]
122
+ @line_ab << srect.center + vec2[+srect.w / 8, 0]
123
+ end
124
+ @dragging_current = nil
125
+ @lpoints_count += 1
126
+ end
127
+
128
+ # NUTSU » [as]ベジェ曲線と直線の交点
129
+ # http://nutsu.com/blog/2007/101701_as_bezjesegment3.html
130
+ def intersection1(p0, p1, p2, a, b, c)
131
+ t = []
132
+
133
+ m = b * p2.y + b * p0.y + a * p2.x + a * p0.x - 2 * b * p1.y - 2 * a * p1.x
134
+ n = -2 * b * p0.y - 2 * a * p0.x + 2 * b * p1.y + 2 * a * p1.x
135
+ l = b * p0.y + a * p0.x + c
136
+
137
+ d = (n**2) - 4 * m * l
138
+
139
+ vputs "a: #{a}"
140
+ vputs "b: #{b}"
141
+ vputs "c: #{c}"
142
+
143
+ vputs "l: #{l}"
144
+ vputs "m: #{m}"
145
+ vputs "n: #{n}"
146
+ vputs "d: #{d}"
147
+
148
+ if d > 0
149
+ d = Math.sqrt(d)
150
+ t << 0.5 * (-n + d) / m
151
+ t << 0.5 * (-n - d) / m
152
+ elsif d.zero?
153
+ t << 0.5 * -n / m
154
+ end
155
+
156
+ vputs "t: #{t}"
157
+
158
+ t = t.find_all {|d|(0..1).include?(d)} # (0..1の範囲外は曲線の延長線上の交点になる)
159
+ t
160
+ end
161
+
162
+ # 二次ベジェ曲線と直線の交点
163
+ # http://geom.web.fc2.com/geometry/bezier/qb-line-intersection.html
164
+ def intersection2(p0, p1, p2, a, b, c)
165
+ t = []
166
+
167
+ l = a * (p2.x - 2 * p1.x + p0.x) + b * (p2.y - 2 * p1.y + p0.y)
168
+ m = 2 * (a * (p1.x - p0.x) + b * (p1.y - p0.y))
169
+ n = a * p0.x + b * p0.y + c
170
+
171
+ # 交点があるにもかかわらず t = [Nan, -Infinity] になってしまう場合がある
172
+ # このとき l が 0 になっているので、次のようにごまかせば交点が生まれたけど、計算が間違っている気がする
173
+ # if l.zero?
174
+ # l = 0.000000001
175
+ # end
176
+
177
+ d = (m**2) - 4 * l * n
178
+
179
+ vputs "a: #{a}"
180
+ vputs "b: #{b}"
181
+ vputs "c: #{c}"
182
+
183
+ vputs "l: #{l}"
184
+ vputs "m: #{m}"
185
+ vputs "n: #{n}"
186
+ vputs "d: #{d}"
187
+
188
+ if d > 0
189
+ s = Math.sqrt(d)
190
+ t << (-m + s) / (2 * l)
191
+ t << (-m - s) / (2 * l)
192
+ elsif d.zero?
193
+ t << -m / (2 * l)
194
+ end
195
+
196
+ vputs "t: #{t}"
197
+
198
+ t = t.find_all {|d|(0..1).include?(d)} # (0..1の範囲外は曲線の延長線上の交点になる)
199
+ t
200
+ end
201
+ end
202
+ end
@@ -0,0 +1,50 @@
1
+ module Helper
2
+ module Cursor
3
+ extend ActiveSupport::Concern
4
+
5
+ include Stylet::Input::Base
6
+ include Stylet::Input::ExtensionButton
7
+ include Stylet::Input::StandardKeybordBind
8
+ include Stylet::Input::JoystickBindMethod
9
+ include Stylet::Input::MouseButtonBind
10
+
11
+ included do
12
+ attr_reader :cursor
13
+
14
+ setup do
15
+ @cursor = CursorSet.new
16
+ @cursor.point = @mouse.point.clone
17
+ end
18
+
19
+ update do
20
+ joys.each {|joy| bit_update_by_joy(joy) }
21
+ key_bit_update_all
22
+ key_counter_update_all
23
+
24
+ if mouse.moved?
25
+ @cursor.point.replace(@mouse.point.clone)
26
+ end
27
+
28
+ if angle = axis_angle
29
+ @cursor.point.replace(@cursor.point + vec2.angle_at(angle) * @cursor.speed)
30
+ end
31
+
32
+ if @cursor.display
33
+ draw_circle(@cursor.point, :radius => @cursor.radius, :vertex => @cursor.vertex, :angle => 1.0 / 64 * frame_counter)
34
+ end
35
+ end
36
+ end
37
+
38
+ class CursorSet
39
+ attr_accessor :point, :speed, :vertex, :radius, :display
40
+
41
+ def initialize
42
+ @point = Stylet::Vector.zero
43
+ @speed = 5
44
+ @vertex = 3
45
+ @radius = 8
46
+ @display = true
47
+ end
48
+ end
49
+ end
50
+ end