picrate 1.2.3-java → 2.1.0-java

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 (101) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/Gemfile +3 -1
  4. data/README.md +8 -9
  5. data/Rakefile +10 -9
  6. data/bin/picrate +3 -1
  7. data/docs/_config.yml +1 -1
  8. data/docs/_editors/geany.md +1 -0
  9. data/docs/_gems/gems/gems.md +1 -1
  10. data/docs/_posts/2018-05-06-getting_started.md +4 -4
  11. data/docs/_posts/2018-05-06-install_jruby.md +5 -11
  12. data/docs/_posts/2018-05-11-arch-linux-arm.md +1 -11
  13. data/docs/_posts/2018-11-18-building-gem.md +2 -2
  14. data/docs/_posts/2018-11-27-getting_started_geany.md +4 -4
  15. data/docs/_posts/2019-11-11-getting_started_buster.md +4 -7
  16. data/docs/_posts/2020-03-09-auto_install_picrate.md +34 -0
  17. data/docs/_posts/2020-05-11-getting_started_manjaro.md +94 -0
  18. data/docs/about.md +1 -1
  19. data/lib/picrate.rb +1 -1
  20. data/lib/picrate/app.rb +11 -3
  21. data/lib/picrate/creators/parameters.rb +8 -8
  22. data/lib/picrate/creators/sketch_factory.rb +5 -3
  23. data/lib/picrate/helper_methods.rb +21 -21
  24. data/lib/picrate/helpers/numeric.rb +2 -0
  25. data/lib/picrate/library.rb +5 -1
  26. data/lib/picrate/library_loader.rb +2 -0
  27. data/lib/picrate/native_folder.rb +2 -1
  28. data/lib/picrate/native_loader.rb +3 -0
  29. data/lib/picrate/runner.rb +5 -2
  30. data/lib/picrate/version.rb +1 -1
  31. data/library/boids/boids.rb +17 -8
  32. data/library/chooser/chooser.rb +10 -9
  33. data/library/color_group/color_group.rb +2 -0
  34. data/library/control_panel/control_panel.rb +7 -4
  35. data/library/dxf/dxf.rb +2 -0
  36. data/library/library_proxy/library_proxy.rb +2 -0
  37. data/library/net/net.rb +2 -0
  38. data/library/slider/slider.rb +24 -23
  39. data/library/vector_utils/vector_utils.rb +4 -0
  40. data/library/video_event/video_event.rb +2 -0
  41. data/picrate.gemspec +13 -14
  42. data/pom.rb +28 -26
  43. data/pom.xml +18 -6
  44. data/src/main/java/monkstone/ColorUtil.java +1 -1
  45. data/src/main/java/monkstone/MathToolModule.java +1 -1
  46. data/src/main/java/monkstone/PicrateLibrary.java +8 -8
  47. data/src/main/java/monkstone/fastmath/Deglut.java +16 -16
  48. data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
  49. data/src/main/java/monkstone/noise/SimplexNoise.java +3 -3
  50. data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
  51. data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
  52. data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +12 -12
  53. data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
  54. data/src/main/java/monkstone/slider/SliderBar.java +1 -1
  55. data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
  56. data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
  57. data/src/main/java/monkstone/vecmath/package-info.java +1 -1
  58. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
  59. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
  60. data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
  61. data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
  62. data/src/main/java/monkstone/videoevent/package-info.java +1 -1
  63. data/src/main/java/processing/awt/PGraphicsJava2D.java +33 -36
  64. data/src/main/java/processing/awt/PImageAWT.java +377 -0
  65. data/src/main/java/processing/awt/PSurfaceAWT.java +0 -20
  66. data/src/main/java/processing/awt/ShimAWT.java +545 -0
  67. data/src/main/java/processing/core/PApplet.java +699 -1523
  68. data/src/main/java/processing/core/PConstants.java +180 -180
  69. data/src/main/java/processing/core/PFont.java +2 -2
  70. data/src/main/java/processing/core/PGraphics.java +190 -176
  71. data/src/main/java/processing/core/PImage.java +1536 -1721
  72. data/src/main/java/processing/core/PMatrix.java +39 -39
  73. data/src/main/java/processing/core/PSurface.java +69 -103
  74. data/src/main/java/processing/core/PSurfaceNone.java +29 -0
  75. data/src/main/java/processing/core/PVector.java +2 -2
  76. data/src/main/java/processing/data/FloatDict.java +251 -284
  77. data/src/main/java/processing/data/TableRow.java +32 -32
  78. data/src/main/java/processing/dxf/RawDXF.java +3 -3
  79. data/src/main/java/processing/net/Client.java +1 -1
  80. data/src/main/java/processing/opengl/PGL.java +1016 -4132
  81. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +223 -184
  82. data/src/main/java/processing/opengl/PJOGL.java +374 -1526
  83. data/src/main/java/processing/opengl/PShapeOpenGL.java +5 -6
  84. data/src/main/java/processing/opengl/PSurfaceJOGL.java +262 -147
  85. data/test/color_group_test.rb +4 -4
  86. data/test/deglut_spec_test.rb +2 -0
  87. data/test/helper_methods_test.rb +41 -13
  88. data/test/math_tool_test.rb +46 -37
  89. data/test/respond_to_test.rb +5 -3
  90. data/test/sketches/key_event.rb +2 -2
  91. data/test/sketches/library/my_library/my_library.rb +3 -0
  92. data/test/test_helper.rb +2 -0
  93. data/test/vecmath_spec_test.rb +30 -19
  94. data/vendors/Rakefile +13 -7
  95. data/vendors/{picrate_sketches.geany → geany.rb} +32 -7
  96. metadata +26 -47
  97. data/docs/_posts/2018-06-26-auto_install_picrate.md +0 -30
  98. data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
  99. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
  100. data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
  101. data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
