propane 0.5.0-java → 0.6.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +3 -1
  4. data/README.md +1 -1
  5. data/Rakefile +1 -1
  6. data/examples/complete/bw_shader.rb +46 -0
  7. data/examples/complete/data/bwfrag.glsl +23 -0
  8. data/examples/complete/data/lachoy.jpg +0 -0
  9. data/examples/complete/data/landscape.glsl +352 -0
  10. data/examples/complete/data/monjori.glsl +30 -0
  11. data/examples/complete/data/moon.jpg +0 -0
  12. data/examples/complete/data/sea.jpg +0 -0
  13. data/examples/complete/edge_detection.rb +49 -0
  14. data/examples/complete/landscape.rb +32 -0
  15. data/examples/complete/linear_image.rb +51 -0
  16. data/examples/complete/monjori.rb +33 -0
  17. data/examples/regular/arcball_box.rb +3 -1
  18. data/examples/regular/arcball_constrain.rb +38 -0
  19. data/examples/regular/bezier_playground.rb +205 -0
  20. data/examples/regular/colors_two.rb +61 -0
  21. data/examples/regular/creating_colors.rb +10 -3
  22. data/examples/regular/elegant_ball.rb +1 -1
  23. data/examples/regular/fibonacci_sphere.rb +90 -0
  24. data/examples/regular/grapher.rb +39 -0
  25. data/examples/regular/gravity.rb +120 -0
  26. data/examples/regular/slider_demo.rb +60 -0
  27. data/examples/regular/slider_example.rb +53 -0
  28. data/examples/regular/slider_simple.rb +47 -0
  29. data/examples/regular/tree.rb +76 -0
  30. data/lib/propane/app.rb +1 -6
  31. data/lib/propane/helper_methods.rb +39 -10
  32. data/lib/propane/version.rb +1 -1
  33. data/library/slider/slider.rb +43 -0
  34. data/pom.rb +4 -4
  35. data/pom.xml +4 -4
  36. data/propane.gemspec +1 -1
  37. data/src/monkstone/ColorUtil.java +42 -9
  38. data/src/monkstone/slider/CustomHorizontalSlider.java +164 -0
  39. data/src/monkstone/slider/CustomVerticalSlider.java +178 -0
  40. data/src/monkstone/slider/SimpleHorizontalSlider.java +145 -0
  41. data/src/monkstone/slider/SimpleSlider.java +175 -0
  42. data/src/monkstone/slider/SimpleVerticalSlider.java +159 -0
  43. data/src/monkstone/slider/Slider.java +61 -0
  44. data/src/monkstone/slider/SliderBar.java +245 -0
  45. data/src/monkstone/slider/SliderGroup.java +56 -0
  46. data/src/monkstone/slider/WheelHandler.java +35 -0
  47. data/src/monkstone/vecmath/vec2/Vec2.java +3 -8
  48. data/src/monkstone/vecmath/vec3/Vec3.java +8 -13
  49. data/vendors/Rakefile +2 -2
  50. metadata +36 -6
  51. data/VERSION.txt +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ce0539eb503a2238662e89c13413096a9432e0d
4
- data.tar.gz: 72c8c27180b18e1160a5e4d1bb67f2230be092cd
3
+ metadata.gz: fc959038fd93430af113ed74e02ae78b8edcebc7
4
+ data.tar.gz: e0bd4194934a2c0ae4c57220a0f253ab29b14b9a
5
5
  SHA512:
