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,60 +0,0 @@
1
- #!/usr/bin/env jruby -v -W2
2
- require 'propane'
3
- require_relative 'lib/rain_drops'
4
-
5
- class Raining < Propane::App
6
- # raining after Rain1 by Thomas R. 'TomK32' Koll
7
- #
8
- # draws raindrops as bezier shapes and moves them downwards
9
- #
10
- # available key commands:
11
- # + make raindrops heavier/bigger
12
- # - make raindrops smaller
13
- # a more raindrops
14
- # s less raindrops
15
- # <SPACE>
16
- #
17
- # License: Same as processing
18
- #
19
-
20
- attr_reader :drops, :weight, :drops_size, :paused
21
-
22
- def setup
23
- size 640, 480
24
- frame_rate 30
25
- @drops_size = 20
26
- @weight = 20
27
- @drops = RainDrops.new width, height
28
- @paused = false
29
- font = create_font('Georgia', 15)
30
- text_font(font)
31
- end
32
-
33
- def draw
34
- return if paused
35
- # we fill up with new drops randomly
36
- drops.fill_up(weight) while rand(drops_size / 3) < (drops_size - drops.size)
37
- # the less drops the darker it is
38
- background 127 + 127 * (drops.size / drops_size.to_f)
39
- drops.run
40
- form = '%d of %d drops with a size of %d'
41
- text(format(form, drops.size, drops_size, weight), 10, 20)
42
- end
43
-
44
- def key_pressed
45
- case key
46
- when '+'
47
- @weight += 5
48
- when '-'
49
- @weight -= 5 if weight > 10
50
- when 'a'
51
- @drops_size += 5
52
- when 's'
53
- @drops_size -= 5 if drops_size > 5
54
- when ' '
55
- @paused = !paused
56
- end
57
- end
58
- end
59
-
60
- Raining.new title: 'Raining'
@@ -1,89 +0,0 @@
1
- #!/usr/bin/env jruby -v -W2
2
- # frozen_string_literal: true
3
- # Adapted to use Propane Vec2D and Vec3D classes by Martin Prout
4
-
5
- # Use Face Struct triangle 'mesh'.
6
- Face = Struct.new(:a, :b, :c) # triangle mesh face
7
- require 'propane'
8
-
9
- # Monkey patch the Vec3D class to support rotations
10
- Vec3D.class_eval do # re-open the Vec3D class to add the rotate methods
11
- def rotate_y!(theta)
12
- co = Math.cos(theta)
13
- si = Math.sin(theta)
14
- xx = co * x - si * z
15
- self.z = si * x + co * z
16
- self.x = xx
17
- self
18
- end
19
-
20
- def rotate_x!(theta)
21
- co = Math.cos(theta)
22
- si = Math.sin(theta)
23
- zz = co * z - si * y
24
- self.y = si * z + co * y
25
- self.z = zz
26
- self
27
- end
28
- end
29
-
30
- # After a toxiclibs "MeshDoodle" sketch by Karsten Schmidt
31
- class Doodle < Propane::App
32
- attr_reader :prev, :p, :q, :rotation, :faces, :pos, :weight
33
-
34
- def setup
35
- size(600, 600, P3D)
36
- @weight = 0
37
- @prev = Vec3D.new
38
- @p = Vec3D.new
39
- @q = Vec3D.new
40
- @rotation = Vec2D.new
41
- @faces = []
42
- end
43
-
44
- def draw
45
- background(0)
46
- lights
47
- translate(width / 2, height / 2, 0)
48
- rotate_x(rotation.x)
49
- rotate_y(rotation.y)
50
- no_stroke
51
- begin_shape(TRIANGLES)
52
- # iterate over all faces/triangles of the 'mesh'
53
- faces.each do |f|
54
- # create vertices for each corner point
55
- f.a.to_vertex(renderer)
56
- f.b.to_vertex(renderer)
57
- f.c.to_vertex(renderer)
58
- end
59
- end_shape
60
- # update rotation
61
- @rotation += Vec2D.new(0.014, 0.0237)
62
- end
63
-
64
- def mouse_moved
65
- # get 3D rotated mouse position
66
- @pos = Vec3D.new(mouse_x - width / 2, mouse_y - height / 2, 0)
67
- pos.rotate_x!(rotation.x)
68
- pos.rotate_y!(rotation.y)
69
- # use distance to previous point as target stroke weight
70
- @weight += (sqrt(pos.dist(prev)) * 2 - weight) * 0.1
71
- # define offset points for the triangle strip
72
- a = pos + Vec3D.new(0, 0, weight)
73
- b = pos + Vec3D.new(0, 0, -weight)
74
- # add 2 faces to the mesh
75
- faces << Face.new(p, b, q)
76
- faces << Face.new(p, a, b)
77
- # store current points for next iteration
78
- @prev = pos
79
- @p = a
80
- @q = b
81
- end
82
-
83
- # An example of AppRenderer usage for Vec3D => vertex conversion
84
- def renderer
85
- @renderer ||= Propane::Render::AppRender.new(self)
86
- end
87
- end
88
-
89
- Doodle.new title: 'Ribbon Doodle'
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env jruby -v -W2
2
-
3
- ############################
4
- # Use mouse drag to rotate
5
- # The arcball. Use mousewheel
6
- # to zoom. Hold down x, y, z
7
- # to constrain rotation axis.
8
- ############################
9
-
10
- require 'propane'
11
-
12
- class SelectFile < Propane::App
13
-
14
- load_library :file_chooser
15
- ###########
16
- # Example Native File Chooser using vanilla processing
17
- # select_input, and file_selected
18
- ###########
19
-
20
- def setup
21
- size 200, 100
22
- # java_signature 'void selectInput(String, String)'
23
- select_input('Select a File', 'file_selected')
24
- end
25
-
26
- # signature 'void file_selected(java.io.File file)'
27
- def file_selected(file)
28
- puts file.get_absolute_path unless file.nil?
29
- end
30
- end
31
-
32
- SelectFile.new
@@ -1,40 +0,0 @@
1
- #!/usr/bin/env jruby -v -W2
2
-
3
- require 'propane'
4
-
5
- class SelectImage < Propane::App
6
-
7
- load_library :file_chooser
8
- ###########
9
- # Example Native File Chooser using vanilla processing
10
- # select_input, and file_selected
11
- ###########
12
- attr_reader :img
13
-
14
- def setup
15
- size(400, 200)
16
- fill 0, 0, 200
17
- text('Click Window to Load Image', 10, 100)
18
- end
19
-
20
- def draw
21
- image(img, 0, 0) unless img.nil?
22
- end
23
-
24
- def file_selected(selection)
25
- if selection.nil?
26
- puts 'Nothing Chosen'
27
- else
28
- @img = load_image(selection.get_absolute_path)
29
- img.resize(width, height)
30
- end
31
- end
32
-
33
- def mouse_clicked
34
- @img = nil
35
- # java_signature 'void selectInput(String, String)'
36
- select_input('Select Image File', 'file_selected')
37
- end
38
- end
39
-
40
- SelectImage.new
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env jruby -v -W2
2
- # frozen_string_literal: true
3
- # example usage of experimental slider library
4
- require 'propane'
5
-
6
- class SliderDemo < Propane::App
7
- load_library :slider
8
- attr_reader :color1, :color2, :color3, :r, :gs, :b, :back
9
-
10
- def setup
11
- size(600, 400)
12
- smooth(4)
13
- @back = true
14
- @r, @gs, @b = 0, 0, 0
15
- @color1 = Slider.slider(
16
- app: self,
17
- vertical: true,
18
- x: 100,
19
- y: 77,
20
- length: 200,
21
- range: (-125.0..125.0),
22
- name: 'Slider 1',
23
- inital_value: 10
24
- )
25
- @color2 = Slider.slider(
26
- app: self,
27
- vertical: true,
28
- x: 256,
29
- y: 77,
30
- length: 200,
31
- range: (0..255),
32
- name: 'Slider 2',
33
- initial_value: 180
34
- )
35
- @color3 = Slider.slider(
36
- app: self,
37
- vertical: true,
38
- x: 410,
39
- y: 77,
40
- length: 200,
41
- range: (0.0..255.0),
42
- name: 'Slider 3',
43
- initial_value: 134
44
- )
45
- color1.bar_width(100)
46
- color1.widget_colors(color('#930303'), color('#FF0000'))
47
- color2.bar_width(100)
48
- color2.widget_colors(color('#5BCE4D'), color('#1CFF00'))
49
- color3.bar_width(100)
50
- color3.widget_colors(color('#4439C9'), color('#9990FF'))
51
- end
52
-
53
- def draw
54
- background(r + 125, gs, b)
55
- @r = color1.read_value
56
- @gs = color2.read_value
57
- @b = color3.read_value
58
- end
59
- end
60
-
61
- SliderDemo.new(title: 'Slider Demo')
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env jruby -v -W2
2
- # frozen_string_literal: true
3
- require 'propane'
4
-
5
- # Simple slider example
6
- class SliderExample < Propane::App
7
- load_library :slider
8
- attr_reader :color1, :color2, :color3, :r, :gs, :b, :back
9
-
10
- def setup
11
- size(600, 400)
12
- smooth(4)
13
- @back = true
14
- @r, @gs, @b = 0, 0, 0
15
- @color1 = Slider.slider(
16
- app: self,
17
- x: 77,
18
- y: 200,
19
- length: 200,
20
- range: (0..255.0),
21
- name: 'Slider 1',
22
- initial_value: 50
23
- )
24
- @color2 = Slider.slider(
25
- app: self,
26
- x: 77,
27
- y: 230,
28
- length: 200,
29
- range: (0..255),
30
- name: 'Slider 2',
31
- initial_value: 50
32
- )
33
- @color3 = Slider.slider(
34
- app: self,
35
- x: 77,
36
- y: 260,
37
- length: 200,
38
- range: (0.0..255.0),
39
- name: 'Slider 3'
40
- )
41
- end
42
-
43
- def draw
44
- background(b, r, gs)
45
- fill(r, gs, b)
46
- ellipse(300, 200, 300, 300)
47
- @r = color1.read_value
48
- @gs = color2.read_value
49
- @b = color3.read_value
50
- end
51
- end
52
-
53
- SliderExample.new(title: 'Slider Example')
@@ -1,47 +0,0 @@
1
- #!/usr/bin/env jruby -v -W2
2
- # frozen_string_literal: true
3
- require 'propane'
4
-
5
- class SliderSimple < Propane::App
6
- load_library :slider
7
- attr_reader :color1, :color2, :color3, :r, :gs, :b, :back
8
-
9
- def setup
10
- size(600, 400)
11
- smooth(4)
12
- @back = true
13
- @r, @gs, @b = 0, 0, 0
14
- @color1 = Slider.slider(
15
- app: self,
16
- x: 77,
17
- y: 200,
18
- name: 'Slider 1',
19
- initial_value: 50
20
- )
21
- @color2 = Slider.slider(
22
- app: self,
23
- x: 77,
24
- y: 230,
25
- name: 'Slider 2',
26
- initial_value: 50
27
- )
28
- @color3 = Slider.slider(
29
- app: self,
30
- x: 77,
31
- y: 260,
32
- name: 'Slider 3'
33
- )
34
- color_mode(RGB, 100)
35
- end
36
-
37
- def draw
38
- background(b, r, gs)
39
- fill(r, gs, b)
40
- ellipse(300, 200, 300, 300)
41
- @r = color1.read_value
42
- @gs = color2.read_value
43
- @b = color3.read_value
44
- end
45
- end
46
-
47
- SliderSimple.new(title: 'Simple Slider')
@@ -1,76 +0,0 @@
1
- #!/usr/bin/env jruby -v -W2
2
- require 'propane'
3
-
4
- class Tree < Propane::App
5
- # http://processing.org/learning/topics/tree.html
6
- # by Joe Holt
7
- def setup
8
- size 200, 200
9
- color_mode RGB, 1
10
- frame_rate 30
11
- smooth
12
- @x = 0.0
13
- @dx = width / 100
14
- @start_time = Time.now
15
- @frame_time = nil
16
- end
17
-
18
- def draw
19
- t = Time.now
20
- if @frame_time
21
- fps = 1.0 / (t - @frame_time)
22
- # printf "%0.1f fps\n", fps
23
- end
24
- @frame_time = t
25
-
26
- background 0
27
- stroke 1, 1, 1
28
- # Let's pick an angle 0 to 90 degrees based on the mouse position
29
- a = (@x / width) * 90
30
- # Convert it to radians
31
- @theta = a.radians
32
- # Start the tree from the bottom of the screen
33
- translate(width / 2, height)
34
- # Draw a line 60 pixels
35
- h = height / 3
36
- line(0, 0, 0, -h)
37
- # Move to the end of that line
38
- translate(0, -h)
39
- # Start the recursive branching!
40
- branch(h)
41
-
42
- @x += @dx
43
- if @x < 0
44
- puts "Time after this iteration: " + (Time.now - @start_time).to_s
45
- end
46
- if @x > width || @x < 0
47
- @dx = - @dx
48
- @x += @dx * 2
49
- end
50
- end
51
-
52
- def branch(h)
53
- # Each branch will be 2/3rds the size of the previous one
54
- h *= 0.66
55
- # All recursive functions must have an exit condition!!!!
56
- # Here, ours is when the length of the branch is 2 pixels or less
57
- if h > 2
58
- push_matrix # Save the current state of transformation (i.e. where are we now)
59
- rotate(@theta) # Rotate by theta
60
- line(0, 0, 0, -h) # Draw the branch
61
- translate(0, -h) # Move to the end of the branch
62
- branch(h) # Ok, now call myself to draw two new branches!!
63
- pop_matrix # Whenever we get back here, we "pop" in order to restore the previous matrix state
64
-
65
- # Repeat the same thing, only branch off to the "left" this time!
66
- push_matrix
67
- rotate(-@theta)
68
- line(0, 0, 0, -h)
69
- translate(0, -h)
70
- branch(h)
71
- pop_matrix
72
- end
73
- end
74
- end
75
-
76
- Tree.new title: 'Tree'