@@ -9,21 +9,21 @@ java_import Java::Monkstone::ColorUtil
9
9
  Dir.chdir(File.dirname(__FILE__))
10
10
 
11
11
  PALETTE = %w[#FFFFFF #FF0000 #0000FF].freeze
12
- COLORS = [16777215, 16711680, 255].to_java(:int)
12
+ COLORS = [16_777_215, 16_711_680, 255].to_java(:int)
13
13
 
14
14
  class ColorGroupTest < Minitest::Test
15
15
  def test_new
16
16
  group = ColorGroup.new(COLORS)
17
- assert group.kind_of? ColorGroup
17
+ assert group.is_a? ColorGroup
18
18
  end
19
19
 
20
20
  def test_web_array
21
21
  group = ColorGroup.from_web_array(PALETTE)
22
- assert group.kind_of? ColorGroup
22
+ assert group.is_a? ColorGroup
23
23
  end
24
24
 
25
25
  def test_ruby_string
26
- p5array = [16777215, 16711680, 255]
26
+ p5array = [16_777_215, 16_711_680, 255]
27
27
  group = ColorGroup.new(COLORS)
28
28
  code_string = "%w[#FFFFFF #FF0000 #0000FF]\n"
29
29
  result = group.ruby_code
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  Dir.chdir(File.dirname(__FILE__))
@@ -10,40 +10,68 @@ include MathTool
10
10
  Dir.chdir(File.dirname(__FILE__))
11
11
 
12
12
  class HelperMethodsTest < Minitest::Test
13
-
14
- ARRAY = %w(albatross dog horse)
15
- def test_hex_color
13
+ ARRAY = %w[albatross dog horse].freeze
14
+ def test_hex_color
16
15
  col_double = 0.5
17
16
  hexcolor = 0xFFCC6600
18
17
  dodgy_hexstring = '*56666'
19
18
  hexstring = '#CC6600'
20
19
  assert hex_color(col_double) == 0.5, 'double as a color'
21
- assert hex_color(hexcolor) == -3381760, 'hexadecimal fixnum color'
22
- assert hex_color(hexstring) == -3381760, 'hexadecimal string color'
20
+ assert hex_color(hexcolor) == -3_381_760, 'hexadecimal fixnum color'
21
+ assert hex_color(hexstring) == -3_381_760, 'hexadecimal string color'
23
22
  assert_raises(StandardError, 'Dodgy Hexstring') do
24
23
  hex_color(dodgy_hexstring)
25
24
  end
26
25
  assert_raises(StandardError, 'Dodgy Color Conversion') do
27
26
  hex_color([])
28
27
  end
29
- end
28
+ end
30
29
 
31
30
  def test_dist
32
- ax, ay, bx, by = 0, 0, 1.0, 1.0
31
+ ax = 0
32
+ ay = 0
33
+ bx = 1.0
34
+ by = 1.0
33
35
  assert_in_epsilon(dist(ax, ay, bx, by), Math.sqrt(2), epsilon = 0.0001, msg = '2D distance')
34
36
  by = 0.0
35
37
  assert_in_epsilon(dist(ax, ay, bx, by), 1.0, epsilon = 0.0001, msg = 'when y dimension is zero')
36
- ax, ay, bx, by = 0, 0, 0.0, 0.0
38
+ ax = 0
39
+ ay = 0
40
+ bx = 0.0
41
+ by = 0.0
37
42
  assert_in_epsilon(dist(ax, ay, bx, by), 0.0, epsilon = 0.0001, msg = 'when x and y dimension are zero')
38
- ax, ay, bx, by = 1, 1, -2.0, -3.0
43
+ ax = 1
44
+ ay = 1
45
+ bx = -2.0
46
+ by = -3.0
39
47
  assert_in_epsilon(dist(ax, ay, bx, by), 5.0, epsilon = 0.0001, msg = 'classic triangle dimensions')
40
- ax, ay, bx, by, cx, cy = -1, -1, 100, 2.0, 3.0, 100
48
+ ax = -1
49
+ ay = -1
50
+ bx = 100
51
+ by = 2.0
52
+ cx = 3.0
53
+ cy = 100
41
54
  assert_in_epsilon(dist(ax, ay, bx, by, cx, cy), 5.0, epsilon = 0.0001, msg = 'classic triangle dimensions')
42
- ax, ay, bx, by, cx, cy = 0, 0, -1.0, -1.0, 0, 0
55
+ ax = 0
56
+ ay = 0
57
+ bx = -1.0
58
+ by = -1.0
59
+ cx = 0
60
+ cy = 0
43
61
  assert_in_epsilon(dist(ax, ay, bx, by, cx, cy), Math.sqrt(2), epsilon = 0.0001, msg = '2D distance')
44
- ax, ay, bx, by, cx, cy = 0, 0, 0.0, 0.0, 0, 0
62
+ ax = 0
63
+ ay = 0
64
+ bx = 0.0
65
+ by = 0.0
66
+ cx = 0
67
+ cy = 0
45
68
  assert_in_epsilon(dist(ax, ay, bx, by, cx, cy), 0.0)
46
- ax, ay, bx, by, cx, cy = 0, 0, 1.0, 0.0, 0, 0
69
+ ax = 0
70
+ ay = 0
71
+ bx = 1.0
72
+ by = 0.0
73
+ cx = 0
74
+ cy = 0
47
75
  assert_in_epsilon(dist(ax, ay, bx, by, cx, cy), 1.0, epsilon = 0.0001, msg = 'when x and z dimension are zero')
48
76
  end
49
77
 
@@ -1,73 +1,82 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  Java::Monkstone::PicrateLibrary.new.load(JRuby.runtime, false)
4
6
 
5
7
  # include Processing::HelperMethods
6
8
 
7
-
8
9
  Dir.chdir(File.dirname(__FILE__))
9
-
10
- class MathToolTest < Minitest::Test
11
- include MathTool
12
- def test_map1d
10
+ # Test processing map functions
11
+ class ProcessingMapTest < Minitest::Test
12
+ include MathTool
13
+ def test_map1d
13
14
  x = [0, 5, 7.5, 10]
14
15
  range1 = (0..10)
15
16
  range2 = (100..1)
16
17
  range3 = (0..10)
17
18
  range4 = (5..105)
18
- assert_in_delta(map1d(x[0], range1, range2), 100, delta = 0.00001, msg = 'map to first')
19
- assert_in_delta(map1d(x[1], range1, range2), 50.5, delta = 0.00001, msg = 'map to reversed intermediate')
20
- assert_in_delta(map1d(x[2], range3, range4), 80.0, delta = 0.00001, msg = 'map to intermediate')
21
- assert_in_delta(map1d(x[3], range1, range2), 1, delta = 0.00001, msg = 'map to last')
22
- end
19
+ assert_in_delta(map1d(x[0], range1, range2), 100, 0.00001, 'map to first')
20
+ assert_in_delta(map1d(x[1], range1, range2), 50.5, 0.00001, 'map to reversed intermediate')
21
+ assert_in_delta(map1d(x[2], range3, range4), 80.0, 0.00001, 'map to intermediate')
22
+ assert_in_delta(map1d(x[3], range1, range2), 1, 0.00001, 'map to last')
23
+ end
23
24
 
24
- def test_p5map # as map1d except not using range input
25
+ # as map1d except not using range input
26
+ def test_p5map
25
27
  x = [0, 5, 7.5, 10]
26
28
  range1 = (0..10)
27
29
  range2 = (100..1)
28
30
  range3 = (0..10)
29
31
  range4 = (5..105)
30
- assert_in_delta(p5map(x[0], range1.first, range1.last, range2.first, range2.last), 100, delta = 0.00001)
31
- assert_in_delta(p5map(x[1], range1.first, range1.last, range2.first, range2.last), 50.5, delta = 0.00001)
32
- assert_in_delta(p5map(x[2], range3.first, range3.last, range4.first, range4.last), 80.0, delta = 0.00001)
33
- assert_in_delta(p5map(x[3], range1.first, range1.last, range2.first, range2.last), 1, delta = 0.00001)
32
+ assert_in_delta(p5map(x[0], range1.first, range1.last, range2.first, range2.last), 100, 0.00001)
33
+ assert_in_delta(p5map(x[1], range1.first, range1.last, range2.first, range2.last), 50.5, 0.00001)
34
+ assert_in_delta(p5map(x[2], range3.first, range3.last, range4.first, range4.last), 80.0, 0.00001)
35
+ assert_in_delta(p5map(x[3], range1.first, range1.last, range2.first, range2.last), 1, 0.00001)
34
36
  end
35
37
 
36
38
  def test_norm
37
39
  x = [10, 140, 210]
38
- start0, last0 = 30, 200
39
- start_int, last_int = 0, 200
40
- assert_in_delta(norm(x[0], start0, last0), -0.11764705882352941, delta = 0.00001, msg = 'unclamped map')
41
- assert_in_delta(norm(x[1], start_int, last_int), 0.7, delta = 0.00001, msg = 'map to intermediate')
42
- assert_in_delta(norm(x[2], start_int, last_int), 1.05, delta = 0.00001, msg = 'unclamped map')
40
+ start0 = 30
41
+ last0 = 200
42
+ start_int = 0
43
+ last_int = 200
44
+ assert_in_delta(norm(x[0], start0, last0), -0.11764705882352941, 0.00001, 'unclamped map')
45
+ assert_in_delta(norm(x[1], start_int, last_int), 0.7, 0.00001, 'map to intermediate')
46
+ assert_in_delta(norm(x[2], start_int, last_int), 1.05, 0.00001, 'unclamped map')
43
47
  end
44
48
 
45
49
  def test_norm_strict
46
50
  x = [10, 140, 210]
47
- assert_in_delta(norm_strict(x[2], x[0], x[1]), 1.0, delta = 0.00001, msg = 'clamped map to 0..1.0')
48
- assert_in_delta(norm_strict(x[2], x[1], x[0]), 0.0, delta = 0.00001, msg = 'clamped map to 0..1.0')
49
- assert_in_delta(norm_strict(x[1], x[0], x[2]), 0.65, delta = 0.00001, msg = 'clamped map to 0..1.0')
51
+ assert_in_delta(norm_strict(x[2], x[0], x[1]), 1.0, 0.00001, 'clamped map to 0..1.0')
52
+ assert_in_delta(norm_strict(x[2], x[1], x[0]), 0.0, 0.00001, 'clamped map to 0..1.0')
53
+ assert_in_delta(norm_strict(x[1], x[0], x[2]), 0.65, 0.00001, 'clamped map to 0..1.0')
50
54
  end
51
55
 
52
- def test_lerp # behaviour is deliberately different to processing which is unclamped
56
+ # behaviour is deliberately different to processing which is unclamped
57
+ def test_lerp
53
58
  x = [0.5, 0.8, 2.0]
54
- start0, last0 = 300, 200
55
- start_int, last_int = 0, 200
56
- assert_in_delta(lerp(start0, last0, x[0]), 250, delta = 0.00001, msg = 'produces a intermediate value of a reversed range')
57
- assert_in_delta(lerp(start_int, last_int, x[1]), 160, delta = 0.00001, msg = 'lerps to an intermediate value')
58
- assert_in_delta(lerp(start_int, last_int, x[2]), 200, delta = 0.00001, msg = 'lerps to the last value of a range')
59
+ start0 = 300
60
+ last0 = 200
61
+ start_int = 0
62
+ last_int = 200
63
+ assert_in_delta(lerp(start0, last0, x[0]), 250, 0.00001, 'produces a intermediate value of a reversed range')
64
+ assert_in_delta(lerp(start_int, last_int, x[1]), 160, 0.00001, 'lerps to an intermediate value')
65
+ assert_in_delta(lerp(start_int, last_int, x[2]), 200, 0.00001, 'lerps to the last value of a range')
59
66
  end
60
67
 
61
68
  def test_constrain
62
69
  x_int = [15, 2_500, -2_500]
63
- start_int, last_int = 0, 200
64
- assert_in_delta(constrain(x_int[0], start_int, last_int), 15, delta = 0.00001)
65
- assert_in_delta(constrain(x_int[1], start_int, last_int), 200, delta = 0.00001)
66
- assert_in_delta(constrain(x_int[2], start_int, last_int), 0, delta = 0.00001)
70
+ start_int = 0
71
+ last_int = 200
72
+ assert_in_delta(constrain(x_int[0], start_int, last_int), 15, 0.00001)
73
+ assert_in_delta(constrain(x_int[1], start_int, last_int), 200, 0.00001)
74
+ assert_in_delta(constrain(x_int[2], start_int, last_int), 0, 0.00001)
67
75
  xf = [15.0, 2_500.0, -2_500.0]
68
- startf, lastf = 0, 200.0
69
- assert_in_delta(constrain(xf[0], startf, lastf), 15.0, delta = 0.00001, msg = 'constrain to 0..200')
70
- assert_in_delta(constrain(xf[1], startf, lastf), 200.0, delta = 0.00001, msg = 'constrain to 0..200')
71
- assert_in_delta(constrain(xf[2], startf, lastf), 0.0, delta = 0.00001, msg = 'constrain to 0..200')
76
+ startf = 0
77
+ lastf = 200.0
78
+ assert_in_delta(constrain(xf[0], startf, lastf), 15.0, 0.00001, 'constrain to 0..200')
79
+ assert_in_delta(constrain(xf[1], startf, lastf), 200.0, 0.00001, 'constrain to 0..200')
80
+ assert_in_delta(constrain(xf[2], startf, lastf), 0.0, 0.00001, 'constrain to 0..200')
72
81
  end
73
82
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative 'test_helper'
4
4
 
5
- METHODS = %i(
5
+ METHODS = %i[
6
6
  alpha
7
7
  ambient
8
8
  ambient_light
@@ -181,7 +181,7 @@ METHODS = %i(
181
181
  update_pixels
182
182
  vertex
183
183
  width
184
- )
184
+ ].freeze
185
185
 
186
186
  class TestSketch < Processing::App
187
187
  def settings
@@ -193,7 +193,9 @@ class TestSketch < Processing::App
193
193
  end
194
194
 
195
195
  def draw
196
- exit if frame_count > 30
196
+ exit if frame_count > 20
197
+
198
+ background 0, 200, 0
197
199
  end
198
200
  end
199
201
 
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env jruby
2
- require 'picrate'
2
+ # frozen_string_literal: true
3
3
 
4
+ require 'picrate'
4
5
 
5
6
  class CustomProxySketch < Processing::App
6
-
7
7
  # A simple demonstration of vanilla processing 'reflection' methods using
8
8
  # picrate :library_proxy. See my_library.rb code for the guts.
9
9
  load_libraries :library_proxy, :my_library
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This class demonstrates how by inheriting from the abstract class LibraryProxy
2
4
  # we can access 'keyEvent' and 'draw' (Note we need a draw method even
3
5
  # though can be empty)
@@ -20,6 +22,7 @@ class MyLibrary < LibraryProxy
20
22
  def keyEvent(e) # NB: need camel case for reflection to work
21
23
  return unless e.get_action == KeyEvent::PRESS
22
24
  return if e.get_key > 122 # else we can't use :chr
25
+
23
26
  case e.get_key.chr.upcase
24
27
  when 'S'
25
28
  app.send :hide, false
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  gem 'minitest'
2
4
  require 'java'
3
5
  require_relative '../lib/picrate'
@@ -1,12 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'test_helper'
2
4
 
3
5
  Java::Monkstone::PicrateLibrary.load(JRuby.runtime)
4
6
 
5
-
6
7
  Dir.chdir(File.dirname(__FILE__))
7
8
 
8
9
  class VecmathTest < Minitest::Test
9
-
10
10
  # duck for Vec2D constructor
11
11
  Point = Struct.new(:x, :y)
12
12
  # duck for Vec3D constructor
@@ -15,12 +15,11 @@ class VecmathTest < Minitest::Test
15
15
  Pointless = Struct.new(:a, :b)
16
16
  # non-duck to test fail
17
17
  Pointless3 = Struct.new(:a, :b, :c)
18
- def setup
19
-
20
- end
18
+ def setup; end
21
19
 
22
20
  def test_equals
23
- x, y = 1.0000001, 1.01
21
+ x = 1.0000001
22
+ y = 1.01
24
23
  a = Vec2D.new(x, y)
25
24
  assert_equal(a.to_a, [x, y], 'Failed to return Vec2D as an Array')
26
25
  end
@@ -32,7 +31,8 @@ class VecmathTest < Minitest::Test
32
31
  end
33
32
 
34
33
  def test_copy_equals
35
- x, y = 1.0000001, 1.01
34
+ x = 1.0000001
35
+ y = 1.01
36
36
  a = Vec2D.new(x, y)
37
37
  b = a.copy
38
38
  assert_equal(a.to_a, b.to_a, 'Failed deep copy')
@@ -58,7 +58,8 @@ class VecmathTest < Minitest::Test
58
58
  end
59
59
 
60
60
  def test_copy_not_equals
61
- x, y = 1.0000001, 1.01
61
+ x = 1.0000001
62
+ y = 1.01
62
63
  a = Vec2D.new(x, y)
63
64
  b = a.copy
64
65
  b *= 0
@@ -119,7 +120,7 @@ class VecmathTest < Minitest::Test
119
120
 
120
121
  def test_random
121
122
  a = Vec2D.random
122
- assert a.kind_of? Vec2D
123
+ assert a.is_a? Vec2D
123
124
  assert_in_epsilon(a.mag, 1.0)
124
125
  end
125
126
 
@@ -131,7 +132,7 @@ class VecmathTest < Minitest::Test
131
132
 
132
133
  def test_mag
133
134
  a = Vec2D.new(-3, -4)
134
- assert_in_epsilon(a.mag, 5, 0.001,'Failed to return magnitude of vector')
135
+ assert_in_epsilon(a.mag, 5, 0.001, 'Failed to return magnitude of vector')
135
136
  end
136
137
 
137
138
  def test_mag_variant
@@ -225,14 +226,16 @@ class VecmathTest < Minitest::Test
225
226
  end
226
227
 
227
228
  def test_rotate
228
- x, y = 20, 10
229
+ x = 20
230
+ y = 10
229
231
  b = Vec2D.new(x, y)
230
232
  a = b.rotate(Math::PI / 2)
231
233
  assert_equal(a, Vec2D.new(-10, 20), 'Failed to rotate vector by scalar radians')
232
234
  end
233
235
 
234
236
  def test_hash_index
235
- x, y = 10, 20
237
+ x = 10
238
+ y = 20
236
239
  b = Vec2D.new(x, y)
237
240
  assert_equal(b[:x], x, 'Failed to hash index')
238
241
  end
@@ -267,7 +270,7 @@ class VecmathTest < Minitest::Test
267
270
  a = Vec2D.new(200, 0)
268
271
  b = Vec2D.new(0, 200)
269
272
  # Expected result is an area, twice that of the triangle created by the vectors
270
- assert_equal((a).cross(b).abs, 40_000.0, 'Failed area test using 2D vector cross product')
273
+ assert_equal(a.cross(b).abs, 40_000.0, 'Failed area test using 2D vector cross product')
271
274
  end
272
275
 
273
276
  def test_cross_non_zero # Could be used to calculate area of triangle
@@ -286,7 +289,9 @@ class VecmathTest < Minitest::Test
286
289
  end
287
290
 
288
291
  def test_equals3
289
- x, y, z = 1.0000001, 1.01, 0.0
292
+ x = 1.0000001
293
+ y = 1.01
294
+ z = 0.0
290
295
  a = Vec3D.new(x, y)
291
296
  assert_equal(a.to_a, [x, y, z], 'Failed to return Vec3D as an Array')
292
297
  end
@@ -317,14 +322,18 @@ class VecmathTest < Minitest::Test
317
322
  end
318
323
 
319
324
  def test_copy_equals3
320
- x, y, z = 1.0000001, 1.01, 1
325
+ x = 1.0000001
326
+ y = 1.01
327
+ z = 1
321
328
  a = Vec3D.new(x, y, z)
322
329
  b = a.copy
323
330
  assert_equal(a.to_a, b.to_a, 'Failed deep copy')
324
331
  end
325
332
 
326
333
  def test_copy_not_equals3
327
- x, y, z = 1.0000001, 1.01, 6.0
334
+ x = 1.0000001
335
+ y = 1.01
336
+ z = 6.0
328
337
  a = Vec3D.new(x, y, z)
329
338
  b = a.copy
330
339
  b *= 0
@@ -369,13 +378,13 @@ class VecmathTest < Minitest::Test
369
378
 
370
379
  def test_random3
371
380
  a = Vec3D.random
372
- assert a.kind_of? Vec3D
381
+ assert a.is_a? Vec3D
373
382
  assert_in_epsilon(a.mag, 1.0)
374
383
  end
375
384
 
376
385
  def test_assign_value3
377
386
  a = Vec3D.new(3, 5)
378
- a.x=23
387
+ a.x = 23
379
388
  assert_equal(a.x, 23, 'Failed to assign x value')
380
389
  end
381
390
 
@@ -504,7 +513,9 @@ class VecmathTest < Minitest::Test
504
513
  end
505
514
 
506
515
  def test_hash_key3
507
- x, y, z = 10, 20, 50
516
+ x = 10
517
+ y = 20
518
+ z = 50
508
519
  b = Vec3D.new(x, y, z)
509
520
  assert_equal(b[:x], x, 'Failed hash key access')
510
521
  assert_equal(b[:y], y, 'Failed hash key access')
@@ -2,14 +2,17 @@
2
2
 
3
3
  require 'fileutils'
4
4
  require 'rake/clean'
5
+ require_relative './geany'
5
6
  WARNING = 'WARNING: wget download failed you could do a manual download'
6
7
  SOUND = 'sound.zip'
7
8
  SOUND_VERSION = 'v1.3.2'
8
9
  VIDEO = 'video-2.0-beta4.zip'
9
10
  VIDEO_VERSION = 'r6-v2.0-beta4'
10
- EXAMPLES = '0.5.1'
11
+ EXAMPLES = '0.5.4'
11
12
  HOME_DIR = ENV['HOME']
12
13
  LIBRARY = File.join(HOME_DIR, '.picrate', 'libraries')
14
+ PROJECT_DIR = File.join(HOME_DIR, 'projects')
15
+ EXAMPLES_DIR = File.join(PROJECT_DIR, 'examples')
13
16
  CLOBBER.include(EXAMPLES, SOUND, VIDEO)
14
17
 
15
18
  def dependency
@@ -67,17 +70,20 @@ task :install_config do
67
70
  FileUtils.mkdir_p "#{HOME_DIR}/.config/geany/templates/files"
68
71
  FileUtils.cp 'picrate.rb', "#{HOME_DIR}/.config/geany/templates/files"
69
72
  end
70
- unless File.exist? "#{HOME_DIR}/projects/sketchbook/picrate_sketches.geany"
71
- FileUtils.mkdir_p "#{HOME_DIR}/projects/sketchbook"
72
- FileUtils.cp 'picrate_sketches.geany', "#{HOME_DIR}/projects/sketchbook"
73
+ project_dir = File.join(HOME_DIR, 'projects')
74
+ unless File.exist? File.join(project_dir, 'examples', 'picrate_sketches.geany')
75
+ FileUtils.mkdir_p "#{HOME_DIR}/projects/examples"
76
+ config = GeanyConfig.new(project_dir, 'examples')
77
+ config.save(File.join(project_dir, 'examples', 'picrate_sketches.geany'))
73
78
  end
74
79
  end
75
80
 
76
81
  desc 'copy examples'
77
82
  task copy_examples: %i[download_samples] do
78
83
  system "tar xzvf #{EXAMPLES}.tar.gz"
79
- FileUtils.rm_r "#{HOME_DIR}/picrate_samples" if File.exist? "#{HOME_DIR}/picrate_samples"
80
- FileUtils.cp_r "picrate-examples-#{EXAMPLES}", "#{HOME_DIR}/picrate_samples"
84
+ FileUtils.rm_r EXAMPLES_DIR if File.exist? EXAMPLES_DIR
85
+ FileUtils.mkdir_p PROJECT_DIR unless File.exist? PROJECT_DIR
86
+ FileUtils.cp_r "picrate-examples-#{EXAMPLES}", EXAMPLES_DIR
81
87
  FileUtils.rm_r "picrate-examples-#{EXAMPLES}"
82
88
  end
83
89
 
@@ -93,5 +99,5 @@ task copy_video: "/tmp/#{VIDEO}" do
93
99
  system "unzip -d /tmp /tmp/#{VIDEO}"
94
100
  FileUtils.rm_r "#{LIBRARY}/video" if File.exist? "#{LIBRARY}/video"
95
101
  FileUtils.mkdir_p "#{LIBRARY}/video/library"
96
- FileUtils.mv Dir.glob("/tmp/video/library/*.jar"), "#{LIBRARY}/video/library"
102
+ FileUtils.mv Dir.glob('/tmp/video/library/*.jar'), "#{LIBRARY}/video/library"
97
103
  end