6
- metadata.gz: d6ab0d0df27aa665df986025dc02f056a9a512c70fb31dc719a15b37715d5765f531d12487d9b631980bf4ea68715bd6d0c9d654fb4605b8136f2fa47b2fdf9b
7
- data.tar.gz: af7361a4fbd3427fed659086521529451117b20eaf83dafb209bb013459b2717c1a0822f30c19f96609e0489da9f8ca950424e4e1f34b644670e64a9653b4ea0
6
+ metadata.gz: a3ced8d05e48c9064445279d75eaf36f7ae29fcbbb667f1a68e22276f65673972580e341d06991d3fa0833e2bef7a722e47bb6900e7dfcdb8c8129c30171c3e1
7
+ data.tar.gz: 12b365acf34662ec7c526e86140ca684622fc47c8fba798b7658c7fcbc8f1df66013be766383f64cf5d3ac493777e16c9384226f7932777c81af7e434fe88063
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *.log
1
2
  *.gem
2
3
  *.rbc
3
4
  .bundle
data/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
 
2
- **v0.5.0** Includes a a sketch creator utility 3D still only for linux64 and macosx, any Windows developers are welcome to extend to windows (should be easy).
2
+ **v0.6.0** Includes a sketch creator utility 3D still only for linux64 and macosx, any Windows developers are welcome to extend to windows (should be easy), includes slider in sketch library, change to requiring jdk8. Update to JRuby-Complete-9.1.0.0, request updated arcball (to run samples).
3
+
4
+ **v0.5.0** Includes a sketch creator utility 3D still only for linux64 and macosx, any Windows developers are welcome to extend to windows (should be easy).
3
5
 
4
6
  **v0.4.0.pre** Inclusion of jogl-all.jar should fix 3D if install fails try getting rid of previous versions of gem (especially if you had done local installs, foxed me first) 3D still only for linux64 and macosx, any Windows developers are welcome to extend to windows (should be easy).
5
7
 
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  A slim layer to communicate with Processing from JRuby, features a polyglot maven build, this started out as a non serious project by Phillip Cunningam called ribiprocessing. It has now morphed into an experimental project for ruby-processing so we can now "Cook with Gas". We have created a configuration free version of ruby processing, albeit tied to processing-2.2.1, where we get processing core from maven central (and opengl currently testing on linux64/mac). These jars are small enough to include in the gem distribution, and hence we should not require configuration. This has created a mainly scriptable version, ie files get run direct from jruby. However (as with ruby-processing/JRubyArt) certain sketches need to call jruby via jruby-complete, for this we have created an executable `propane` that can also be used to install `jruby-complete` as well as run sketches (maybe export?, possibly watch).
5
5
  ## Requirements
6
6
 
7
- - jdk7+ possibly jdk8+ in near future
7
+ - jdk8+ since version 0.6.0
8
8
  - jruby-9.0.5.0+
9
9
  - mvn-3.3.1+ (development only)
10
10
 
data/Rakefile CHANGED
@@ -8,7 +8,7 @@ def create_manifest
8
8
  File.open('MANIFEST.MF', 'w') do |f|
9
9
  f.puts(title)
10
10
  f.puts(version)
11
- f.puts('Class-Path: core-2.2.1.jar, gluegen-rt-2.1.5-01.jar, jog-all-2.1.5-01.jar')
11
+ f.puts('Class-Path: core-2.2.1.jar gluegen-rt-2.1.5-01.jar jog-all-2.1.5-01.jar')
12
12
  end
13
13
  end
14
14
 
