propane 0.7.0-java → 0.8.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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -3
- data/CHANGELOG.md +2 -0
- data/README.md +3 -5
- data/examples/{complete → data_path}/Rakefile +2 -2
- data/examples/{complete → data_path}/bw_shader.rb +7 -6
- data/examples/{complete → data_path}/data/Texture01.jpg +0 -0
- data/examples/{complete → data_path}/data/Texture02.jpg +0 -0
- data/examples/{complete → data_path}/data/Univers45.vlw +0 -0
- data/examples/{complete → data_path}/data/bwfrag.glsl +0 -0
- data/examples/{complete → data_path}/data/displaceFrag.glsl +0 -0
- data/examples/{complete → data_path}/data/displaceVert.glsl +0 -0
- data/examples/{complete → data_path}/data/lachoy.jpg +0 -0
- data/examples/{complete → data_path}/data/landscape.glsl +0 -0
- data/examples/{complete → data_path}/data/monjori.glsl +0 -0
- data/examples/{complete → data_path}/data/moon.jpg +0 -0
- data/examples/{complete → data_path}/data/sea.jpg +0 -0
- data/examples/{complete → data_path}/edge_detection.rb +2 -2
- data/examples/{complete → data_path}/glsl_heightmap_noise.rb +9 -5
- data/examples/{complete → data_path}/kinetic_type.rb +5 -5
- data/examples/{complete → data_path}/landscape.rb +11 -9
- data/examples/{complete → data_path}/linear_image.rb +2 -2
- data/examples/{complete → data_path}/monjori.rb +7 -5
- data/examples/regular/arcball_box.rb +3 -13
- data/examples/regular/arcball_constrain.rb +12 -21
- data/examples/regular/bezier_playground.rb +32 -31
- data/examples/regular/circle_collision.rb +9 -9
- data/examples/regular/colors_two.rb +2 -1
- data/examples/regular/creating_colors.rb +2 -2
- data/examples/regular/drawolver.rb +1 -0
- data/examples/regular/elegant_ball.rb +1 -1
- data/examples/regular/empathy.rb +11 -10
- data/examples/regular/fern.rb +1 -0
- data/examples/regular/fibonacci_sphere.rb +1 -0
- data/examples/regular/flight_patterns.rb +6 -5
- data/examples/regular/fractions.rb +1 -0
- data/examples/regular/grapher.rb +6 -5
- data/examples/regular/gravity.rb +17 -17
- data/examples/regular/grey_circles.rb +2 -2
- data/examples/regular/jwishy.rb +5 -6
- data/examples/regular/letters.rb +19 -19
- data/examples/regular/liquidy.rb +5 -4
- data/examples/regular/mouse_button_demo.rb +5 -7
- data/examples/regular/polyhedrons.rb +1 -0
- data/examples/regular/raining.rb +6 -5
- data/examples/regular/ribbon_doodle.rb +1 -1
- data/examples/regular/select_file.rb +32 -0
- data/examples/regular/select_image.rb +40 -0
- data/examples/regular/slider_demo.rb +2 -1
- data/examples/regular/slider_example.rb +1 -1
- data/examples/regular/slider_simple.rb +1 -1
- data/examples/regular/tree.rb +7 -6
- data/lib/propane/creators/sketch_writer.rb +66 -0
- data/lib/propane/library_loader.rb +1 -5
- data/lib/propane/runner.rb +4 -3
- data/lib/propane/version.rb +1 -1
- data/library/file_chooser/chooser.rb +20 -0
- data/library/file_chooser/file_chooser.rb +20 -0
- data/pom.rb +1 -1
- data/pom.xml +1 -1
- data/propane.gemspec +1 -1
- data/src/monkstone/MathToolModule.java +63 -47
- data/src/monkstone/filechooser/Chooser.java +44 -0
- data/test/create_test.rb +48 -0
- metadata +30 -23
- data/lib/propane/creators/creator.rb +0 -136
data/propane.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.name = 'propane'
|
8
8
|
gem.version = Propane::VERSION
|
9
9
|
gem.authors = ['filib', 'monkstone']
|
10
|
-
gem.email = ['
|
10
|
+
gem.email = ['mamba2928@yahoo.co.uk']
|
11
11
|
gem.license = 'MIT'
|
12
12
|
gem.description = %q{A Standalone Ruby Processing implementation}
|
13
13
|
gem.summary = %q{A really slim layer between Ruby and Processing-2.2.1.}
|
@@ -11,6 +11,7 @@
|
|
11
11
|
package monkstone;
|
12
12
|
|
13
13
|
import org.jruby.Ruby;
|
14
|
+
import org.jruby.RubyFixnum;
|
14
15
|
import org.jruby.RubyFloat;
|
15
16
|
import org.jruby.RubyModule;
|
16
17
|
import org.jruby.RubyRange;
|
@@ -23,14 +24,13 @@ import org.jruby.runtime.builtin.IRubyObject;
|
|
23
24
|
*
|
24
25
|
* @author Martin Prout
|
25
26
|
*/
|
26
|
-
@JRubyModule(name = "MathTool")
|
27
|
-
public class MathToolModule {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
@JRubyModule(name = "MathTool")
|
28
|
+
public class MathToolModule {
|
29
|
+
|
30
|
+
/**
|
31
|
+
*
|
32
|
+
* @param runtime Ruby
|
33
|
+
*/
|
34
34
|
public static void createMathToolModule(Ruby runtime) {
|
35
35
|
RubyModule mtModule = runtime.defineModule("MathTool");
|
36
36
|
mtModule.defineAnnotatedMethods(MathToolModule.class);
|
@@ -39,38 +39,47 @@ public class MathToolModule {
|
|
39
39
|
/**
|
40
40
|
*
|
41
41
|
* @param context ThreadContext
|
42
|
-
* @param recv IRubyObject
|
42
|
+
* @param recv IRubyObject
|
43
43
|
* @param args array of RubyRange (must be be numeric)
|
44
44
|
* @return mapped value RubyFloat
|
45
45
|
*/
|
46
46
|
@JRubyMethod(name = "map1d", rest = true, module = true)
|
47
47
|
public static IRubyObject mapOneD(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
|
48
|
-
double value = (
|
48
|
+
double value = (args[0] instanceof RubyFloat)
|
49
|
+
? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
49
50
|
RubyRange r1 = (RubyRange) args[1];
|
50
51
|
RubyRange r2 = (RubyRange) args[2];
|
51
|
-
double first1 = (
|
52
|
-
|
53
|
-
double
|
54
|
-
|
52
|
+
double first1 = (r1.first(context) instanceof RubyFloat)
|
53
|
+
? ((RubyFloat) r1.first(context)).getValue() : ((RubyFixnum) r1.first(context)).getDoubleValue();
|
54
|
+
double first2 = (r2.first(context) instanceof RubyFloat)
|
55
|
+
? ((RubyFloat) r2.first(context)).getValue() : ((RubyFixnum) r2.first(context)).getDoubleValue();
|
56
|
+
double last1 = (r1.last(context) instanceof RubyFloat)
|
57
|
+
? ((RubyFloat) r1.last(context)).getValue() : ((RubyFixnum) r1.last(context)).getDoubleValue();
|
58
|
+
double last2 = (r2.last(context) instanceof RubyFloat)
|
59
|
+
? ((RubyFloat) r2.last(context)).getValue() : ((RubyFixnum) r2.last(context)).getDoubleValue();
|
55
60
|
return mapMt(context, value, first1, last1, first2, last2);
|
56
61
|
}
|
57
62
|
|
58
63
|
/**
|
59
64
|
*
|
60
65
|
* @param context ThreadContext
|
61
|
-
* @param recv IRubyObject
|
66
|
+
* @param recv IRubyObject
|
62
67
|
* @param args array of RubyRange (must be be numeric)
|
63
68
|
* @return mapped value RubyFloat
|
64
69
|
*/
|
65
70
|
@JRubyMethod(name = "constrained_map", rest = true, module = true)
|
66
71
|
public static IRubyObject constrainedMap(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
|
67
|
-
double value = (
|
72
|
+
double value = (args[0] instanceof RubyFloat) ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
68
73
|
RubyRange r1 = (RubyRange) args[1];
|
69
74
|
RubyRange r2 = (RubyRange) args[2];
|
70
|
-
double first1 = (
|
71
|
-
|
72
|
-
double
|
73
|
-
|
75
|
+
double first1 = (r1.first(context) instanceof RubyFloat)
|
76
|
+
? ((RubyFloat) r1.first(context)).getValue() : ((RubyFixnum) r1.first(context)).getDoubleValue();
|
77
|
+
double first2 = (r2.first(context) instanceof RubyFloat)
|
78
|
+
? ((RubyFloat) r2.first(context)).getValue() : ((RubyFixnum) r2.first(context)).getDoubleValue();
|
79
|
+
double last1 = (r1.last(context) instanceof RubyFloat)
|
80
|
+
? ((RubyFloat) r1.last(context)).getValue() : ((RubyFixnum) r1.last(context)).getDoubleValue();
|
81
|
+
double last2 = (r2.last(context) instanceof RubyFloat)
|
82
|
+
? ((RubyFloat) r2.last(context)).getValue() : ((RubyFixnum) r2.last(context)).getDoubleValue();
|
74
83
|
double max = Math.max(first1, last1);
|
75
84
|
double min = Math.min(first1, last1);
|
76
85
|
if (value < min) {
|
@@ -79,7 +88,7 @@ public class MathToolModule {
|
|
79
88
|
if (value > max) {
|
80
89
|
value = max;
|
81
90
|
}
|
82
|
-
|
91
|
+
return mapMt(context, value, first1, last1, first2, last2);
|
83
92
|
}
|
84
93
|
|
85
94
|
/**
|
@@ -91,37 +100,42 @@ public class MathToolModule {
|
|
91
100
|
*/
|
92
101
|
@JRubyMethod(name = "p5map", rest = true, module = true)
|
93
102
|
public static IRubyObject mapProcessing(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
|
94
|
-
double value = (
|
95
|
-
double first1 = (
|
96
|
-
double first2 = (
|
97
|
-
double last1 = (
|
98
|
-
double last2 = (
|
103
|
+
double value = (args[0] instanceof RubyFloat) ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
104
|
+
double first1 = (args[1] instanceof RubyFloat) ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
105
|
+
double first2 = (args[3] instanceof RubyFloat) ? ((RubyFloat) args[3]).getValue() : ((RubyFixnum) args[3]).getDoubleValue();
|
106
|
+
double last1 = (args[2] instanceof RubyFloat) ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
|
107
|
+
double last2 = (args[4] instanceof RubyFloat) ? ((RubyFloat) args[4]).getValue() : ((RubyFixnum) args[4]).getDoubleValue();
|
99
108
|
return mapMt(context, value, first1, last1, first2, last2);
|
100
109
|
}
|
101
110
|
|
102
|
-
|
103
111
|
/**
|
104
112
|
* A more correct version than processing.org version
|
113
|
+
*
|
105
114
|
* @param context ThreadContext
|
106
115
|
* @param recv self IRubyObject
|
107
|
-
* @param args args[2] should be between 0 and 1.0 if not returns start or
|
116
|
+
* @param args args[2] should be between 0 and 1.0 if not returns start or
|
117
|
+
* stop
|
108
118
|
* @return lerped value RubyFloat
|
109
119
|
*/
|
110
120
|
@JRubyMethod(name = "lerp", rest = true, module = true)
|
111
121
|
public static IRubyObject lerpP(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
|
112
|
-
double start = (
|
113
|
-
double stop = (
|
114
|
-
double amount = (
|
115
|
-
if (amount <= 0)
|
116
|
-
|
117
|
-
|
122
|
+
double start = (args[0] instanceof RubyFloat) ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
123
|
+
double stop = (args[1] instanceof RubyFloat) ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
124
|
+
double amount = (args[2] instanceof RubyFloat) ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
|
125
|
+
if (amount <= 0) {
|
126
|
+
return args[0];
|
127
|
+
}
|
128
|
+
if (amount >= 1.0) {
|
129
|
+
return args[1];
|
130
|
+
}
|
131
|
+
return context.runtime.newFloat((1 - amount) * start + (stop * amount));
|
118
132
|
}
|
119
133
|
|
120
|
-
|
121
134
|
/**
|
122
|
-
* Identical to p5map(value, low, high, 0, 1).
|
123
|
-
*
|
124
|
-
*
|
135
|
+
* Identical to p5map(value, low, high, 0, 1). Numbers outside of the range
|
136
|
+
* are not clamped to 0 and 1, because out-of-range values are often
|
137
|
+
* intentional and useful.
|
138
|
+
*
|
125
139
|
* @param context ThreadContext
|
126
140
|
* @param recv IRubyObject
|
127
141
|
* @param args array of args must be be numeric
|
@@ -129,15 +143,16 @@ public class MathToolModule {
|
|
129
143
|
*/
|
130
144
|
@JRubyMethod(name = "norm", rest = true, module = true)
|
131
145
|
public static IRubyObject normP(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
|
132
|
-
double value = (
|
133
|
-
double start = (
|
134
|
-
double stop = (
|
146
|
+
double value = (args[0] instanceof RubyFloat) ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
147
|
+
double start = (args[1] instanceof RubyFloat) ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
148
|
+
double stop = (args[2] instanceof RubyFloat) ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
|
135
149
|
return mapMt(context, value, start, stop, 0, 1.0);
|
136
150
|
}
|
137
151
|
|
138
152
|
/**
|
139
|
-
* Identical to p5map(value, low, high, 0, 1) but 'clamped'.
|
140
|
-
*
|
153
|
+
* Identical to p5map(value, low, high, 0, 1) but 'clamped'. Numbers outside
|
154
|
+
* of the range are clamped to 0 and 1,
|
155
|
+
*
|
141
156
|
* @param context ThreadContext
|
142
157
|
* @param recv IRubyObject
|
143
158
|
* @param args array of args must be be numeric
|
@@ -146,9 +161,9 @@ public class MathToolModule {
|
|
146
161
|
@JRubyMethod(name = "norm_strict", rest = true, module = true)
|
147
162
|
public static IRubyObject norm_strict(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
|
148
163
|
Ruby ruby = context.runtime;
|
149
|
-
double value = (
|
150
|
-
double start = (
|
151
|
-
double stop = (
|
164
|
+
double value = (args[0] instanceof RubyFloat) ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
|
165
|
+
double start = (args[1] instanceof RubyFloat) ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
|
166
|
+
double stop = (args[2] instanceof RubyFloat) ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
|
152
167
|
if (value <= start) {
|
153
168
|
return new RubyFloat(ruby, 0);
|
154
169
|
} else if (value >= stop) {
|
@@ -160,11 +175,12 @@ public class MathToolModule {
|
|
160
175
|
|
161
176
|
static final RubyFloat mapMt(ThreadContext context, double value, double first1, double last1, double first2, double last2) {
|
162
177
|
double result = first2 + (last2 - first2) * ((value - first1) / (last1 - first1));
|
163
|
-
return context.
|
178
|
+
return context.runtime.newFloat(result);
|
164
179
|
}
|
165
180
|
|
166
181
|
/**
|
167
182
|
* Provides processing constrain method as a ruby module method
|
183
|
+
*
|
168
184
|
* @param context ThreadContext
|
169
185
|
* @param recv IRubyObject
|
170
186
|
* @param args array of args must be be numeric
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 2016 Martin Prout
|
3
|
+
*
|
4
|
+
* This library is free software; you can redistribute it and/or
|
5
|
+
* modify it under the terms of the GNU Lesser General Public
|
6
|
+
* License as published by the Free Software Foundation; either
|
7
|
+
* version 2.1 of the License, or (at your option) any later version.
|
8
|
+
*
|
9
|
+
* http://creativecommons.org/licenses/LGPL/2.1/
|
10
|
+
*
|
11
|
+
* This library is distributed in the hope that it will be useful,
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14
|
+
* Lesser General Public License for more details.
|
15
|
+
*
|
16
|
+
* You should have received a copy of the GNU Lesser General Public
|
17
|
+
* License along with this library; if not, write to the Free Software
|
18
|
+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
|
+
*/
|
20
|
+
package monkstone.filechooser;
|
21
|
+
|
22
|
+
import java.io.File;
|
23
|
+
|
24
|
+
/**
|
25
|
+
* This interface makes it easier/possible to use the reflection methods
|
26
|
+
* selectInput
|
27
|
+
* def setup
|
28
|
+
* java_signature 'void selectInput(String, String)'
|
29
|
+
* selectInput('Select a file to process:', 'fileSelected')
|
30
|
+
* end
|
31
|
+
*
|
32
|
+
* def file_selected(selection)
|
33
|
+
* if selection.nil?
|
34
|
+
* puts 'Window was closed or the user hit cancel.'
|
35
|
+
* else
|
36
|
+
* puts format('User selected %s', selection.get_absolute_path)
|
37
|
+
* end
|
38
|
+
* end
|
39
|
+
* @author Martin Prout
|
40
|
+
*/
|
41
|
+
public interface Chooser {
|
42
|
+
|
43
|
+
public void file_selected(File selection);
|
44
|
+
}
|
data/test/create_test.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
gem 'minitest' # don't use bundled minitest
|
2
|
+
require 'minitest/autorun'
|
3
|
+
require 'minitest/pride'
|
4
|
+
|
5
|
+
|
6
|
+
require_relative '../lib/propane/creators/sketch_writer'
|
7
|
+
|
8
|
+
CLASS_SKETCH = <<~CODE
|
9
|
+
# frozen_string_literal: false
|
10
|
+
require 'propane'
|
11
|
+
|
12
|
+
class FredSketch < Propane::App
|
13
|
+
def setup
|
14
|
+
size 200, 200, P2D
|
15
|
+
end
|
16
|
+
|
17
|
+
def draw
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
CODE
|
23
|
+
|
24
|
+
class SketchWriterTest < Minitest::Test
|
25
|
+
ParamMethods = Struct.new(:name, :class_name, :sketch_size)
|
26
|
+
|
27
|
+
def setup
|
28
|
+
@param = ParamMethods.new(
|
29
|
+
'fred_sketch',
|
30
|
+
'FredSketch',
|
31
|
+
'size 200, 200, P2D'
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_parameter_new
|
36
|
+
param = SketchParameters.new(name: 'fred_sketch', args: %w(200 200 p2d))
|
37
|
+
assert_equal 'size 200, 200, P2D', param.sketch_size
|
38
|
+
assert_equal 'FredSketch', param.class_name
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_class
|
42
|
+
result = CLASS_SKETCH.split(/\n/, -1)
|
43
|
+
class_lines = ClassSketch.new.code(@param)
|
44
|
+
class_lines.each_with_index do |line, i|
|
45
|
+
assert_equal result[i], line
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: propane
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- filib
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-08-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: arcball
|
@@ -27,7 +27,7 @@ dependencies:
|
|
27
27
|
version: 0.0.3
|
28
28
|
description: A Standalone Ruby Processing implementation
|
29
29
|
email:
|
30
|
-
-
|
30
|
+
- mamba2928@yahoo.co.uk
|
31
31
|
executables:
|
32
32
|
- propane
|
33
33
|
extensions: []
|
@@ -45,25 +45,25 @@ files:
|
|
45
45
|
- README.md
|
46
46
|
- Rakefile
|
47
47
|
- bin/propane
|
48
|
-
- examples/
|
49
|
-
- examples/
|
50
|
-
- examples/
|
51
|
-
- examples/
|
52
|
-
- examples/
|
53
|
-
- examples/
|
54
|
-
- examples/
|
55
|
-
- examples/
|
56
|
-
- examples/
|
57
|
-
- examples/
|
58
|
-
- examples/
|
59
|
-
- examples/
|
60
|
-
- examples/
|
61
|
-
- examples/
|
62
|
-
- examples/
|
63
|
-
- examples/
|
64
|
-
- examples/
|
65
|
-
- examples/
|
66
|
-
- examples/
|
48
|
+
- examples/data_path/Rakefile
|
49
|
+
- examples/data_path/bw_shader.rb
|
50
|
+
- examples/data_path/data/Texture01.jpg
|
51
|
+
- examples/data_path/data/Texture02.jpg
|
52
|
+
- examples/data_path/data/Univers45.vlw
|
53
|
+
- examples/data_path/data/bwfrag.glsl
|
54
|
+
- examples/data_path/data/displaceFrag.glsl
|
55
|
+
- examples/data_path/data/displaceVert.glsl
|
56
|
+
- examples/data_path/data/lachoy.jpg
|
57
|
+
- examples/data_path/data/landscape.glsl
|
58
|
+
- examples/data_path/data/monjori.glsl
|
59
|
+
- examples/data_path/data/moon.jpg
|
60
|
+
- examples/data_path/data/sea.jpg
|
61
|
+
- examples/data_path/edge_detection.rb
|
62
|
+
- examples/data_path/glsl_heightmap_noise.rb
|
63
|
+
- examples/data_path/kinetic_type.rb
|
64
|
+
- examples/data_path/landscape.rb
|
65
|
+
- examples/data_path/linear_image.rb
|
66
|
+
- examples/data_path/monjori.rb
|
67
67
|
- examples/regular/Rakefile
|
68
68
|
- examples/regular/arcball_box.rb
|
69
69
|
- examples/regular/arcball_constrain.rb
|
@@ -92,6 +92,8 @@ files:
|
|
92
92
|
- examples/regular/polyhedrons.rb
|
93
93
|
- examples/regular/raining.rb
|
94
94
|
- examples/regular/ribbon_doodle.rb
|
95
|
+
- examples/regular/select_file.rb
|
96
|
+
- examples/regular/select_image.rb
|
95
97
|
- examples/regular/slider_demo.rb
|
96
98
|
- examples/regular/slider_example.rb
|
97
99
|
- examples/regular/slider_simple.rb
|
@@ -110,7 +112,7 @@ files:
|
|
110
112
|
- lib/propane.jar
|
111
113
|
- lib/propane.rb
|
112
114
|
- lib/propane/app.rb
|
113
|
-
- lib/propane/creators/
|
115
|
+
- lib/propane/creators/sketch_writer.rb
|
114
116
|
- lib/propane/helper_methods.rb
|
115
117
|
- lib/propane/helpers/numeric.rb
|
116
118
|
- lib/propane/helpers/string_extra.rb
|
@@ -120,6 +122,8 @@ files:
|
|
120
122
|
- lib/propane/version.rb
|
121
123
|
- library/boids/boids.rb
|
122
124
|
- library/control_panel/control_panel.rb
|
125
|
+
- library/file_chooser/chooser.rb
|
126
|
+
- library/file_chooser/file_chooser.rb
|
123
127
|
- library/slider/slider.rb
|
124
128
|
- pom.rb
|
125
129
|
- pom.xml
|
@@ -132,6 +136,7 @@ files:
|
|
132
136
|
- src/monkstone/core/AbstractLibrary.java
|
133
137
|
- src/monkstone/fastmath/Deglut.java
|
134
138
|
- src/monkstone/fastmath/package-info.java
|
139
|
+
- src/monkstone/filechooser/Chooser.java
|
135
140
|
- src/monkstone/slider/CustomHorizontalSlider.java
|
136
141
|
- src/monkstone/slider/CustomVerticalSlider.java
|
137
142
|
- src/monkstone/slider/SimpleHorizontalSlider.java
|
@@ -149,6 +154,7 @@ files:
|
|
149
154
|
- src/monkstone/vecmath/vec2/package-info.java
|
150
155
|
- src/monkstone/vecmath/vec3/Vec3.java
|
151
156
|
- src/monkstone/vecmath/vec3/package-info.java
|
157
|
+
- test/create_test.rb
|
152
158
|
- test/respond_to_test.rb
|
153
159
|
- vendors/Rakefile
|
154
160
|
homepage: https://github.com/monkstone/propane
|
@@ -176,4 +182,5 @@ signing_key:
|
|
176
182
|
specification_version: 4
|
177
183
|
summary: A really slim layer between Ruby and Processing-2.2.1.
|
178
184
|
test_files:
|
185
|
+
- test/create_test.rb
|
179
186
|
- test/respond_to_test.rb
|
@@ -1,136 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# frozen_string_literal: false
|
3
|
-
|
4
|
-
BASIC = <<-CODE
|
5
|
-
# encoding: utf-8
|
6
|
-
# frozen_string_literal: false
|
7
|
-
require 'propane'
|
8
|
-
|
9
|
-
class %s < Propane::App
|
10
|
-
def setup
|
11
|
-
size %s, %s
|
12
|
-
end
|
13
|
-
|
14
|
-
def draw
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
%s.new title: '%s'
|
20
|
-
CODE
|
21
|
-
|
22
|
-
MODE = <<-CODE
|
23
|
-
# encoding: utf-8
|
24
|
-
# frozen_string_literal: false
|
25
|
-
require 'propane'
|
26
|
-
|
27
|
-
class %s < Propane::App
|
28
|
-
def setup
|
29
|
-
size %s, %s, %s
|
30
|
-
end
|
31
|
-
|
32
|
-
def draw
|
33
|
-
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
%s.new title: '%s'
|
38
|
-
CODE
|
39
|
-
|
40
|
-
INNER = <<-CODE
|
41
|
-
# encoding: utf-8
|
42
|
-
# frozen_string_literal: false
|
43
|
-
class %s
|
44
|
-
include Propane::Proxy
|
45
|
-
|
46
|
-
end
|
47
|
-
CODE
|
48
|
-
|
49
|
-
# processing wrapper module
|
50
|
-
module Propane
|
51
|
-
require_relative '../helpers/string_extra'
|
52
|
-
# Write file to disk
|
53
|
-
class SketchWriter
|
54
|
-
attr_reader :file
|
55
|
-
def initialize(path)
|
56
|
-
underscore = StringExtra.new(path).underscore
|
57
|
-
@file = "#{File.dirname(path)}/#{underscore}.rb"
|
58
|
-
end
|
59
|
-
|
60
|
-
def save(template)
|
61
|
-
File.open(file, 'w+') do |f|
|
62
|
-
f.write(template)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
# An abstract class providing common methods for real creators
|
68
|
-
class Creator
|
69
|
-
ALL_DIGITS = /\A\d+\Z/
|
70
|
-
|
71
|
-
def already_exist(path)
|
72
|
-
underscore = StringExtra.new(path).underscore
|
73
|
-
new_file = "#{File.dirname(path)}/#{underscore}.rb"
|
74
|
-
return if !FileTest.exist?(path) && !FileTest.exist?(new_file)
|
75
|
-
puts 'That file already exists!'
|
76
|
-
exit
|
77
|
-
end
|
78
|
-
|
79
|
-
# Show the help/usage message for create.
|
80
|
-
def usage
|
81
|
-
puts <<-USAGE
|
82
|
-
|
83
|
-
Usage: propane --create <sketch_to_generate> <width> <height> <mode>
|
84
|
-
optional mode can be P2D / P3D.
|
85
|
-
Use --inner to generated a ruby version of 'java' Inner class
|
86
|
-
Examples: propane --create app 800 600
|
87
|
-
propane --create app 800 600 p3d
|
88
|
-
propane --create inner_class --inner
|
89
|
-
|
90
|
-
USAGE
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# This class creates bare sketches, with an optional render mode
|
95
|
-
class BasicSketch < Creator
|
96
|
-
def template_default
|
97
|
-
format(BASIC, @name, @width, @height, @name, @title)
|
98
|
-
end
|
99
|
-
|
100
|
-
def template_mode
|
101
|
-
format(MODE, @name, @width, @height, @mode, @name, @title)
|
102
|
-
end
|
103
|
-
# Create a class wrapped sketch, given a path.
|
104
|
-
def create!(path, args)
|
105
|
-
return usage if /\?/ =~ path || /--help/ =~ path
|
106
|
-
main_file = File.basename(path, '.rb') # allow uneeded extension input
|
107
|
-
# Check to make sure that the main file doesn't exist already
|
108
|
-
already_exist(path)
|
109
|
-
@name = StringExtra.new(main_file).camelize
|
110
|
-
writer = SketchWriter.new(main_file)
|
111
|
-
@title = StringExtra.new(main_file).titleize
|
112
|
-
@width, @height = args[0], args[1]
|
113
|
-
@mode = args[2].upcase unless args[2].nil?
|
114
|
-
template = @mode.nil? ? template_default : template_mode
|
115
|
-
writer.save(template)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
# This class creates a pseudo 'java inner class' of the sketch
|
120
|
-
class Inner < Creator
|
121
|
-
def inner_class_template
|
122
|
-
format(INNER, @name)
|
123
|
-
end
|
124
|
-
# Create a pseudo inner class, given a path.
|
125
|
-
def create!(path, _args_)
|
126
|
-
return usage if /\?/ =~ path || /--help/ =~ path
|
127
|
-
main_file = File.basename(path, '.rb') # allow uneeded extension input
|
128
|
-
# Check to make sure that the main file doesn't exist already
|
129
|
-
already_exist(path)
|
130
|
-
@name = main_file.camelize
|
131
|
-
writer = SketchWriter.new(main_file)
|
132
|
-
template = inner_class_template
|
133
|
-
writer.save(template)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|