propane 0.7.0-java → 0.8.0-java
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,15 +1,15 @@
|
|
1
|
+
#!/usr/bin/env jruby -v -w
|
1
2
|
require 'propane'
|
2
3
|
|
3
|
-
|
4
4
|
# Based on http://processing.org/learning/topics/circlecollision.html
|
5
|
-
class CircleCollision < Propane::App
|
5
|
+
class CircleCollision < Propane::App
|
6
6
|
attr_reader :balls
|
7
|
-
|
7
|
+
|
8
8
|
def setup
|
9
9
|
size 640, 360
|
10
10
|
@balls = [Ball.new(100, 40, 20), Ball.new(200, 100, 80)]
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def draw
|
14
14
|
background(51)
|
15
15
|
balls.each do |b|
|
@@ -25,18 +25,18 @@ end
|
|
25
25
|
class Ball
|
26
26
|
include Propane::Proxy, Math
|
27
27
|
attr_accessor :position, :r, :m, :velocity
|
28
|
-
|
28
|
+
|
29
29
|
def initialize(x = 0.0, y = 0.0, r = 0.0)
|
30
30
|
@position = Vec2D.new(x, y)
|
31
31
|
@r = r
|
32
32
|
@m = r * 0.1
|
33
33
|
@velocity = Vec2D.new(rand(-3.0..3), rand(-3.0..3))
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
def update
|
37
37
|
@position += velocity
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
def check_boundary(width, height)
|
41
41
|
unless (r..width - r).include?(position.x)
|
42
42
|
(position.x > width - r) ? position.x = width - r : position.x = r
|
@@ -46,7 +46,7 @@ class Ball
|
|
46
46
|
(position.y > height - r) ? position.y = height - r : position.y = r
|
47
47
|
velocity.y *= -1
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def check_collision(other_ball)
|
51
51
|
# get distances between the balls components
|
52
52
|
difference = other_ball.position - position
|
@@ -105,7 +105,7 @@ class Ball
|
|
105
105
|
other_ball.velocity.x = cosine * final_velocities[1].x - sine * final_velocities[1].y
|
106
106
|
other_ball.velocity.y = cosine * final_velocities[1].y + sine * final_velocities[1].x
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
def display
|
110
110
|
no_stroke
|
111
111
|
fill(204)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
#!/usr/bin/env jruby -v -w
|
1
2
|
# Creating Colors (Homage to Albers).
|
2
3
|
#
|
3
4
|
require 'propane'
|
@@ -7,7 +8,7 @@ require 'propane'
|
|
7
8
|
class CreatingColors < Propane::App
|
8
9
|
attr_reader :redder, :yellower, :orangish
|
9
10
|
def setup
|
10
|
-
size 640,
|
11
|
+
size 640, 360
|
11
12
|
# palette = web_to_color_array(['#CC6600', '#CC9900', '#993300'].to_java(:string))
|
12
13
|
palette = web_to_color_array(['#CC6600', '#CC9900', '#993300'])
|
13
14
|
# @redder = color 204, 102, 0
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env jruby -v -w
|
2
2
|
# frozen_string_literal: true
|
3
3
|
# Creating Colors (Homage to Albers).
|
4
4
|
#
|
@@ -8,7 +8,7 @@ require 'propane'
|
|
8
8
|
# in the program by their name, rather than a number.
|
9
9
|
class CreatingColors < Propane::App
|
10
10
|
attr_reader :redder, :yellower, :orangish
|
11
|
-
|
11
|
+
|
12
12
|
WEB = %w(#CC6600 #CC9900 #993300)
|
13
13
|
|
14
14
|
def setup
|
data/examples/regular/empathy.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#!/usr/bin/env jruby -v -W2
|
1
2
|
# Empathy
|
2
3
|
# original by Kyle McDonald
|
3
4
|
# http://www.openprocessing.org/visuals/?visualID=1182
|
@@ -12,16 +13,16 @@ ROTATION = 0.004
|
|
12
13
|
LINE_LENGTH = 37
|
13
14
|
|
14
15
|
class Empathy < Propane::App
|
15
|
-
|
16
|
+
|
16
17
|
attr_reader :cells
|
17
|
-
|
18
|
+
|
18
19
|
def setup
|
19
20
|
size(500, 500)
|
20
21
|
stroke(0, 0, 0, 25)
|
21
22
|
@cells = create_cells(CELL_COUNT)
|
22
23
|
start_cell_updates
|
23
24
|
end
|
24
|
-
|
25
|
+
|
25
26
|
def create_cells(n)
|
26
27
|
(0..n).map do |i|
|
27
28
|
a = i + rand(PI / 9.0)
|
@@ -29,20 +30,20 @@ class Empathy < Propane::App
|
|
29
30
|
Cell.new((r * cos(a) + width / 2).to_i, (r * sin(a) + height / 2).to_i)
|
30
31
|
end
|
31
32
|
end
|
32
|
-
|
33
|
+
|
33
34
|
def start_cell_updates
|
34
35
|
Thread.new { Kernel.loop { cells.each(&:update) } }
|
35
36
|
end
|
36
|
-
|
37
|
+
|
37
38
|
def draw
|
38
39
|
background 255
|
39
40
|
cells.each(&:draw_line) if started?
|
40
41
|
end
|
41
|
-
|
42
|
+
|
42
43
|
def started?
|
43
44
|
pmouse_x != 0 || pmouse_y != 0
|
44
45
|
end
|
45
|
-
|
46
|
+
|
46
47
|
def mouse_pressed
|
47
48
|
cells.each(&:reset)
|
48
49
|
end
|
@@ -58,18 +59,18 @@ class Cell
|
|
58
59
|
@x, @y = x, y
|
59
60
|
reset
|
60
61
|
end
|
61
|
-
|
62
|
+
|
62
63
|
def reset
|
63
64
|
@spin, @angle = 0, 0
|
64
65
|
end
|
65
|
-
|
66
|
+
|
66
67
|
def update
|
67
68
|
det = ((pmouse_x - x) * (mouse_y - y) - (mouse_x - x) * (pmouse_y - y))
|
68
69
|
@spin += ROTATION * det.to_f / dist(x, y, mouse_x, mouse_y)
|
69
70
|
@spin *= SLOW_DOWN
|
70
71
|
@angle += spin
|
71
72
|
end
|
72
|
-
|
73
|
+
|
73
74
|
def draw_line
|
74
75
|
d = LINE_LENGTH * spin + 0.001
|
75
76
|
line(x, y, x + d * cos(angle), y + d * sin(angle))
|
data/examples/regular/fern.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#!/usr/bin/env jruby -v -w
|
1
2
|
# Description:
|
2
3
|
# Flight Patterns is that ol' Euruko 2008 demo.
|
3
4
|
# Reworked version for Propane
|
@@ -8,9 +9,9 @@ require 'propane'
|
|
8
9
|
|
9
10
|
class FlightPatterns < Propane::App
|
10
11
|
load_library :boids
|
11
|
-
|
12
|
+
|
12
13
|
attr_reader :flee, :radius
|
13
|
-
|
14
|
+
|
14
15
|
def setup
|
15
16
|
size 1024, 768, P3D
|
16
17
|
sphere_detail 8
|
@@ -24,16 +25,16 @@ class FlightPatterns < Propane::App
|
|
24
25
|
@flee = false
|
25
26
|
@flocks = (0..3).map { Boids.flock(n: 20, x: 0, y: 0, w: width, h: height) }
|
26
27
|
end
|
27
|
-
|
28
|
+
|
28
29
|
def mouse_pressed
|
29
30
|
@click = !@click
|
30
31
|
end
|
31
|
-
|
32
|
+
|
32
33
|
def key_pressed
|
33
34
|
return unless key == 'f'
|
34
35
|
@flee = !@flee
|
35
36
|
end
|
36
|
-
|
37
|
+
|
37
38
|
def draw
|
38
39
|
background 0.05
|
39
40
|
ambient_light 0.01, 0.01, 0.01
|
data/examples/regular/grapher.rb
CHANGED
@@ -1,15 +1,16 @@
|
|
1
|
+
#!/usr/bin/env jruby -v -w
|
1
2
|
require 'propane'
|
2
3
|
|
3
4
|
class Grapher < Propane::App
|
4
5
|
# Grapher is based on a context free art design
|
5
6
|
# by ColorMeImpressed (takes a bit of time to run)
|
6
7
|
# http://www.contextfreeart.org/gallery/view.php?id=2844
|
7
|
-
#
|
8
|
+
#
|
8
9
|
CMIN = -2.0 # Important to specify float else get random int from range?
|
9
10
|
CMAX = 2.0
|
10
11
|
FUZZ = 0.04
|
11
12
|
SZ = 5
|
12
|
-
|
13
|
+
|
13
14
|
def setup
|
14
15
|
size 600, 600
|
15
16
|
no_stroke
|
@@ -17,12 +18,12 @@ class Grapher < Propane::App
|
|
17
18
|
background(0)
|
18
19
|
frame_rate(4_000)
|
19
20
|
end
|
20
|
-
|
21
|
+
|
21
22
|
def draw
|
22
23
|
translate(width / 2, height / 2)
|
23
24
|
dot(rand(-180..180), rand(-180..180), rand(CMIN..CMAX)) unless frame_count > 200_000
|
24
25
|
end
|
25
|
-
|
26
|
+
|
26
27
|
def dot(px, py, c)
|
27
28
|
func = DegLut.sin(px) + DegLut.sin(py) + c
|
28
29
|
# change function to change the graph eg.
|
@@ -33,7 +34,7 @@ class Grapher < Propane::App
|
|
33
34
|
else
|
34
35
|
dot(rand(-180..180), rand(-180..180), rand(CMIN..CMAX))
|
35
36
|
end
|
36
|
-
end
|
37
|
+
end
|
37
38
|
end
|
38
39
|
|
39
40
|
Grapher.new title: 'Grapher'
|
data/examples/regular/gravity.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
+
#!/usr/bin/env jruby -v -w
|
2
|
+
# After Gravity by Christian Hahn
|
3
|
+
# mouse click on window
|
1
4
|
require 'propane'
|
2
5
|
|
3
6
|
class Gravity < Propane::App
|
4
|
-
# After Gravity by Christian Hahn
|
5
|
-
|
6
7
|
attr_reader :particles, :grabbed
|
7
|
-
|
8
|
+
|
8
9
|
def setup
|
9
10
|
size 600, 500
|
10
11
|
@particles = []
|
@@ -15,24 +16,24 @@ class Gravity < Propane::App
|
|
15
16
|
ellipse_mode CENTER
|
16
17
|
color_mode RGB, 255
|
17
18
|
end
|
18
|
-
|
19
|
+
|
19
20
|
def draw
|
20
21
|
no_stroke
|
21
22
|
fill 0, 60
|
22
23
|
rect 0, 0, width, height
|
23
24
|
particles.each(&:run)
|
24
25
|
end
|
25
|
-
|
26
|
+
|
26
27
|
def mouse_pressed
|
27
28
|
return if mouse_x == 0 || mouse_y == 0
|
28
29
|
return if particle_grab
|
29
30
|
particles << Particle.new(mouse_x, mouse_y, rand(0.1..8))
|
30
31
|
end
|
31
|
-
|
32
|
+
|
32
33
|
def mouse_released
|
33
34
|
@grabbed = nil
|
34
35
|
end
|
35
|
-
|
36
|
+
|
36
37
|
def particle_grab
|
37
38
|
@grabbed = particles.detect { |p| dist(mouse_x, mouse_y, p.x1, p.y1) < p.diameter/2 }
|
38
39
|
end
|
@@ -42,7 +43,7 @@ class Particle
|
|
42
43
|
include Math, Propane::Proxy
|
43
44
|
GRAVITY = 1.0
|
44
45
|
attr_reader :x0, :y0, :x1, :y1, :diameter, :mass_amount
|
45
|
-
|
46
|
+
|
46
47
|
def initialize(x, y, mass)
|
47
48
|
@x0, @y0, @x1, @y1 = x, y, x, y
|
48
49
|
@x_speed, @y_speed = 0, 0
|
@@ -50,7 +51,7 @@ class Particle
|
|
50
51
|
@mass_amount = mass
|
51
52
|
@diameter = sqrt(mass_amount) * 20
|
52
53
|
end
|
53
|
-
|
54
|
+
|
54
55
|
def collect_force
|
55
56
|
@x_accel, @y_accel = 0, 0
|
56
57
|
@min_dist = 1000
|
@@ -66,29 +67,29 @@ class Particle
|
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
69
|
-
|
70
|
+
|
70
71
|
def move
|
71
72
|
@x_speed, @y_speed = 0, 0 if grabbed?
|
72
73
|
@x_speed += @x_accel
|
73
74
|
@y_speed += @y_accel
|
74
75
|
@x1, @y1 = x0 + @x_speed, y0 + @y_speed
|
75
76
|
end
|
76
|
-
|
77
|
+
|
77
78
|
def grabbed?
|
78
79
|
$app.grabbed == self
|
79
80
|
end
|
80
|
-
|
81
|
+
|
81
82
|
def run
|
82
83
|
collect_force
|
83
84
|
move
|
84
85
|
render
|
85
86
|
end
|
86
|
-
|
87
|
+
|
87
88
|
def render
|
88
89
|
no_stroke
|
89
90
|
grabbed? ? render_grabbed : render_free
|
90
91
|
end
|
91
|
-
|
92
|
+
|
92
93
|
def render_free
|
93
94
|
charge_col = 1000.0 / @min_dist / 50.0
|
94
95
|
tot_col_1 = 100 + charge_col * 6
|
@@ -101,7 +102,7 @@ class Particle
|
|
101
102
|
ellipse x1, y1, diameter, diameter
|
102
103
|
@x0, @y0 = x1, y1
|
103
104
|
end
|
104
|
-
|
105
|
+
|
105
106
|
def render_grabbed
|
106
107
|
fill 150, 150, 255, 100
|
107
108
|
ellipse mouse_x, mouse_y, diameter + 8, diameter + 8
|
@@ -110,11 +111,10 @@ class Particle
|
|
110
111
|
ellipse mouse_x, mouse_y, diameter, diameter
|
111
112
|
@x0, @y0 = mouse_x, mouse_y
|
112
113
|
end
|
113
|
-
|
114
|
+
|
114
115
|
def angle_of(x1, y1, x2, y2)
|
115
116
|
Math::PI - atan2(y1 - y2, x1 - x2)
|
116
117
|
end
|
117
118
|
end
|
118
119
|
|
119
|
-
|
120
120
|
Gravity.new title: 'Gravity'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env jruby -v -w
|
2
2
|
# frozen_string_literal: true
|
3
3
|
# grey circles : borrowed from https://github.com/quil/quil
|
4
4
|
require 'propane'
|
@@ -9,7 +9,7 @@ class GreyCircles < Propane::App
|
|
9
9
|
size(323, 200)
|
10
10
|
smooth
|
11
11
|
frame_rate(1)
|
12
|
-
background(200)
|
12
|
+
background(200)
|
13
13
|
end
|
14
14
|
|
15
15
|
def draw
|
data/examples/regular/jwishy.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env jruby -v -W2
|
2
2
|
# frozen_string_literal: true
|
3
3
|
require 'propane'
|
4
4
|
# Iconic ruby-processing example for Propane
|
@@ -6,7 +6,7 @@ class JWishy < Propane::App
|
|
6
6
|
load_library :control_panel
|
7
7
|
|
8
8
|
attr_reader :alpha, :back_color, :bluish, :hide, :magnitude, :panel
|
9
|
-
attr_reader :x_wiggle, :y_wiggle
|
9
|
+
attr_reader :x_wiggle, :y_wiggle, :go_big, :shape
|
10
10
|
|
11
11
|
def setup
|
12
12
|
size 600, 600
|
@@ -15,13 +15,12 @@ class JWishy < Propane::App
|
|
15
15
|
c.look_feel 'Nimbus'
|
16
16
|
c.slider :bluish, 0.0..1.0, 0.5
|
17
17
|
c.slider :alpha, 0.0..1.0, 0.5
|
18
|
-
c.checkbox :go_big
|
18
|
+
c.checkbox :go_big, false
|
19
19
|
c.button :reset
|
20
|
-
c.menu :shape, %w(oval square triangle)
|
20
|
+
c.menu :shape, %w(oval square triangle), 'oval'
|
21
21
|
@panel = c
|
22
22
|
end
|
23
23
|
@hide = false
|
24
|
-
@shape = 'oval'
|
25
24
|
@x_wiggle, @y_wiggle = 10.0, 0
|
26
25
|
@magnitude = 8.15
|
27
26
|
@back_color = [0.06, 0.03, 0.18]
|
@@ -50,7 +49,7 @@ class JWishy < Propane::App
|
|
50
49
|
# Seed the random numbers for consistent placement from frame to frame
|
51
50
|
srand(0)
|
52
51
|
horiz, vert, mag = x_wiggle, y_wiggle, magnitude
|
53
|
-
if
|
52
|
+
if go_big
|
54
53
|
mag *= 2
|
55
54
|
vert /= 2
|
56
55
|
end
|
data/examples/regular/letters.rb
CHANGED
@@ -1,36 +1,36 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env jruby -v -W2
|
2
2
|
# frozen_string_literal: true
|
3
|
-
# Letters.
|
4
|
-
#
|
3
|
+
# Letters. Hit any key.
|
4
|
+
#
|
5
5
|
require 'propane'
|
6
6
|
|
7
7
|
LETTERS = ('A'..'Z').to_a + ('0'..'9').to_a + ('a'..'z').to_a
|
8
8
|
|
9
|
-
# Draws letters to the screen. This requires loading a font,
|
9
|
+
# Draws letters to the screen. This requires loading a font,
|
10
10
|
# setting the font, and then drawing the letters.
|
11
11
|
class Letters < Propane::App
|
12
|
-
def setup
|
13
|
-
size 640, 360
|
14
|
-
@font = create_font 'Georgia', 24
|
12
|
+
def setup
|
13
|
+
size 640, 360
|
14
|
+
@font = create_font 'Georgia', 24
|
15
15
|
text_font @font
|
16
|
-
text_align CENTER, CENTER
|
16
|
+
text_align CENTER, CENTER
|
17
17
|
end
|
18
|
-
|
19
|
-
def draw
|
20
|
-
background 0
|
21
|
-
translate 24, 32
|
18
|
+
|
19
|
+
def draw
|
20
|
+
background 0
|
21
|
+
translate 24, 32
|
22
22
|
x, y = 0.0, 0.0
|
23
|
-
gap = 30
|
24
|
-
# ranges -> arrays -> joined!
|
25
|
-
LETTERS.each do |letter|
|
23
|
+
gap = 30
|
24
|
+
# ranges -> arrays -> joined!
|
25
|
+
LETTERS.each do |letter|
|
26
26
|
fill 255
|
27
27
|
fill 204, 204, 0 if letter =~ /[AEIOU]/
|
28
28
|
fill 0, 204, 204 if letter =~ /[aeiou]/
|
29
29
|
fill 153 if letter =~ /[0-9]/
|
30
|
-
fill 255, 100, 0 if key_pressed? && (letter.downcase.eql? key)
|
31
|
-
fill 0, 100, 255 if key_pressed? && (letter.upcase.eql? key)
|
32
|
-
text letter, x, y
|
33
|
-
x += gap
|
30
|
+
fill 255, 100, 0 if key_pressed? && (letter.downcase.eql? key)
|
31
|
+
fill 0, 100, 255 if key_pressed? && (letter.upcase.eql? key)
|
32
|
+
text letter, x, y
|
33
|
+
x += gap
|
34
34
|
if x > width - 30
|
35
35
|
x = 0
|
36
36
|
y += gap
|