propane 3.4.1-java → 3.7.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -1
- data/.mvn/wrapper/MavenWrapperDownloader.java +2 -2
- data/.mvn/wrapper/maven-wrapper.properties +2 -2
- data/.travis.yml +1 -1
- data/CHANGELOG.md +9 -1
- data/Gemfile +2 -0
- data/README.md +9 -5
- data/Rakefile +10 -11
- data/bin/propane +3 -1
- data/lib/propane.rb +4 -2
- data/lib/propane/app.rb +2 -1
- data/lib/propane/creators/sketch_class.rb +7 -1
- data/lib/propane/creators/sketch_factory.rb +4 -2
- data/lib/propane/creators/sketch_writer.rb +1 -0
- data/lib/propane/helper_methods.rb +22 -23
- data/lib/propane/helpers/numeric.rb +2 -0
- data/lib/propane/helpers/version_error.rb +1 -0
- data/lib/propane/library.rb +5 -1
- data/lib/propane/library_loader.rb +2 -0
- data/lib/propane/native_folder.rb +10 -9
- data/lib/propane/native_loader.rb +3 -0
- data/lib/propane/runner.rb +20 -14
- data/lib/propane/version.rb +2 -1
- data/library/boids/boids.rb +21 -11
- data/library/color_group/color_group.rb +2 -0
- data/library/control_panel/control_panel.rb +8 -5
- data/library/dxf/dxf.rb +2 -0
- data/library/file_chooser/chooser.rb +10 -9
- data/library/file_chooser/file_chooser.rb +10 -9
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +2 -0
- data/library/simplex_noise/simplex_noise.rb +2 -0
- data/library/slider/slider.rb +23 -22
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +2 -0
- data/pom.rb +37 -36
- data/pom.xml +6 -6
- data/propane.gemspec +12 -10
- data/src/main/java/japplemenubar/JAppleMenuBar.java +3 -3
- data/src/main/java/monkstone/ColorUtil.java +1 -3
- data/src/main/java/monkstone/MathToolModule.java +10 -9
- data/src/main/java/monkstone/PropaneLibrary.java +2 -2
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
- data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +2 -2
- 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 +1 -1
- 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 -2
- 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 +781 -285
- data/src/main/java/processing/awt/PImageAWT.java +377 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +56 -52
- data/src/main/java/processing/awt/PSurfaceAWT.java +308 -208
- data/src/main/java/processing/awt/ShimAWT.java +581 -0
- data/src/main/java/processing/core/PApplet.java +4225 -4855
- data/src/main/java/processing/core/PConstants.java +477 -447
- data/src/main/java/processing/core/PFont.java +914 -880
- data/src/main/java/processing/core/PGraphics.java +150 -134
- data/src/main/java/processing/core/PImage.java +275 -372
- data/src/main/java/processing/core/PMatrix.java +172 -159
- data/src/main/java/processing/core/PMatrix2D.java +478 -415
- data/src/main/java/processing/core/PMatrix3D.java +762 -735
- data/src/main/java/processing/core/PShape.java +2887 -2651
- data/src/main/java/processing/core/PShapeOBJ.java +97 -92
- data/src/main/java/processing/core/PShapeSVG.java +1705 -1490
- data/src/main/java/processing/core/PStyle.java +40 -37
- data/src/main/java/processing/core/PSurface.java +139 -97
- data/src/main/java/processing/core/PSurfaceNone.java +296 -218
- data/src/main/java/processing/core/PVector.java +995 -963
- data/src/main/java/processing/core/ThinkDifferent.java +12 -8
- data/src/main/java/processing/data/DoubleDict.java +756 -710
- data/src/main/java/processing/data/DoubleList.java +749 -696
- data/src/main/java/processing/data/FloatDict.java +748 -702
- data/src/main/java/processing/data/FloatList.java +751 -697
- data/src/main/java/processing/data/IntDict.java +720 -673
- data/src/main/java/processing/data/IntList.java +699 -633
- data/src/main/java/processing/data/JSONArray.java +931 -873
- data/src/main/java/processing/data/JSONObject.java +1262 -1165
- data/src/main/java/processing/data/JSONTokener.java +351 -341
- data/src/main/java/processing/data/LongDict.java +710 -663
- data/src/main/java/processing/data/LongList.java +701 -635
- data/src/main/java/processing/data/Sort.java +37 -41
- data/src/main/java/processing/data/StringDict.java +525 -486
- data/src/main/java/processing/data/StringList.java +626 -580
- data/src/main/java/processing/data/Table.java +3690 -3510
- data/src/main/java/processing/data/TableRow.java +182 -183
- data/src/main/java/processing/data/XML.java +957 -883
- data/src/main/java/processing/event/Event.java +87 -67
- data/src/main/java/processing/event/KeyEvent.java +48 -41
- data/src/main/java/processing/event/MouseEvent.java +88 -113
- data/src/main/java/processing/event/TouchEvent.java +10 -6
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
- data/src/main/java/processing/javafx/PSurfaceFX.java +149 -121
- data/src/main/java/processing/net/Client.java +20 -20
- data/src/main/java/processing/net/Server.java +9 -9
- data/src/main/java/processing/opengl/FontTexture.java +286 -266
- data/src/main/java/processing/opengl/FrameBuffer.java +389 -377
- data/src/main/java/processing/opengl/LinePath.java +132 -89
- data/src/main/java/processing/opengl/LineStroker.java +588 -581
- data/src/main/java/processing/opengl/PGL.java +660 -567
- data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
- data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12378 -12075
- data/src/main/java/processing/opengl/PJOGL.java +1753 -1670
- data/src/main/java/processing/opengl/PShader.java +369 -461
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4678 -4580
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1114 -1027
- data/src/main/java/processing/opengl/Texture.java +1492 -1401
- data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
- data/test/create_test.rb +21 -20
- data/test/deglut_spec_test.rb +4 -2
- data/test/helper_methods_test.rb +49 -20
- data/test/math_tool_test.rb +39 -32
- data/test/native_folder.rb +47 -0
- data/test/respond_to_test.rb +3 -2
- 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 +35 -22
- data/vendors/Rakefile +35 -40
- metadata +42 -22
- 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
@@ -1,3 +1,5 @@
|
|
1
|
+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
|
+
|
1
3
|
/*
|
2
4
|
Part of the Processing project - http://processing.org
|
3
5
|
|
@@ -18,69 +20,69 @@
|
|
18
20
|
Public License along with this library; if not, write to the
|
19
21
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
20
22
|
Boston, MA 02111-1307 USA
|
21
|
-
|
23
|
+
*/
|
24
|
+
|
22
25
|
package processing.opengl;
|
23
26
|
|
24
27
|
import processing.opengl.PGraphicsOpenGL.GLResourceVertexBuffer;
|
25
28
|
|
26
29
|
// TODO: need to combine with PGraphicsOpenGL.VertexAttribute
|
27
30
|
public class VertexBuffer {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
glres = null;
|
75
|
-
}
|
31
|
+
static protected final int INIT_VERTEX_BUFFER_SIZE = 256;
|
32
|
+
static protected final int INIT_INDEX_BUFFER_SIZE = 512;
|
33
|
+
|
34
|
+
public int glId;
|
35
|
+
int target;
|
36
|
+
int elementSize;
|
37
|
+
int ncoords;
|
38
|
+
boolean index;
|
39
|
+
|
40
|
+
protected PGL pgl; // The interface between Processing and OpenGL.
|
41
|
+
protected int context; // The context that created this texture.
|
42
|
+
private GLResourceVertexBuffer glres;
|
43
|
+
|
44
|
+
VertexBuffer(PGraphicsOpenGL pg, int target, int ncoords, int esize) {
|
45
|
+
this(pg, target, ncoords, esize, false);
|
46
|
+
}
|
47
|
+
|
48
|
+
VertexBuffer(PGraphicsOpenGL pg, int target, int ncoords, int esize, boolean index) {
|
49
|
+
pgl = pg.pgl;
|
50
|
+
context = pgl.createEmptyContext();
|
51
|
+
|
52
|
+
this.target = target;
|
53
|
+
this.ncoords = ncoords;
|
54
|
+
this.elementSize = esize;
|
55
|
+
this.index = index;
|
56
|
+
create();
|
57
|
+
init();
|
58
|
+
}
|
59
|
+
|
60
|
+
protected final void create() {
|
61
|
+
context = pgl.getCurrentContext();
|
62
|
+
glres = new GLResourceVertexBuffer(this);
|
63
|
+
}
|
64
|
+
|
65
|
+
protected final void init() {
|
66
|
+
int size = index ? ncoords * INIT_INDEX_BUFFER_SIZE * elementSize :
|
67
|
+
ncoords * INIT_VERTEX_BUFFER_SIZE * elementSize;
|
68
|
+
pgl.bindBuffer(target, glId);
|
69
|
+
pgl.bufferData(target, size, null, PGL.STATIC_DRAW);
|
70
|
+
}
|
71
|
+
|
72
|
+
protected void dispose() {
|
73
|
+
if (glres != null) {
|
74
|
+
glres.dispose();
|
75
|
+
glId = 0;
|
76
|
+
glres = null;
|
76
77
|
}
|
78
|
+
}
|
77
79
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
}
|
83
|
-
return outdated;
|
80
|
+
protected boolean contextIsOutdated() {
|
81
|
+
boolean outdated = !pgl.contextIsCurrent(context);
|
82
|
+
if (outdated) {
|
83
|
+
dispose();
|
84
84
|
}
|
85
|
+
return outdated;
|
86
|
+
}
|
85
87
|
|
86
88
|
}
|
data/test/create_test.rb
CHANGED
@@ -1,33 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'test_helper'
|
2
4
|
require_relative '../lib/propane/creators/sketch_class'
|
3
5
|
require_relative '../lib/propane/creators/sketch_writer'
|
4
6
|
|
5
7
|
CLASS_SKETCH = <<~CODE
|
8
|
+
#!/usr/bin/env jruby
|
9
|
+
# frozen_string_literal: false
|
6
10
|
|
7
|
-
|
8
|
-
# frozen_string_literal: false
|
9
|
-
require 'propane'
|
11
|
+
require 'propane'
|
10
12
|
|
11
|
-
class FredSketch < Propane::App
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
class FredSketch < Propane::App
|
14
|
+
def settings
|
15
|
+
size 200, 200
|
16
|
+
end
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
def setup
|
19
|
+
sketch_title 'Fred Sketch'
|
20
|
+
end
|
19
21
|
|
20
|
-
|
22
|
+
def draw
|
21
23
|
|
24
|
+
end
|
22
25
|
end
|
23
|
-
end
|
24
26
|
|
25
|
-
FredSketch.new
|
27
|
+
FredSketch.new
|
26
28
|
|
27
29
|
CODE
|
28
|
-
|
30
|
+
# Create sketch test
|
29
31
|
class SketchClassTest < Minitest::Test
|
30
|
-
|
31
32
|
def setup
|
32
33
|
@basic = SketchClass.new(name: 'fred_sketch', width: 200, height: 200)
|
33
34
|
@sketch = SketchClass.new(name: 'fred_sketch', width: 200, height: 200, mode: 'p2d')
|
@@ -35,7 +36,7 @@ class SketchClassTest < Minitest::Test
|
|
35
36
|
|
36
37
|
def test_class
|
37
38
|
result = CLASS_SKETCH.split(/\n/, -1)
|
38
|
-
class_lines = @
|
39
|
+
class_lines = @basic.lines
|
39
40
|
class_lines.each_with_index do |line, i|
|
40
41
|
assert_equal result[i], line
|
41
42
|
end
|
@@ -54,15 +55,15 @@ class SketchClassTest < Minitest::Test
|
|
54
55
|
assert_equal " sketch_title 'Fred Sketch'", @sketch.sketch_title
|
55
56
|
end
|
56
57
|
|
57
|
-
def
|
58
|
-
assert_equal
|
58
|
+
def test_class_class
|
59
|
+
assert_equal 'FredSketch', @sketch.sketch_class
|
59
60
|
end
|
60
61
|
|
61
62
|
def test_class_new
|
62
|
-
assert_equal
|
63
|
+
assert_equal 'FredSketch.new', @sketch.sketch_new
|
63
64
|
end
|
64
65
|
|
65
66
|
def test_sketch_class
|
66
|
-
assert_equal
|
67
|
+
assert_equal 'class FredSketch < Propane::App', @basic.class_sketch
|
67
68
|
end
|
68
69
|
end
|
data/test/deglut_spec_test.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'test_helper'
|
2
4
|
require 'java'
|
3
5
|
require_relative '../lib/propane'
|
@@ -15,10 +17,10 @@ class DeglutTest < Minitest::Test
|
|
15
17
|
(-720..720).step(1) do |deg|
|
16
18
|
sine = DegLut.sin(deg)
|
17
19
|
deg_sin = Math.sin(deg * to_radian)
|
18
|
-
assert_in_delta(sine, deg_sin,
|
20
|
+
assert_in_delta(sine, deg_sin, 0.000001)
|
19
21
|
cosine = DegLut.cos(deg)
|
20
22
|
deg_cos = Math.cos(deg * to_radian)
|
21
|
-
assert_in_delta(cosine, deg_cos,
|
23
|
+
assert_in_delta(cosine, deg_cos, 0.000001)
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
data/test/helper_methods_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require_relative 'test_helper'
|
3
4
|
require 'java'
|
4
5
|
require_relative '../lib/propane'
|
@@ -11,41 +12,69 @@ include MathTool
|
|
11
12
|
Dir.chdir(File.dirname(__FILE__))
|
12
13
|
|
13
14
|
class HelperMethodsTest < Minitest::Test
|
14
|
-
|
15
|
-
|
16
|
-
def test_hex_color
|
15
|
+
ARRAY = %w[albatross dog horse].freeze
|
16
|
+
def test_hex_color
|
17
17
|
col_double = 0.5
|
18
18
|
hexcolor = 0xFFCC6600
|
19
19
|
dodgy_hexstring = '*56666'
|
20
20
|
hexstring = '#CC6600'
|
21
21
|
assert hex_color(col_double) == 0.5, 'double as a color'
|
22
|
-
assert hex_color(hexcolor) == -
|
23
|
-
assert hex_color(hexstring) == -
|
22
|
+
assert hex_color(hexcolor) == -3_381_760, 'hexadecimal fixnum color'
|
23
|
+
assert hex_color(hexstring) == -3_381_760, 'hexadecimal string color'
|
24
24
|
assert_raises(StandardError, 'Dodgy Hexstring') do
|
25
25
|
hex_color(dodgy_hexstring)
|
26
26
|
end
|
27
27
|
assert_raises(StandardError, 'Dodgy Color Conversion') do
|
28
28
|
hex_color([])
|
29
29
|
end
|
30
|
-
|
30
|
+
end
|
31
31
|
|
32
32
|
def test_dist
|
33
|
-
ax
|
34
|
-
|
33
|
+
ax = 0
|
34
|
+
ay = 0
|
35
|
+
bx = 1.0
|
36
|
+
by = 1.0
|
37
|
+
assert_in_epsilon(dist(ax, ay, bx, by), Math.sqrt(2), 0.0001, '2D distance')
|
35
38
|
by = 0.0
|
36
|
-
assert_in_epsilon(dist(ax, ay, bx, by), 1.0,
|
37
|
-
ax
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
ax, ay, bx, by,
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
39
|
+
assert_in_epsilon(dist(ax, ay, bx, by), 1.0, 0.0001, 'when y dimension is zero')
|
40
|
+
ax = 0
|
41
|
+
ay = 0
|
42
|
+
bx = 0.0
|
43
|
+
by = 0.0
|
44
|
+
assert_in_epsilon(dist(ax, ay, bx, by), 0.0, 0.0001, 'when x and y dimension are zero')
|
45
|
+
ax = 1
|
46
|
+
ay = 1
|
47
|
+
bx = -2.0
|
48
|
+
by = -3.0
|
49
|
+
assert_in_epsilon(dist(ax, ay, bx, by), 5.0, 0.0001, 'classic triangle dimensions')
|
50
|
+
ax = -1
|
51
|
+
ay = -1
|
52
|
+
bx = 100
|
53
|
+
by = 2.0
|
54
|
+
cx = 3.0
|
55
|
+
cy = 100
|
56
|
+
assert_in_epsilon(dist(ax, ay, bx, by, cx, cy), 5.0, 0.0001, 'classic triangle dimensions')
|
57
|
+
ax = 0
|
58
|
+
ay = 0
|
59
|
+
bx = -1.0
|
60
|
+
by = -1.0
|
61
|
+
cx = 0
|
62
|
+
cy = 0
|
63
|
+
assert_in_epsilon(dist(ax, ay, bx, by, cx, cy), Math.sqrt(2), 0.0001, '2D distance')
|
64
|
+
ax = 0
|
65
|
+
ay = 0
|
66
|
+
bx = 0.0
|
67
|
+
by = 0.0
|
68
|
+
cx = 0
|
69
|
+
cy = 0
|
46
70
|
assert_in_epsilon(dist(ax, ay, bx, by, cx, cy), 0.0)
|
47
|
-
ax
|
48
|
-
|
71
|
+
ax = 0
|
72
|
+
ay = 0
|
73
|
+
bx = 1.0
|
74
|
+
by = 0.0
|
75
|
+
cx = 0
|
76
|
+
cy = 0
|
77
|
+
assert_in_epsilon(dist(ax, ay, bx, by, cx, cy), 1.0, 0.0001, 'when x and z dimension are zero')
|
49
78
|
end
|
50
79
|
|
51
80
|
def test_min
|
data/test/math_tool_test.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'test_helper'
|
2
4
|
require 'java'
|
3
5
|
require_relative '../lib/propane'
|
@@ -6,21 +8,20 @@ Java::Monkstone::PropaneLibrary.new.load(JRuby.runtime, false)
|
|
6
8
|
|
7
9
|
# include Processing::HelperMethods
|
8
10
|
|
9
|
-
|
10
11
|
Dir.chdir(File.dirname(__FILE__))
|
11
12
|
|
12
13
|
class MathToolTest < Minitest::Test
|
13
|
-
|
14
|
-
|
14
|
+
include MathTool
|
15
|
+
def test_map1d
|
15
16
|
x = [0, 5, 7.5, 10]
|
16
17
|
range1 = (0..10)
|
17
18
|
range2 = (100..1)
|
18
19
|
range3 = (0..10)
|
19
20
|
range4 = (5..105)
|
20
|
-
assert_in_delta(map1d(x[0], range1, range2), 100,
|
21
|
-
assert_in_delta(map1d(x[1], range1, range2), 50.5,
|
22
|
-
assert_in_delta(map1d(x[2], range3, range4), 80.0,
|
23
|
-
assert_in_delta(map1d(x[3], range1, range2), 1,
|
21
|
+
assert_in_delta(map1d(x[0], range1, range2), 100, 0.00001, 'map to first')
|
22
|
+
assert_in_delta(map1d(x[1], range1, range2), 50.5, 0.00001, 'map to reversed intermediate')
|
23
|
+
assert_in_delta(map1d(x[2], range3, range4), 80.0, 0.00001, 'map to intermediate')
|
24
|
+
assert_in_delta(map1d(x[3], range1, range2), 1, 0.00001, 'map to last')
|
24
25
|
end
|
25
26
|
|
26
27
|
def test_p5map # as map1d except not using range input
|
@@ -29,47 +30,53 @@ class MathToolTest < Minitest::Test
|
|
29
30
|
range2 = (100..1)
|
30
31
|
range3 = (0..10)
|
31
32
|
range4 = (5..105)
|
32
|
-
assert_in_delta(p5map(x[0], range1.first, range1.last, range2.first, range2.last), 100,
|
33
|
-
assert_in_delta(p5map(x[1], range1.first, range1.last, range2.first, range2.last), 50.5,
|
34
|
-
assert_in_delta(p5map(x[2], range3.first, range3.last, range4.first, range4.last), 80.0,
|
35
|
-
assert_in_delta(p5map(x[3], range1.first, range1.last, range2.first, range2.last), 1,
|
33
|
+
assert_in_delta(p5map(x[0], range1.first, range1.last, range2.first, range2.last), 100, 0.00001)
|
34
|
+
assert_in_delta(p5map(x[1], range1.first, range1.last, range2.first, range2.last), 50.5, 0.00001)
|
35
|
+
assert_in_delta(p5map(x[2], range3.first, range3.last, range4.first, range4.last), 80.0, 0.00001)
|
36
|
+
assert_in_delta(p5map(x[3], range1.first, range1.last, range2.first, range2.last), 1, 0.00001)
|
36
37
|
end
|
37
38
|
|
38
39
|
def test_norm
|
39
40
|
x = [10, 140, 210]
|
40
|
-
start0
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
assert_in_delta(norm(x[
|
41
|
+
start0 = 30
|
42
|
+
last0 = 200
|
43
|
+
start_int = 0
|
44
|
+
last_int = 200
|
45
|
+
assert_in_delta(norm(x[0], start0, last0), -0.11764705882352941, 0.00001, 'unclamped map')
|
46
|
+
assert_in_delta(norm(x[1], start_int, last_int), 0.7, 0.00001, 'map to intermediate')
|
47
|
+
assert_in_delta(norm(x[2], start_int, last_int), 1.05, 0.00001, 'unclamped map')
|
45
48
|
end
|
46
49
|
|
47
50
|
def test_norm_strict
|
48
51
|
x = [10, 140, 210]
|
49
|
-
assert_in_delta(norm_strict(x[2], x[0], x[1]), 1.0,
|
50
|
-
assert_in_delta(norm_strict(x[2], x[1], x[0]), 0.0,
|
51
|
-
assert_in_delta(norm_strict(x[1], x[0], x[2]), 0.65,
|
52
|
+
assert_in_delta(norm_strict(x[2], x[0], x[1]), 1.0, 0.00001, 'clamped map to 0..1.0')
|
53
|
+
assert_in_delta(norm_strict(x[2], x[1], x[0]), 0.0, 0.00001, 'clamped map to 0..1.0')
|
54
|
+
assert_in_delta(norm_strict(x[1], x[0], x[2]), 0.65, 0.00001, 'clamped map to 0..1.0')
|
52
55
|
end
|
53
56
|
|
54
57
|
def test_lerp # behaviour is deliberately different to processing which is unclamped
|
55
58
|
x = [0.5, 0.8, 2.0]
|
56
|
-
start0
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
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')
|
61
66
|
end
|
62
67
|
|
63
68
|
def test_constrain
|
64
69
|
x_int = [15, 2_500, -2_500]
|
65
|
-
start_int
|
66
|
-
|
67
|
-
assert_in_delta(constrain(x_int[
|
68
|
-
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)
|
69
75
|
xf = [15.0, 2_500.0, -2_500.0]
|
70
|
-
startf
|
71
|
-
|
72
|
-
assert_in_delta(constrain(xf[
|
73
|
-
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')
|
74
81
|
end
|
75
82
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'test_helper'
|
4
|
+
require 'java'
|
5
|
+
require_relative '../lib/propane'
|
6
|
+
# Mock class
|
7
|
+
class WindowsNativeFolder < NativeFolder
|
8
|
+
def initialize
|
9
|
+
@os = 'mswin'
|
10
|
+
@bit = 64
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class MacNativeFolder < NativeFolder
|
15
|
+
def initialize
|
16
|
+
@os = 'mac'
|
17
|
+
@bit = 64
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Test class
|
22
|
+
class NativeFolderTest < Minitest::Test
|
23
|
+
def test_windows_native_folder
|
24
|
+
obj = WindowsNativeFolder.new
|
25
|
+
assert_kind_of NativeFolder, obj, 'Constructor Failed'
|
26
|
+
assert(/windows/.match?(obj.name))
|
27
|
+
assert(/\*.dll/.match?(obj.extension))
|
28
|
+
end
|
29
|
+
|
30
|
+
class NativeFolderTest < Minitest::Test
|
31
|
+
def test_windows_native_folder
|
32
|
+
obj = MacNativeFolder.new
|
33
|
+
assert_kind_of NativeFolder, obj, 'Constructor Failed'
|
34
|
+
assert(/macos/.match?(obj.name))
|
35
|
+
assert(/\*.dylib/.match?(obj.extension))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
if /linux/.match?(RbConfig::CONFIG['host_os'].downcase)
|
40
|
+
def test_native_folder
|
41
|
+
obj = NativeFolder.new
|
42
|
+
assert_instance_of NativeFolder, obj, 'Constructor Failed'
|
43
|
+
assert(/linux/.match?(obj.name))
|
44
|
+
assert(/\*.so/.match?(obj.extension))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|