Skip to content

Commit 9799bb7

Browse files
committed
Update samples for propane-2.0 (ie processing 3)
1 parent c6aabbd commit 9799bb7

39 files changed

+246
-102
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# propane-examples
2-
Example Sketches for propane see also [Example-Sketches][examples] for ruby-processing (many of with only need to be class wrapped to run with propane).
2+
Example Sketches for propane-2.0+ see also [Example-Sketches][examples] for ruby-processing (many of with only need to be class wrapped to run with propane).
33

4-
1. Sketches using the [data_path wrapper][path] (yields absolute path to `data` folder). NB without wrapper these sketches would need to be run using jruby-complete (`propane --run sketch.rb` rather than `jruby sketch.rb`
4+
1. Sketches using the [data_path wrapper][path] (yields absolute path to `data` folder).
55

6-
2. Other [sketches][regular], can be run with `propane --run sketch.rb` or `jruby sketch.rb`
6+
2. Other [sketches][regular]
77

88
[path]:https://github.com/ruby-processing/propane-examples/tree/master/data_path
99
[regular]:https://github.com/ruby-processing/propane-examples/tree/master/data_path

data_path/bw_shader.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ class BwShader < Propane::App
77

88
attr_reader :label, :can, :angle, :bw_shader
99

10-
def setup
10+
def settings
1111
size(640, 360, P3D)
12+
end
13+
14+
def setup
15+
sketch_title 'Black and White Shader'
1216
@label = load_image(data_path('lachoy.jpg'))
1317
@can = create_can(100, 200, 32, label)
1418
@bw_shader = load_shader(data_path('bwfrag.glsl'))
@@ -44,4 +48,4 @@ def create_can(r, h, detail, tex)
4448
end
4549
end
4650

47-
BwShader.new title: 'Black & White Shader'
51+
BwShader.new

data_path/edge_detection.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ class EdgeDetection < Propane::App
1010
KERNEL = [[-1, -1, -1], [-1, 9, -1], [-1, -1, -1]].freeze
1111
attr_reader :img
1212

13-
def setup
13+
def settings
1414
size(640, 360)
15+
end
16+
17+
def setup
18+
sketch_title 'Edge Detection'
1519
@img = load_image(data_path('moon.jpg')) # Load the original image
1620
no_loop
1721
end
@@ -46,4 +50,4 @@ def draw
4650
end
4751
end
4852

49-
EdgeDetection.new title: 'Edge Detection'
53+
EdgeDetection.new

data_path/glsl_heightmap_noise.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ class HeightMap < Propane::App
2929
attr_reader :images # array to hold 2 input images
3030
attr_reader :color_map # variable to keep track of the current colorMap
3131

32-
def setup
32+
def settings
3333
size(1280, 720, P3D) # use the P3D OpenGL renderer
34+
end
35+
36+
def setup
37+
sketch_title 'Height Map'
3438
@blur_factor = 3
3539
@resize_factor = 0.25
3640
displace_strength = 0.25 # the displace strength of the GLSL shader displacement effect
@@ -122,4 +126,4 @@ def key_released
122126
end
123127
end
124128

125-
HeightMap.new title: 'Height Map'
129+
HeightMap.new

data_path/kinetic_type.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
# dispay them 'words'
1414
class KineticType < Propane::App
1515

16-
def setup
16+
def settings
1717
size(200, 200, P3D)
18+
end
19+
20+
def setup
21+
sketch_title 'Kinetic Type'
1822
frame_rate 30
1923
# Load the font from the sketch's data directory.
2024
text_font loadFont(data_path('Univers45.vlw')), 1.0
@@ -76,4 +80,4 @@ def initialize(c, x, y)
7680
end
7781
end
7882

79-
KineticType.new title: 'Kinetic Type'
83+
KineticType.new

data_path/landscape.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ class Landscape < Propane::App
1313
attr_reader :landscape
1414
java_alias :background_int, :background, [Java::int]
1515

16-
def setup
16+
def settings
1717
size(640, 360, P2D)
18+
end
19+
20+
def setup
21+
sketch_title 'Landscape'
1822
no_stroke
1923
# The code of this shader shows how to integrate shaders from shadertoy
2024
# into Processing with minimal changes.
@@ -31,4 +35,4 @@ def draw
3135
end
3236
end
3337

34-
Landscape.new title: 'Landscape'
38+
Landscape.new

data_path/linear_image.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
class LinearImage < Propane::App
1313
attr_reader :signal, :img, :direction
1414

15-
def setup
15+
def settings
1616
size(640, 360)
17+
end
18+
19+
def setup
20+
sketch_title 'Linear Image'
1721
stroke(255)
1822
@img = load_image(data_path('sea.jpg'))
1923
@direction = 1
@@ -48,4 +52,4 @@ def draw
4852
end
4953
end
5054

51-
LinearImage.new title: 'Linear Image'
55+
LinearImage.new

data_path/monjori.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ class Monjori < Propane::App
1313
# (Look for Monjori under the Plane Deformations Presets)
1414

1515
attr_reader :monjori
16-
17-
def setup
16+
17+
def settings
1818
size(640, 360, P2D)
19+
end
20+
21+
def setup
22+
sketch_title 'Monjori'
1923
no_stroke
2024
@monjori = load_shader(data_path('monjori.glsl'))
2125
monjori.set('resolution', width.to_f, height.to_f)
@@ -32,4 +36,4 @@ def draw
3236
end
3337
end
3438

35-
Monjori.new title: 'Monjori'
39+
Monjori.new

regular/arcball_box.rb

+14-11
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,21 @@
1111

1212
class ArcballBox < Propane::App
1313

14-
def setup
15-
size(600, 600, P3D)
16-
smooth(8)
17-
Processing::ArcBall.init(self, 300, 300)
18-
fill 180
19-
end
14+
def setup
15+
size(600, 600, P3D)
16+
smooth(8)
17+
end
2018

21-
def draw
22-
background(50)
23-
box(300, 300, 300)
24-
end
19+
def setup
20+
sketch_title 'ArcBall Box'
21+
ArcBall.init(self, 300, 300)
22+
fill 180
23+
end
2524

25+
def draw
26+
background(50)
27+
box(300, 300, 300)
28+
end
2629
end
2730

28-
ArcballBox.new title: 'ArcBall Box'
31+
ArcballBox.new

regular/arcball_constrain.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@
1212

1313
class ArcballBox < Propane::App
1414

15-
def setup
15+
def settings
1616
size(600, 600, P3D)
1717
smooth(8)
18+
end
19+
20+
def setup
21+
sketch_title 'ArcBall Box'
1822
Processing::ArcBall.constrain(self, :xaxis)
1923
fill 180
2024
end
@@ -23,7 +27,6 @@ def draw
2327
background(50)
2428
box(300, 300, 300)
2529
end
26-
2730
end
2831

29-
ArcballBox.new title: 'ArcBall Box'
32+
ArcballBox.new

regular/bezier_playground.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,13 @@ class BezierPlayground < Propane::App
6565

6666
load_library :control_panel
6767
include Olap
68+
69+
def settings
70+
size 300, 300
71+
end
6872

6973
def setup
70-
size 300, 300
74+
sketch_title 'Bezier Playground'
7175
@curves = []
7276
@hide = false
7377
control_panel do |c|
@@ -203,4 +207,4 @@ def draw_control_tangent_lines
203207
end
204208
end
205209

206-
BezierPlayground.new title: 'Bezier Playground'
210+
BezierPlayground.new

regular/circle_collision.rb

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
# Based on http://processing.org/learning/topics/circlecollision.html
55
class CircleCollision < Propane::App
66
attr_reader :balls
7+
8+
def settings
9+
size 640, 360
10+
end
711

812
def setup
9-
size 640, 360
13+
sketch_title 'Circle Collision'
1014
@balls = [Ball.new(100, 40, 20), Ball.new(200, 100, 80)]
1115
end
1216

@@ -113,6 +117,4 @@ def display
113117
end
114118
end
115119

116-
117-
118-
CircleCollision.new title: 'Circle Collision'
120+
CircleCollision.new

regular/colors_two.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
# in the program by their name, rather than a number.
88
class CreatingColors < Propane::App
99
attr_reader :redder, :yellower, :orangish
10-
def setup
10+
def settings
1111
size 640, 360
12+
end
13+
14+
def setup
15+
sketch_title 'Homage to Albers'
1216
# palette = web_to_color_array(['#CC6600', '#CC9900', '#993300'].to_java(:string))
1317
palette = web_to_color_array(['#CC6600', '#CC9900', '#993300'])
1418
# @redder = color 204, 102, 0
@@ -57,4 +61,4 @@ def draw
5761
end
5862
end
5963

60-
CreatingColors.new title: 'Homage to Albers'
64+
CreatingColors.new

regular/creating_colors.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
# in the program by their name, rather than a number.
99
class CreatingColors < Propane::App
1010
attr_reader :redder, :yellower, :orangish
11-
1211
WEB = %w(#CC6600 #CC9900 #993300)
12+
13+
def settings
14+
size 640, 360
15+
end
1316

1417
def setup
15-
size 640, 360
18+
sketch_title 'Homage to Albers'
1619
palette = web_to_color_array(WEB)
1720
@redder = palette[0]
1821
@yellower = palette[1]
@@ -61,4 +64,4 @@ def draw
6164
end
6265
end
6366

64-
CreatingColors.new title: 'Homage to Albers'
67+
CreatingColors.new

regular/drawolver.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@
1212
class Drawolver < Propane::App
1313
attr_reader :drawing_mode, :points, :rot_x, :rot_y, :vertices
1414

15-
def setup
15+
def settings
1616
size 1024, 768, P3D
17+
end
18+
19+
def setup
20+
sketch_title 'Drawolver'
1721
frame_rate 30
1822
reset_scene
1923
end
@@ -90,4 +94,4 @@ def recalculate_shape
9094
end
9195
end
9296

93-
Drawolver.new title: 'Drawolver'
97+
Drawolver.new

regular/elegant_ball.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
class ElegantBall < Propane::App
1010

1111
attr_reader :start_t
12-
1312
def setup
1413
size(800, 800, P3D)
14+
end
15+
16+
def setup
17+
sketch_title 'Elegant Ball'
1518
color_mode(RGB, 1)
1619
end
1720

@@ -156,4 +159,4 @@ def draw_triangle(depth, r, p1, p2, p3)
156159
end
157160
end
158161

159-
ElegantBall.new title: 'Elegant Ball'
162+
ElegantBall.new

regular/empathy.rb

+7-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@
1515
class Empathy < Propane::App
1616

1717
attr_reader :cells
18-
19-
def setup
18+
19+
def settings
2020
size(500, 500)
21+
end
22+
23+
def setup
24+
sketch_title 'Empathy'
2125
stroke(0, 0, 0, 25)
2226
@cells = create_cells(CELL_COUNT)
2327
start_cell_updates
@@ -77,4 +81,4 @@ def draw_line
7781
end
7882
end
7983

80-
Empathy.new(title: 'Empathy')
84+
Empathy.new

regular/fern.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ class Fern < Propane::App
77

88
attr_reader :bnds
99

10-
def setup
10+
def settings
1111
size 500, 500
12+
end
13+
14+
def setup
15+
sketch_title 'Fern'
1216
@bnds = Boundary.new(0, width)
1317
no_loop
1418
puts 'Be patient. This takes about 10 seconds to render.'
@@ -54,4 +58,4 @@ def include?(x)
5458
end
5559
end
5660

57-
Fern.new title: 'Fern'
61+
Fern.new

0 commit comments

Comments
 (0)