propane 0.8.0-java → 0.9.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -1
  3. data/README.md +1 -1
  4. data/lib/propane/app.rb +56 -55
  5. data/lib/propane/creators/sketch_writer.rb +7 -3
  6. data/lib/propane/helper_methods.rb +40 -29
  7. data/lib/propane/runner.rb +3 -2
  8. data/lib/propane/version.rb +1 -1
  9. data/pom.rb +1 -1
  10. data/pom.xml +1 -1
  11. data/vendors/Rakefile +31 -1
  12. metadata +2 -59
  13. data/examples/data_path/Rakefile +0 -32
  14. data/examples/data_path/bw_shader.rb +0 -47
  15. data/examples/data_path/data/Texture01.jpg +0 -0
  16. data/examples/data_path/data/Texture02.jpg +0 -0
  17. data/examples/data_path/data/Univers45.vlw +0 -0
  18. data/examples/data_path/data/bwfrag.glsl +0 -23
  19. data/examples/data_path/data/displaceFrag.glsl +0 -8
  20. data/examples/data_path/data/displaceVert.glsl +0 -201
  21. data/examples/data_path/data/lachoy.jpg +0 -0
  22. data/examples/data_path/data/landscape.glsl +0 -352
  23. data/examples/data_path/data/monjori.glsl +0 -30
  24. data/examples/data_path/data/moon.jpg +0 -0
  25. data/examples/data_path/data/sea.jpg +0 -0
  26. data/examples/data_path/edge_detection.rb +0 -49
  27. data/examples/data_path/glsl_heightmap_noise.rb +0 -125
  28. data/examples/data_path/kinetic_type.rb +0 -79
  29. data/examples/data_path/landscape.rb +0 -34
  30. data/examples/data_path/linear_image.rb +0 -51
  31. data/examples/data_path/monjori.rb +0 -35
  32. data/examples/regular/Rakefile +0 -30
  33. data/examples/regular/arcball_box.rb +0 -28
  34. data/examples/regular/arcball_constrain.rb +0 -29
  35. data/examples/regular/bezier_playground.rb +0 -206
  36. data/examples/regular/circle_collision.rb +0 -118
  37. data/examples/regular/colors_two.rb +0 -60
  38. data/examples/regular/creating_colors.rb +0 -64
  39. data/examples/regular/drawolver.rb +0 -93
  40. data/examples/regular/elegant_ball.rb +0 -159
  41. data/examples/regular/empathy.rb +0 -80
  42. data/examples/regular/fern.rb +0 -57
  43. data/examples/regular/fibonacci_sphere.rb +0 -91
  44. data/examples/regular/flight_patterns.rb +0 -64
  45. data/examples/regular/fractions.rb +0 -32
  46. data/examples/regular/grapher.rb +0 -40
  47. data/examples/regular/gravity.rb +0 -120
  48. data/examples/regular/grey_circles.rb +0 -28
  49. data/examples/regular/jwishy.rb +0 -99
  50. data/examples/regular/letters.rb +0 -42
  51. data/examples/regular/lib/boundary.rb +0 -38
  52. data/examples/regular/lib/particle.rb +0 -77
  53. data/examples/regular/lib/particle_system.rb +0 -111
  54. data/examples/regular/lib/rain_drops.rb +0 -54
  55. data/examples/regular/liquidy.rb +0 -41
  56. data/examples/regular/mouse_button_demo.rb +0 -32
  57. data/examples/regular/polyhedrons.rb +0 -249
  58. data/examples/regular/raining.rb +0 -60
  59. data/examples/regular/ribbon_doodle.rb +0 -89
  60. data/examples/regular/select_file.rb +0 -32
  61. data/examples/regular/select_image.rb +0 -40
  62. data/examples/regular/slider_demo.rb +0 -61
  63. data/examples/regular/slider_example.rb +0 -53
  64. data/examples/regular/slider_simple.rb +0 -47
  65. data/examples/regular/tree.rb +0 -76
  66. data/examples/regular/vector_math.rb +0 -37
  67. data/examples/regular/words.rb +0 -41
  68. data/lib/propane/helpers/string_extra.rb +0 -45
  69. data/lib/propane/underscorer.rb +0 -19
