picrate 1.3.0-java → 2.1.2-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
- data/CHANGELOG.md +10 -1
- data/Gemfile +3 -1
- data/README.md +9 -6
- data/Rakefile +8 -3
- data/bin/picrate +3 -1
- data/docs/_config.yml +1 -1
- data/docs/_editors/geany.md +1 -0
- data/docs/_gems/gems/gems.md +1 -1
- data/docs/_methods/alternative_methods.md +2 -1
- data/docs/_posts/2018-05-06-getting_started.md +4 -4
- data/docs/_posts/2018-05-06-install_jruby.md +5 -11
- data/docs/_posts/2018-05-11-arch-linux-arm.md +1 -11
- data/docs/_posts/2018-11-18-building-gem.md +2 -2
- data/docs/_posts/2018-11-27-getting_started_geany.md +1 -1
- data/docs/_posts/2019-11-11-getting_started_buster.md +3 -6
- data/docs/_posts/{2018-06-26-auto_install_picrate.md → 2020-03-09-auto_install_picrate.md} +9 -6
- data/docs/_posts/2020-05-11-getting_started_manjaro.md +106 -0
- data/docs/about.md +1 -1
- data/lib/picrate.rb +3 -2
- data/lib/picrate/app.rb +11 -3
- data/lib/picrate/creators/parameters.rb +8 -8
- data/lib/picrate/creators/sketch_factory.rb +5 -3
- data/lib/picrate/helper_methods.rb +22 -22
- data/lib/picrate/helpers/numeric.rb +2 -0
- data/lib/picrate/library.rb +5 -1
- data/lib/picrate/library_loader.rb +2 -0
- data/lib/picrate/native_folder.rb +2 -1
- data/lib/picrate/native_loader.rb +3 -0
- data/lib/picrate/runner.rb +5 -4
- data/lib/picrate/version.rb +1 -1
- data/library/boids/boids.rb +17 -8
- data/library/chooser/chooser.rb +10 -9
- data/library/color_group/color_group.rb +2 -0
- data/library/control_panel/control_panel.rb +7 -4
- data/library/dxf/dxf.rb +2 -0
- data/library/jcomplex/jcomplex.rb +1 -0
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +2 -0
- data/library/slider/slider.rb +24 -23
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +2 -0
- data/mvnw +2 -2
- data/mvnw.cmd +2 -2
- data/picrate.gemspec +13 -13
- data/pom.rb +26 -23
- data/pom.xml +19 -7
- data/src/main/java/monkstone/ColorUtil.java +1 -1
- data/src/main/java/monkstone/MathToolModule.java +1 -1
- data/src/main/java/monkstone/PicrateLibrary.java +8 -8
- data/src/main/java/monkstone/complex/JComplex.java +252 -0
- data/src/main/java/monkstone/fastmath/Deglut.java +16 -16
- data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +3 -3
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +12 -12
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +33 -36
- data/src/main/java/processing/awt/PImageAWT.java +377 -0
- data/src/main/java/processing/awt/PSurfaceAWT.java +0 -20
- data/src/main/java/processing/awt/ShimAWT.java +545 -0
- data/src/main/java/processing/core/PApplet.java +699 -1523
- data/src/main/java/processing/core/PConstants.java +180 -180
- data/src/main/java/processing/core/PFont.java +2 -2
- data/src/main/java/processing/core/PGraphics.java +190 -176
- data/src/main/java/processing/core/PImage.java +1536 -1721
- data/src/main/java/processing/core/PMatrix.java +39 -39
- data/src/main/java/processing/core/PSurface.java +69 -103
- data/src/main/java/processing/core/PSurfaceNone.java +29 -0
- data/src/main/java/processing/core/PVector.java +2 -2
- data/src/main/java/processing/data/FloatDict.java +251 -284
- data/src/main/java/processing/data/TableRow.java +32 -32
- data/src/main/java/processing/dxf/RawDXF.java +3 -3
- data/src/main/java/processing/net/Client.java +1 -1
- data/src/main/java/processing/opengl/PGL.java +1016 -4132
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +232 -176
- data/src/main/java/processing/opengl/PJOGL.java +374 -1526
- data/src/main/java/processing/opengl/PShapeOpenGL.java +5 -6
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +262 -147
- data/test/color_group_test.rb +4 -4
- data/test/deglut_spec_test.rb +2 -0
- data/test/helper_methods_test.rb +41 -13
- data/test/math_tool_test.rb +46 -37
- data/test/respond_to_test.rb +5 -3
- data/test/sketches/key_event.rb +2 -2
- data/test/sketches/library/my_library/my_library.rb +3 -0
- data/test/test_helper.rb +2 -0
- data/test/vecmath_spec_test.rb +30 -19
- data/vendors/Rakefile +33 -21
- data/vendors/{picrate_sketches.geany → geany.rb} +32 -7
- metadata +27 -46
- data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
- data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
data/test/color_group_test.rb
CHANGED
@@ -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 = [
|
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.
|
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.
|
22
|
+
assert group.is_a? ColorGroup
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_ruby_string
|
26
|
-
p5array = [
|
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
|
data/test/deglut_spec_test.rb
CHANGED
data/test/helper_methods_test.rb
CHANGED
@@ -10,40 +10,68 @@ include MathTool
|
|
10
10
|
Dir.chdir(File.dirname(__FILE__))
|
11
11
|
|
12
12
|
class HelperMethodsTest < Minitest::Test
|
13
|
-
|
14
|
-
|
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) == -
|
22
|
-
assert hex_color(hexstring) == -
|
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
|
-
|
28
|
+
end
|
30
29
|
|
31
30
|
def test_dist
|
32
|
-
ax
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
|
data/test/math_tool_test.rb
CHANGED
@@ -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
|
11
|
-
|
12
|
-
|
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,
|
19
|
-
assert_in_delta(map1d(x[1], range1, range2), 50.5,
|
20
|
-
assert_in_delta(map1d(x[2], range3, range4), 80.0,
|
21
|
-
assert_in_delta(map1d(x[3], range1, range2), 1,
|
22
|
-
|
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
|
-
|
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,
|
31
|
-
assert_in_delta(p5map(x[1], range1.first, range1.last, range2.first, range2.last), 50.5,
|
32
|
-
assert_in_delta(p5map(x[2], range3.first, range3.last, range4.first, range4.last), 80.0,
|
33
|
-
assert_in_delta(p5map(x[3], range1.first, range1.last, range2.first, range2.last), 1,
|
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
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
assert_in_delta(norm(x[
|
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,
|
48
|
-
assert_in_delta(norm_strict(x[2], x[1], x[0]), 0.0,
|
49
|
-
assert_in_delta(norm_strict(x[1], x[0], x[2]), 0.65,
|
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
|
-
|
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
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
assert_in_delta(lerp(
|
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
|
64
|
-
|
65
|
-
assert_in_delta(constrain(x_int[
|
66
|
-
assert_in_delta(constrain(x_int[
|
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
|
69
|
-
|
70
|
-
assert_in_delta(constrain(xf[
|
71
|
-
assert_in_delta(constrain(xf[
|
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
|
data/test/respond_to_test.rb
CHANGED
@@ -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 >
|
196
|
+
exit if frame_count > 20
|
197
|
+
|
198
|
+
background 0, 200, 0
|
197
199
|
end
|
198
200
|
end
|
199
201
|
|
data/test/sketches/key_event.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env jruby
|
2
|
-
|
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
|
data/test/test_helper.rb
CHANGED
data/test/vecmath_spec_test.rb
CHANGED
@@ -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
|
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
|
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
|
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.
|
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
|
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
|
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(
|
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
|
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
|
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
|
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.
|
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
|
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')
|
data/vendors/Rakefile
CHANGED
@@ -2,12 +2,13 @@
|
|
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
|
-
VIDEO = 'video
|
9
|
-
|
10
|
-
EXAMPLES = '0.5.
|
8
|
+
PROCESSING_GITHUB = 'https://github.com/processing'
|
9
|
+
VIDEO = 'video.zip'
|
10
|
+
DOWNLOAD = 'releases/download/latest'
|
11
|
+
EXAMPLES = '0.5.5'
|
11
12
|
HOME_DIR = ENV['HOME']
|
12
13
|
LIBRARY = File.join(HOME_DIR, '.picrate', 'libraries')
|
13
14
|
PROJECT_DIR = File.join(HOME_DIR, 'projects')
|
@@ -46,16 +47,24 @@ task download_samples: ["#{EXAMPLES}.tar.gz"]
|
|
46
47
|
|
47
48
|
desc 'download sound library'
|
48
49
|
task :download_sound do
|
49
|
-
wget_base = 'wget
|
50
|
-
wget_string = [wget_base, '
|
51
|
-
|
50
|
+
wget_base = ['wget', PROCESSING_GITHUB].join(' ')
|
51
|
+
wget_string = [wget_base, 'processing-sound', DOWNLOAD, SOUND].join('/')
|
52
|
+
begin
|
53
|
+
sh wget_string
|
54
|
+
rescue StandardError
|
55
|
+
warn(WARNING)
|
56
|
+
end
|
52
57
|
end
|
53
58
|
|
54
59
|
desc 'download video library'
|
55
60
|
task :download_video do
|
56
|
-
wget_base = 'wget
|
57
|
-
wget_string = [wget_base, '
|
58
|
-
|
61
|
+
wget_base = ['wget', PROCESSING_GITHUB].join(' ')
|
62
|
+
wget_string = [wget_base, 'processing-video', DOWNLOAD, VIDEO].join('/')
|
63
|
+
begin
|
64
|
+
sh wget_string
|
65
|
+
rescue StandardError
|
66
|
+
warn(WARNING)
|
67
|
+
end
|
59
68
|
end
|
60
69
|
|
61
70
|
desc 'initialize ~/.picrate directories'
|
@@ -69,9 +78,11 @@ task :install_config do
|
|
69
78
|
FileUtils.mkdir_p "#{HOME_DIR}/.config/geany/templates/files"
|
70
79
|
FileUtils.cp 'picrate.rb', "#{HOME_DIR}/.config/geany/templates/files"
|
71
80
|
end
|
72
|
-
|
73
|
-
|
74
|
-
FileUtils.
|
81
|
+
project_dir = File.join(HOME_DIR, 'projects')
|
82
|
+
unless File.exist? File.join(project_dir, 'picrate_sketches.geany')
|
83
|
+
FileUtils.mkdir_p "#{HOME_DIR}/projects"
|
84
|
+
config = GeanyConfig.new(project_dir)
|
85
|
+
config.save(File.join(project_dir, 'picrate_sketches.geany'))
|
75
86
|
end
|
76
87
|
end
|
77
88
|
|
@@ -86,15 +97,16 @@ end
|
|
86
97
|
|
87
98
|
desc 'copy sound library'
|
88
99
|
task copy_sound: SOUND do
|
89
|
-
|
90
|
-
|
91
|
-
|
100
|
+
sh "unzip #{SOUND}"
|
101
|
+
sh "rm -r #{LIBRARY}/sound" if File.exist? "#{LIBRARY}/sound"
|
102
|
+
sh "cp -r sound #{LIBRARY}"
|
103
|
+
sh 'rm -r sound'
|
92
104
|
end
|
93
105
|
|
94
106
|
desc 'copy video library'
|
95
|
-
task copy_video:
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
107
|
+
task copy_video: VIDEO do
|
108
|
+
sh "unzip #{VIDEO}"
|
109
|
+
sh "rm -r #{LIBRARY}/video" if File.exist? "#{LIBRARY}/video"
|
110
|
+
sh "cp -r video #{LIBRARY}"
|
111
|
+
sh 'rm -r video'
|
100
112
|
end
|