@@ -0,0 +1,46 @@
1
+ require 'propane'
2
+
3
+ class BwShader < Propane::App
4
+ # Texture from Jason Liebig's FLICKR collection of vintage labels and wrappers:
5
+ # http://www.flickr.com/photos/jasonliebigstuff/3739263136/in/photostream/
6
+
7
+ attr_reader :label, :can, :angle, :bw_shader
8
+
9
+ def setup
10
+ size(640, 360, P3D)
11
+ @label = load_image('lachoy.jpg')
12
+ @can = create_can(100, 200, 32, label)
13
+ @bw_shader = load_shader('bwfrag.glsl')
14
+ @angle = 0
15
+ end
16
+
17
+ def draw
18
+ background(0)
19
+ shader(bw_shader)
20
+ translate(width/2, height/2)
21
+ rotate_y(angle)
22
+ shape(can)
23
+ @angle += 0.01
24
+ end
25
+
26
+ def create_can(r, h, detail, tex)
27
+ texture_mode(NORMAL)
28
+ sh = create_shape
29
+ sh.begin_shape(QUAD_STRIP)
30
+ sh.no_stroke
31
+ sh.texture(tex)
32
+ (0..detail).each do |i|
33
+ angle = TAU / detail
34
+ x = sin(i * angle)
35
+ z = cos(i * angle)
36
+ u = i.to_f / detail
37
+ sh.normal(x, 0, z)
38
+ sh.vertex(x * r, -h/2, z * r, u, 0)
39
+ sh.vertex(x * r, +h/2, z * r, u, 1)
40
+ end
41
+ sh.end_shape
42
+ sh
43
+ end
44
+ end
45
+
46
+ BwShader.new title: 'Black & White Shader'
@@ -0,0 +1,23 @@
1
+ #ifdef GL_ES
2
+ precision mediump float;
3
+ precision mediump int;
4
+ #endif
5
+
6
+ #define PROCESSING_TEXTURE_SHADER
7
+
8
+ uniform sampler2D texture;
9
+
10
+ varying vec4 vertColor;
11
+ varying vec4 vertTexCoord;
12
+
13
+ const vec4 lumcoeff = vec4(0.299, 0.587, 0.114, 0);
14
+
15
+ void main() {
16
+ vec4 col = texture2D(texture, vertTexCoord.st);
17
+ float lum = dot(col, lumcoeff);
18
+ if (0.5 < lum) {
19
+ gl_FragColor = vertColor;
20
+ } else {
21
+ gl_FragColor = vec4(0, 0, 0, 1);
22
+ }
23
+ }
Binary file
@@ -0,0 +1,352 @@
1
+ // Elevated shader
2
+ // https://www.shadertoy.com/view/MdX3Rr by inigo quilez
3
+
4
+ // Created by inigo quilez - iq/2013
5
+ // License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
6
+
7
+ // Processing port by Raphaël de Courville.
8
+
9
+ #ifdef GL_ES
10
+ precision highp float;
11
+ #endif
12
+
13
+ // Type of shader expected by Processing
14
+ #define PROCESSING_COLOR_SHADER
15
+
16
+ // Processing specific input
17
+ uniform float time;
18
+ uniform vec2 resolution;
19
+ uniform vec2 mouse;
20
+
21
+ // Layer between Processing and Shadertoy uniforms
22
+ vec3 iResolution = vec3(resolution,0.0);
23
+ float iGlobalTime = time;
24
+ vec4 iMouse = vec4(mouse,0.0,0.0); // zw would normally be the click status
25
+
26
+ // ------- Below is the unmodified Shadertoy code ----------
27
+ // Created by inigo quilez - iq/2013
28
+ // License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
29
+
30
+ //stereo thanks to Croqueteer
31
+ //#define STEREO
32
+
33
+ mat3 m = mat3( 0.00, 0.80, 0.60,
34
+ -0.80, 0.36, -0.48,
35
+ -0.60, -0.48, 0.64 );
36
+
37
+ float hash( float n )
38
+ {
39
+ return fract(sin(n)*43758.5453123);
40
+ }
41
+
42
+
43
+ float noise( in vec3 x )
44
+ {
45
+ vec3 p = floor(x);
46
+ vec3 f = fract(x);
47
+
48
+ f = f*f*(3.0-2.0*f);
49
+
50
+ float n = p.x + p.y*57.0 + 113.0*p.z;
51
+
52
+ float res = mix(mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),
53
+ mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y),
54
+ mix(mix( hash(n+113.0), hash(n+114.0),f.x),
55
+ mix( hash(n+170.0), hash(n+171.0),f.x),f.y),f.z);
56
+ return res;
57
+ }
58
+
59
+
60
+
61
+
62
+ vec3 noised( in vec2 x )
63
+ {
64
+ vec2 p = floor(x);
65
+ vec2 f = fract(x);
66
+
67
+ vec2 u = f*f*(3.0-2.0*f);
68
+
69
+ float n = p.x + p.y*57.0;
70
+
71
+ float a = hash(n+ 0.0);
72
+ float b = hash(n+ 1.0);
73
+ float c = hash(n+ 57.0);
74
+ float d = hash(n+ 58.0);
75
+ return vec3(a+(b-a)*u.x+(c-a)*u.y+(a-b-c+d)*u.x*u.y,
76
+ 30.0*f*f*(f*(f-2.0)+1.0)*(vec2(b-a,c-a)+(a-b-c+d)*u.yx));
77
+
78
+ }
79
+
80
+ float noise( in vec2 x )
81
+ {
82
+ vec2 p = floor(x);
83
+ vec2 f = fract(x);
84
+
85
+ f = f*f*(3.0-2.0*f);
86
+
87
+ float n = p.x + p.y*57.0;
88
+
89
+ float res = mix(mix( hash(n+ 0.0), hash(n+ 1.0),f.x),
90
+ mix( hash(n+ 57.0), hash(n+ 58.0),f.x),f.y);
91
+
92
+ return res;
93
+ }
94
+
95
+ float fbm( vec3 p )
96
+ {
97
+ float f = 0.0;
98
+
99
+ f += 0.5000*noise( p ); p = m*p*2.02;
100
+ f += 0.2500*noise( p ); p = m*p*2.03;
101
+ f += 0.1250*noise( p ); p = m*p*2.01;
102
+ f += 0.0625*noise( p );
103
+
104
+ return f/0.9375;
105
+ }
106
+
107
+ mat2 m2 = mat2(1.6,-1.2,1.2,1.6);
108
+
109
+ float fbm( vec2 p )
110
+ {
111
+ float f = 0.0;
112
+
113
+ f += 0.5000*noise( p ); p = m2*p*2.02;
114
+ f += 0.2500*noise( p ); p = m2*p*2.03;
115
+ f += 0.1250*noise( p ); p = m2*p*2.01;
116
+ f += 0.0625*noise( p );
117
+
118
+ return f/0.9375;
119
+ }
120
+
121
+ float terrain( in vec2 x )
122
+ {
123
+ vec2 p = x*0.003;
124
+ float a = 0.0;
125
+ float b = 1.0;
126
+ vec2 d = vec2(0.0);
127
+ for(int i=0;i<5; i++)
128
+ {
129
+ vec3 n = noised(p);
130
+ d += n.yz;
131
+ a += b*n.x/(1.0+dot(d,d));
132
+ b *= 0.5;
133
+ p=mat2(1.6,-1.2,1.2,1.6)*p;
134
+ }
135
+
136
+ return 140.0*a;
137
+ }
138
+
139
+ float terrain2( in vec2 x )
140
+ {
141
+ vec2 p = x*0.003;
142
+ float a = 0.0;
143
+ float b = 1.0;
144
+ vec2 d = vec2(0.0);
145
+ for(int i=0;i<14; i++)
146
+ {
147
+ vec3 n = noised(p);
148
+ d += n.yz;
149
+ a += b*n.x/(1.0+dot(d,d));
150
+ b *= 0.5;
151
+ p=m2*p;
152
+ }
153
+
154
+ return 140.0*a;
155
+ }
156
+
157
+
158
+ float map( in vec3 p )
159
+ {
160
+ float h = terrain(p.xz);
161
+
162
+ float ss = 0.03;
163
+ float hh = h*ss;
164
+ float fh = fract(hh);
165
+ float ih = floor(hh);
166
+ fh = mix( sqrt(fh), fh, smoothstep(50.0,140.0,h) );
167
+ h = (ih+fh)/ss;
168
+
169
+ return p.y - h;
170
+ }
171
+
172
+ float map2( in vec3 p )
173
+ {
174
+ float h = terrain2(p.xz);
175
+
176
+
177
+ float ss = 0.03;
178
+ float hh = h*ss;
179
+ float fh = fract(hh);
180
+ float ih = floor(hh);
181
+ fh = mix( sqrt(fh), fh, smoothstep(50.0,140.0,h) );
182
+ h = (ih+fh)/ss;
183
+
184
+ return p.y - h;
185
+ }
186
+
187
+ bool jinteresct(in vec3 rO, in vec3 rD, out float resT )
188
+ {
189
+ float h = 0.0;
190
+ float t = 0.0;
191
+ for( int j=0; j<120; j++ )
192
+ {
193
+ //if( t>2000.0 ) break;
194
+
195
+ vec3 p = rO + t*rD;
196
+ if( p.y>300.0 ) break;
197
+ h = map( p );
198
+
199
+ if( h<0.1 )
200
+ {
201
+ resT = t;
202
+ return true;
203
+ }
204
+ t += max(0.1,0.5*h);
205
+
206
+ }
207
+
208
+ if( h<5.0 )
209
+ {
210
+ resT = t;
211
+ return true;
212
+ }
213
+ return false;
214
+ }
215
+
216
+ float sinteresct(in vec3 rO, in vec3 rD )
217
+ {
218
+ float res = 1.0;
219
+ float t = 0.0;
220
+ for( int j=0; j<50; j++ )
221
+ {
222
+ //if( t>1000.0 ) break;
223
+ vec3 p = rO + t*rD;
224
+
225
+ float h = map( p );
226
+
227
+ if( h<0.1 )
228
+ {
229
+ return 0.0;
230
+ }
231
+ res = min( res, 16.0*h/t );
232
+ t += h;
233
+
234
+ }
235
+
236
+ return clamp( res, 0.0, 1.0 );
237
+ }
238
+
239
+ vec3 calcNormal( in vec3 pos, float t )
240
+ {
241
+ float e = 0.001;
242
+ e = 0.001*t;
243
+ vec3 eps = vec3(e,0.0,0.0);
244
+ vec3 nor;
245
+ nor.x = map2(pos+eps.xyy) - map2(pos-eps.xyy);
246
+ nor.y = map2(pos+eps.yxy) - map2(pos-eps.yxy);
247
+ nor.z = map2(pos+eps.yyx) - map2(pos-eps.yyx);
248
+ return normalize(nor);
249
+ }
250
+
251
+ vec3 camPath( float time )
252
+ {
253
+ vec2 p = 600.0*vec2( cos(1.4+0.37*time),
254
+ cos(3.2+0.31*time) );
255
+
256
+ return vec3( p.x, 0.0, p.y );
257
+ }
258
+
259
+ void main(void)
260
+ {
261
+ vec2 xy = -1.0 + 2.0*gl_FragCoord.xy / iResolution.xy;
262
+
263
+ vec2 s = xy*vec2(1.75,1.0);
264
+
265
+ #ifdef STEREO
266
+ float isCyan = mod(gl_FragCoord.x + mod(gl_FragCoord.y,2.0),2.0);
267
+ #endif
268
+
269
+ float time = iGlobalTime*.15;
270
+
271
+ vec3 light1 = normalize( vec3( 0.4, 0.22, 0.6 ) );
272
+ vec3 light2 = vec3( -0.707, 0.000, -0.707 );
273
+
274
+
275
+ vec3 campos = camPath( time );
276
+ vec3 camtar = camPath( time + 3.0 );
277
+ campos.y = terrain( campos.xz ) + 15.0;
278
+ camtar.y = campos.y*0.5;
279
+
280
+ float roll = 0.1*cos(0.1*time);
281
+ vec3 cw = normalize(camtar-campos);
282
+ vec3 cp = vec3(sin(roll), cos(roll),0.0);
283
+ vec3 cu = normalize(cross(cw,cp));
284
+ vec3 cv = normalize(cross(cu,cw));
285
+ vec3 rd = normalize( s.x*cu + s.y*cv + 1.6*cw );
286
+
287
+ #ifdef STEREO
288
+ campos += 2.0*cu*isCyan; // move camera to the right - the rd vector is still good
289
+ #endif
290
+
291
+ float sundot = clamp(dot(rd,light1),0.0,1.0);
292
+ vec3 col;
293
+ float t;
294
+ if( !jinteresct(campos,rd,t) )
295
+ {
296
+ col = 0.9*vec3(0.97,.99,1.0)*(1.0-0.3*rd.y);
297
+ col += 0.2*vec3(0.8,0.7,0.5)*pow( sundot, 4.0 );
298
+ }
299
+ else
300
+ {
301
+ vec3 pos = campos + t*rd;
302
+
303
+ vec3 nor = calcNormal( pos, t );
304
+
305
+ float dif1 = clamp( dot( light1, nor ), 0.0, 1.0 );
306
+ float dif2 = clamp( 0.2 + 0.8*dot( light2, nor ), 0.0, 1.0 );
307
+ float sh = 1.0;
308
+ if( dif1>0.001 )
309
+ sh = sinteresct(pos+light1*20.0,light1);
310
+
311
+ vec3 dif1v = vec3(dif1);
312
+ dif1v *= vec3( sh, sh*sh*0.5+0.5*sh, sh*sh );
313
+
314
+ float r = noise( 7.0*pos.xz );
315
+
316
+ col = (r*0.25+0.75)*0.9*mix( vec3(0.10,0.05,0.03), vec3(0.13,0.10,0.08), clamp(terrain2( vec2(pos.x,pos.y*48.0))/200.0,0.0,1.0) );
317
+ col = mix( col, 0.17*vec3(0.5,.23,0.04)*(0.50+0.50*r),smoothstep(0.70,0.9,nor.y) );
318
+ col = mix( col, 0.10*vec3(0.2,.30,0.00)*(0.25+0.75*r),smoothstep(0.95,1.0,nor.y) );
319
+ col *= 0.75;
320
+ // snow
321
+ #if 1
322
+ float h = smoothstep(55.0,80.0,pos.y + 25.0*fbm(0.01*pos.xz) );
323
+ float e = smoothstep(1.0-0.5*h,1.0-0.1*h,nor.y);
324
+ float o = 0.3 + 0.7*smoothstep(0.0,0.1,nor.x+h*h);
325
+ float s = h*e*o;
326
+ s = smoothstep( 0.1, 0.9, s );
327
+ col = mix( col, 0.4*vec3(0.6,0.65,0.7), s );
328
+ #endif
329
+
330
+
331
+ vec3 brdf = 2.0*vec3(0.17,0.19,0.20)*clamp(nor.y,0.0,1.0);
332
+ brdf += 6.0*vec3(1.00,0.95,0.80)*dif1v;
333
+ brdf += 2.0*vec3(0.20,0.20,0.20)*dif2;
334
+
335
+ col *= brdf;
336
+
337
+ float fo = 1.0-exp(-pow(0.0015*t,1.5));
338
+ vec3 fco = vec3(0.7) + 0.6*vec3(0.8,0.7,0.5)*pow( sundot, 4.0 );
339
+ col = mix( col, fco, fo );
340
+ }
341
+
342
+ col = sqrt(col);
343
+
344
+ vec2 uv = xy*0.5+0.5;
345
+ col *= 0.7 + 0.3*pow(16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y),0.1);
346
+
347
+ #ifdef STEREO
348
+ col *= vec3( isCyan, 1.0-isCyan, 1.0-isCyan );
349
+ #endif
350
+
351
+ gl_FragColor=vec4(col,1.0);
352
+ }