@@ -1,64 +0,0 @@
1
- #!/usr/bin/env jruby -v -w
2
- # Description:
3
- # Flight Patterns is that ol' Euruko 2008 demo.
4
- # Reworked version for Propane
5
- # Usage:
6
- # Drag mouse to steer 'invisible' flock attractor, use 'f' key to toggle flee
7
- # Mouse 'click' to toggle 'sphere' or 'circle' display
8
- require 'propane'
9
-
10
- class FlightPatterns < Propane::App
11
- load_library :boids
12
-
13
- attr_reader :flee, :radius
14
-
15
- def setup
16
- size 1024, 768, P3D
17
- sphere_detail 8
18
- color_mode RGB, 1.0
19
- no_stroke
20
- shininess 1.0
21
- specular 0.3, 0.1, 0.1
22
- emissive 0.03, 0.03, 0.1
23
- @radius = 0.02 * height
24
- @click = false
25
- @flee = false
26
- @flocks = (0..3).map { Boids.flock(n: 20, x: 0, y: 0, w: width, h: height) }
27
- end
28
-
29
- def mouse_pressed
30
- @click = !@click
31
- end
32
-
33
- def key_pressed
34
- return unless key == 'f'
35
- @flee = !@flee
36
- end
37
-
38
- def draw
39
- background 0.05
40
- ambient_light 0.01, 0.01, 0.01
41
- light_specular 0.4, 0.2, 0.2
42
- point_light 1.0, 1.0, 1.0, mouse_x, mouse_y, 190
43
- @flocks.each_with_index do |flock, i|
44
- flock.goal(target: Vec3D.new(mouse_x, mouse_y, 0), flee: @flee)
45
- flock.update(goal: 185, limit: 13.5)
46
- flock.each do |boid|
47
- r = (0.15 * boid.pos.z) + radius
48
- case i
49
- when 0 then fill 0.85, 0.65, 0.65
50
- when 1 then fill 0.65, 0.85, 0.65
51
- when 2 then fill 0.65, 0.65, 0.85
52
- end
53
- push_matrix
54
- point_array = (boid.pos.to_a).map { |p| p - (r / 2.0) }
55
- translate(*point_array)
56
- @click ? sphere(r / 2) : ellipse(0, 0, r, r)
57
- @click ? hint(ENABLE_DEPTH_TEST) : hint(DISABLE_DEPTH_TEST)
58
- pop_matrix
59
- end
60
- end
61
- end
62
- end
63
-
64
- FlightPatterns.new title: 'Flight Patterns'
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env jruby -v -w
2
- # fractions.rb, by Martin Prout
3
- require 'propane'
4
-
5
- class Fractions < Propane::App
6
- attr_reader :f, :add, :subtract, :multiply
7
-
8
- def setup
9
- size 640, 250
10
- @f = createFont('Arial', 24, true)
11
- third = 1 / 3r # since ruby 2.1.0 (and jruby-9.0.0.0)
12
- quarter = 1 / 4r
13
- format_add = '%s + %s = %s'
14
- format_sub = format_add.gsub('+', '-')
15
- format_mult = format_add.gsub('+', '*')
16
- @add = format(format_add, third, quarter, third + quarter)
17
- @subtract = format(format_sub, third, quarter, third - quarter)
18
- @multiply = format(format_mult, third, quarter, third * quarter)
19
- end
20
-
21
- def draw
22
- background 10
23
- text_font(f, 24)
24
- fill(220)
25
- text('Math Blackboard Propane', 80, 50)
26
- text(add, 110, 100)
27
- text(subtract, 110, 150)
28
- text(multiply, 110, 200)
29
- end
30
- end
31
-
32
- Fractions.new(title: 'Fraction Sums')
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env jruby -v -w
2
- require 'propane'
3
-
4
- class Grapher < Propane::App
5
- # Grapher is based on a context free art design
6
- # by ColorMeImpressed (takes a bit of time to run)
7
- # http://www.contextfreeart.org/gallery/view.php?id=2844
8
- #
9
- CMIN = -2.0 # Important to specify float else get random int from range?
10
- CMAX = 2.0
11
- FUZZ = 0.04
12
- SZ = 5
13
-
14
- def setup
15
- size 600, 600
16
- no_stroke
17
- color_mode(HSB, 1.0)
18
- background(0)
19
- frame_rate(4_000)
20
- end
21
-
22
- def draw
23
- translate(width / 2, height / 2)
24
- dot(rand(-180..180), rand(-180..180), rand(CMIN..CMAX)) unless frame_count > 200_000
25
- end
26
-
27
- def dot(px, py, c)
28
- func = DegLut.sin(px) + DegLut.sin(py) + c
29
- # change function to change the graph eg.
30
- # func = DegLut.cos(px) + DegLut.sin(py) + c
31
- if func.abs <= FUZZ
32
- fill(((CMIN - c) / (CMIN - CMAX)), 1, 1)
33
- ellipse px * width / 360, py * height / 360, SZ, SZ
34
- else
35
- dot(rand(-180..180), rand(-180..180), rand(CMIN..CMAX))
36
- end
37
- end
38
- end
39
-
40
- Grapher.new title: 'Grapher'
@@ -1,120 +0,0 @@
1
- #!/usr/bin/env jruby -v -w
2
- # After Gravity by Christian Hahn
3
- # mouse click on window
4
- require 'propane'
5
-
6
- class Gravity < Propane::App
7
- attr_reader :particles, :grabbed
8
-
9
- def setup
10
- size 600, 500
11
- @particles = []
12
- @grabbed = nil
13
- background 0
14
- smooth 4
15
- stroke_weight 4
16
- ellipse_mode CENTER
17
- color_mode RGB, 255
18
- end
19
-
20
- def draw
21
- no_stroke
22
- fill 0, 60
23
- rect 0, 0, width, height
24
- particles.each(&:run)
25
- end
26
-
27
- def mouse_pressed
28
- return if mouse_x == 0 || mouse_y == 0
29
- return if particle_grab
30
- particles << Particle.new(mouse_x, mouse_y, rand(0.1..8))
31
- end
32
-
33
- def mouse_released
34
- @grabbed = nil
35
- end
36
-
37
- def particle_grab
38
- @grabbed = particles.detect { |p| dist(mouse_x, mouse_y, p.x1, p.y1) < p.diameter/2 }
39
- end
40
- end
41
-
42
- class Particle
43
- include Math, Propane::Proxy
44
- GRAVITY = 1.0
45
- attr_reader :x0, :y0, :x1, :y1, :diameter, :mass_amount
46
-
47
- def initialize(x, y, mass)
48
- @x0, @y0, @x1, @y1 = x, y, x, y
49
- @x_speed, @y_speed = 0, 0
50
- @x_accel, @y_accel = 0, 0
51
- @mass_amount = mass
52
- @diameter = sqrt(mass_amount) * 20
53
- end
54
-
55
- def collect_force
56
- @x_accel, @y_accel = 0, 0
57
- @min_dist = 1000
58
- $app.particles.each do |p|
59
- next if p == self
60
- g_dist = hypot(x0 - p.x0, y0 - p.y0)
61
- g_theta = -angle_of(x0, y0, p.x0, p.y0)
62
- @min_dist = g_dist if g_dist < @min_dist
63
- force = (GRAVITY * mass_amount * p.mass_amount) / g_dist
64
- if g_dist.abs > diameter
65
- @x_accel += force / mass_amount * cos(g_theta)
66
- @y_accel += force / mass_amount * sin(g_theta)
67
- end
68
- end
69
- end
70
-
71
- def move
72
- @x_speed, @y_speed = 0, 0 if grabbed?
73
- @x_speed += @x_accel
74
- @y_speed += @y_accel
75
- @x1, @y1 = x0 + @x_speed, y0 + @y_speed
76
- end
77
-
78
- def grabbed?
79
- $app.grabbed == self
80
- end
81
-
82
- def run
83
- collect_force
84
- move
85
- render
86
- end
87
-
88
- def render
89
- no_stroke
90
- grabbed? ? render_grabbed : render_free
91
- end
92
-
93
- def render_free
94
- charge_col = 1000.0 / @min_dist / 50.0
95
- tot_col_1 = 100 + charge_col * 6
96
- tot_col_2 = 150 + charge_col * charge_col
97
- tot_col_3 = diameter + 8 + charge_col
98
- fill(tot_col_1, tot_col_1, 255, charge_col * 150 + 3)
99
- ellipse(x1, y1, tot_col_3, tot_col_3)
100
- fill 0, 255
101
- stroke tot_col_2, tot_col_2, 255, charge_col * 255 + 3
102
- ellipse x1, y1, diameter, diameter
103
- @x0, @y0 = x1, y1
104
- end
105
-
106
- def render_grabbed
107
- fill 150, 150, 255, 100
108
- ellipse mouse_x, mouse_y, diameter + 8, diameter + 8
109
- fill 0, 255
110
- stroke 150, 150, 255, 255
111
- ellipse mouse_x, mouse_y, diameter, diameter
112
- @x0, @y0 = mouse_x, mouse_y
113
- end
114
-
115
- def angle_of(x1, y1, x2, y2)
116
- Math::PI - atan2(y1 - y2, x1 - x2)
117
- end
118
- end
119
-
120
- Gravity.new title: 'Gravity'
@@ -1,28 +0,0 @@
1
- #!/usr/bin/env jruby -v -w
2
- # frozen_string_literal: true
3
- # grey circles : borrowed from https://github.com/quil/quil
4
- require 'propane'
5
-
6
- class GreyCircles < Propane::App
7
-
8
- def setup
9
- size(323, 200)
10
- smooth
11
- frame_rate(1)
12
- background(200)
13
- end
14
-
15
- def draw
16
- stroke_setup
17
- diameter = rand(100)
18
- ellipse(rand(width), rand(height), diameter, diameter)
19
- end
20
-
21
- def stroke_setup
22
- [:stroke, :stroke_weight, :fill].each do |method|
23
- send(method, rand(255))
24
- end
25
- end
26
- end
27
-
28
- GreyCircles.new title: 'Oh so many circles'
@@ -1,99 +0,0 @@
1
- #!/usr/bin/env jruby -v -W2
2
- # frozen_string_literal: true
3
- require 'propane'
4
- # Iconic ruby-processing example for Propane
5
- class JWishy < Propane::App
6
- load_library :control_panel
7
-
8
- attr_reader :alpha, :back_color, :bluish, :hide, :magnitude, :panel
9
- attr_reader :x_wiggle, :y_wiggle, :go_big, :shape
10
-
11
- def setup
12
- size 600, 600
13
- control_panel do |c|
14
- c.title = 'Control Panel'
15
- c.look_feel 'Nimbus'
16
- c.slider :bluish, 0.0..1.0, 0.5
17
- c.slider :alpha, 0.0..1.0, 0.5
18
- c.checkbox :go_big, false
19
- c.button :reset
20
- c.menu :shape, %w(oval square triangle), 'oval'
21
- @panel = c
22
- end
23
- @hide = false
24
- @x_wiggle, @y_wiggle = 10.0, 0
25
- @magnitude = 8.15
26
- @back_color = [0.06, 0.03, 0.18]
27
- color_mode RGB, 1
28
- ellipse_mode CORNER
29
- smooth
30
- end
31
-
32
- def draw_background
33
- back_color[3] = alpha
34
- fill(*back_color.to_java(:float))
35
- rect 0, 0, width, height
36
- end
37
-
38
- def reset
39
- @y_wiggle = 0
40
- end
41
-
42
- def draw
43
- # only make control_panel visible once, or again when hide is false
44
- unless hide
45
- @hide = true
46
- panel.set_visible(hide)
47
- end
48
- draw_background
49
- # Seed the random numbers for consistent placement from frame to frame
50
- srand(0)
51
- horiz, vert, mag = x_wiggle, y_wiggle, magnitude
52
- if go_big
53
- mag *= 2
54
- vert /= 2
55
- end
56
- blu = bluish
57
- x, y = (width / 2), -27
58
- c = 0.0
59
- 64.times do
60
- x += cos(horiz) * mag
61
- y += log10(vert) * mag + sin(vert) * 2
62
- fill(sin(y_wiggle + c), rand * 0.2, rand * blu, 0.5)
63
- s = 42 + cos(vert) * 17
64
- args = [@shape, x - s / 2, y - s / 2, s, s]
65
- draw_shape(args)
66
- vert += rand * 0.25
67
- horiz += rand * 0.25
68
- c += 0.1
69
- end
70
- @x_wiggle += 0.05
71
- @y_wiggle += 0.1
72
- end
73
-
74
- def mouse_pressed
75
- return unless hide
76
- @hide = false
77
- end
78
-
79
- def draw_shape(args)
80
- case args[0]
81
- when 'triangle'
82
- draw_triangle(args)
83
- when 'square'
84
- rect(args[1], args[2], args[3], args[4])
85
- else
86
- ellipse(args[1], args[2], args[3], args[4]) # oval for Shoes
87
- end
88
- end
89
-
90
- def draw_triangle(args)
91
- x2 = args[1] + (args[3] * 0.6)
92
- y0 = args[2] + (args[4] * 0.396)
93
- y1 = args[2] - (args[4] * 0.792)
94
- y2 = args[2] + (args[4] * 0.396)
95
- triangle(args[1] - (args[3] * 0.6), y0, args[1], y1, x2, y2)
96
- end
97
- end
98
-
99
- JWishy.new title: 'Wishy Worm'
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env jruby -v -W2
2
- # frozen_string_literal: true
3
- # Letters. Hit any key.
4
- #
5
- require 'propane'
6
-
7
- LETTERS = ('A'..'Z').to_a + ('0'..'9').to_a + ('a'..'z').to_a
8
-
9
- # Draws letters to the screen. This requires loading a font,
10
- # setting the font, and then drawing the letters.
11
- class Letters < Propane::App
12
- def setup
13
- size 640, 360
14
- @font = create_font 'Georgia', 24
15
- text_font @font
16
- text_align CENTER, CENTER
17
- end
18
-
19
- def draw
20
- background 0
21
- translate 24, 32
22
- x, y = 0.0, 0.0
23
- gap = 30
24
- # ranges -> arrays -> joined!
25
- LETTERS.each do |letter|
26
- fill 255
27
- fill 204, 204, 0 if letter =~ /[AEIOU]/
28
- fill 0, 204, 204 if letter =~ /[aeiou]/
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
34
- if x > width - 30
35
- x = 0
36
- y += gap
37
- end
38
- end
39
- end
40
- end
41
-
42
- Letters.new title: 'Letters'
@@ -1,38 +0,0 @@
1
- # Re-usable Boundary class
2
- class Boundary
3
- include Propane::Proxy
4
- attr_reader :box2d, :b, :pos, :size, :a
5
-
6
- def initialize(b2d, pos, sz, a = 0)
7
- @box2d, @pos, @size, @a = b2d, pos, sz, a
8
- # Define the polygon
9
- sd = PolygonShape.new
10
- # Figure out the box2d coordinates
11
- box2d_w = box2d.scale_to_world(size.x / 2)
12
- box2d_h = box2d.scale_to_world(size.y / 2)
13
- # We're just a box
14
- sd.set_as_box(box2d_w, box2d_h)
15
- # Create the body
16
- bd = BodyDef.new
17
- bd.type = BodyType::STATIC
18
- bd.angle = a
19
- bd.position.set(box2d.processing_to_world(pos.x, pos.y))
20
- @b = box2d.create_body(bd)
21
- # Attached the shape to the body using a Fixture
22
- b.create_fixture(sd, 1)
23
- end
24
-
25
- # Draw the boundary, it doesn't move so we don't ask for location
26
- def display
27
- fill(0)
28
- stroke(0)
29
- stroke_weight(1)
30
- rect_mode(PConstants::CENTER)
31
- a = b.get_angle
32
- push_matrix
33
- translate(pos.x, pos.y)
34
- rotate(-a)
35
- rect(0, 0, size.x, size.y)
36
- pop_matrix
37
- end
38
- end