propane 0.3.0.pre-java → 0.4.0.pre-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d427bc8bff6a2ecdae40c103234be639ce4f78db
4
- data.tar.gz: 84d89e9ff7e3d14aebd3daa2eccf80e62be05bbd
3
+ metadata.gz: 8be45e7e7dceb0061a4af4af3044de8e277d0ace
4
+ data.tar.gz: d9477ff46ea8cac2ed39cf486d7a9556a9312aae
5
5
  SHA512:
6
- metadata.gz: 647c0f4a7f69ecd471205ecdba116d99b012f201ca705a1cef5c9660f5f23e920688e5b61603da4012f0af3a0b1f5e6a07b4a4b8e914b3f93fc8f64e21f6735c
7
- data.tar.gz: 3315621182cb97955f3d9cbd6c88bc7d3ae0f4f67679fe7f83b6e774facf09ef6959ad01653c0488d5d8732f9e1c16ebddb514a41aba731c2cd673ea1410d68a
6
+ metadata.gz: b5e216855d9d126045ae5d2ec0eb0962bd83861c58d1c1cbe740f56bcf43a192bdb6464bfcbfc811e340a7dcb47c304cf69db5e21fded92c094d5f06f0a789a0
7
+ data.tar.gz: 4e514eb57e7fbf78bb861d4e156063fe2a85f39ab21f4a348b02da0e6e56edbe225c61792179de7c05b0c56d608b6bb702ef6947714d6a0225be89d4dab48263
@@ -0,0 +1,33 @@
1
+ ## Contributing
2
+ In the spirit of [free software][free-sw], **everyone** is encouraged to help improve this project.
3
+
4
+ Here are some ways *you* can contribute:
5
+
6
+ * by reporting bugs
7
+ * by suggesting/implementing new features
8
+ * by writing or editing documentation ( _expert Windows users could help write install instructions_ )
9
+ * by contributing examples ( _show your creativity, or translate someone elses masterpiece_ )
10
+ * by refactoring examples to be more rubyfied
11
+ * by closing [issues][]
12
+ * by proselytizing Propane, we need more champions
13
+ * by supporting [Processing.org][], nothing to do with us but we rely on them
14
+ * by creating gems for pdf, video library etc see arcball gem as example
15
+
16
+ ## Submitting an Issue
17
+ We use the [GitHub issue tracker][issues] to track bugs and features. Before
18
+ submitting a bug report or feature request, check to make sure it hasn't
19
+ already been submitted. When submitting a bug report, ideally include a [Gist][]
20
+ that includes a stack trace and any details that may be necessary to reproduce
21
+ the bug, including your gem version, Ruby version, and operating system.
22
+
23
+
24
+ ## Submitting a Pull Request
25
+ 1. [Fork the repository.][fork]
26
+ 2. [Submit a pull request.][pr]
27
+
28
+ [free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
29
+ [issues]: https://github.com/monkstone/Propane/issues
30
+ [gist]: https://gist.github.com/
31
+ [fork]: http://help.github.com/fork-a-repo/
32
+ [pr]: http://help.github.com/send-pull-requests/
33
+ [processing.org]: http://processing.org/foundation/
@@ -0,0 +1,27 @@
1
+ <!--
2
+ This is a simple template for filing Propane issues.
3
+
4
+ Please help us help you by providing the information below.
5
+
6
+ Text inside XML comment tags will not be shown in your report.
7
+ -->
8
+
9
+ ### Environment
10
+
11
+ Ensure that you are using the recommended versions of jruby (`jruby -v`) and java (`java -version`)
12
+ Provide Propane version that you are using (`propane --version`)
13
+ Provide your operating system and platform (e.g. `uname -a`, and/or `java -version` output if relevant)
14
+
15
+ ### Expected Behavior
16
+
17
+ Describe your expectation of how Propane sketch should behave.
18
+ Provide a `problematic` Propane sketch or a link to an example repository.
19
+
20
+ ### Actual Behavior
21
+
22
+ Describe or show the actual behavior.
23
+ Provide text or screen capture showing the behavior.
24
+
25
+ ### Other
26
+
27
+ eg installation issue (just use this header and explain the problem as best you can)
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+
2
+ **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 welocme to extens to windows (should be easy).
3
+
4
+ **v0.3.0.pre** First pre-release of propane.gem turns out 3D was not working because of missing jar in gem (3D was only going to work on macosx and linux64 OS anyways.
5
+
data/Gemfile CHANGED
@@ -1,4 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- gemspec
3
- gem 'rspec'
4
- gem 'rake'
2
+
data/README.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Propane
2
+ [![Gem Version](https://badge.fury.io/rb/propane.svg)](https://badge.fury.io/rb/propane)
2
3
 
3
- A really 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 a gem distribution, and hence we should not require configuration. This would is mainly scriptable version ie files get run direct from jruby. For certain sketches we need to call jruby via jruby-complete for this we have created an executable `propane` that can used to install `jruby-complete` and run sketches (maybe export?, possibly watch).
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
+ ## Requirements
6
+
7
+ - jdk7+
8
+ - jruby-9.0.5.0+
9
+ - mvn-3.3.1+ (development only)
4
10
 
5
11
  ## Building and testing
6
12
 
@@ -60,10 +66,3 @@ To run sketches using the installed jruby-complete
60
66
  propane --run my_sketch.rb # or
61
67
  jruby -S propane --run my_sketch.rb # belt and braces version
62
68
  ```
63
- ## Contributing
64
-
65
- 1. Fork it
66
- 2. Create your feature branch (`git checkout -b my-new-feature`)
67
- 3. Commit your changes (`git commit -am 'Add some feature'`)
68
- 4. Push to the branch (`git push origin my-new-feature`)
69
- 5. Create new Pull Request
data/Rakefile CHANGED
@@ -8,6 +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
12
  end
12
13
  end
13
14
 
@@ -7,7 +7,7 @@ require 'arcball'
7
7
  # to constrain rotation axis.
8
8
  ############################
9
9
 
10
- require_relative '../../lib/propane' # temporary local
10
+ require 'propane' # temporary local
11
11
 
12
12
  # Include processing opengl classes that we'd like to use:
13
13
  %w(PGL PGraphics3D PGraphicsOpenGL PShapeOpenGL Texture).each do |klass|
@@ -0,0 +1,118 @@
1
+ require 'propane'
2
+
3
+
4
+ # Based on http://processing.org/learning/topics/circlecollision.html
5
+ class CircleCollision < Propane::App
6
+ attr_reader :balls
7
+
8
+ def setup
9
+ size 640, 360
10
+ @balls = [Ball.new(100, 40, 20), Ball.new(200, 100, 80)]
11
+ end
12
+
13
+ def draw
14
+ background(51)
15
+ balls.each do |b|
16
+ b.update
17
+ b.display
18
+ b.check_boundary width, height
19
+ end
20
+ balls[0].check_collision(balls[1])
21
+ end
22
+ end
23
+
24
+ # The Ball class knows how to behave, their is a case for a separate boundary class
25
+ class Ball
26
+ include Propane::Proxy, Math
27
+ attr_accessor :position, :r, :m, :velocity
28
+
29
+ def initialize(x = 0.0, y = 0.0, r = 0.0)
30
+ @position = Vec2D.new(x, y)
31
+ @r = r
32
+ @m = r * 0.1
33
+ @velocity = Vec2D.new(rand(-3.0..3), rand(-3.0..3))
34
+ end
35
+
36
+ def update
37
+ @position += velocity
38
+ end
39
+
40
+ def check_boundary(width, height)
41
+ unless (r..width - r).include?(position.x)
42
+ (position.x > width - r) ? position.x = width - r : position.x = r
43
+ velocity.x *= -1
44
+ end
45
+ return if (r..height - r).include?(position.y)
46
+ (position.y > height - r) ? position.y = height - r : position.y = r
47
+ velocity.y *= -1
48
+ end
49
+
50
+ def check_collision(other_ball)
51
+ # get distances between the balls components
52
+ difference = other_ball.position - position
53
+ # calculate magnitude of the vector separating the balls
54
+ return unless difference.mag < (r + other_ball.r)
55
+ # get angle of difference
56
+ theta = difference.heading
57
+ # precalculate trig values
58
+ sine = sin(theta)
59
+ cosine = cos(theta)
60
+ # ball_array will hold rotated ball positions. You just
61
+ # need to worry about ball_array[1] position
62
+ ball_array = [Ball.new, Ball.new]
63
+ # other_ball's position is relative to ball's
64
+ # so you can use the vector between them (difference) as the
65
+ # reference point in the rotation expressions.
66
+ # ball_array[0].x and ball_array[0].y will initialize
67
+ # automatically to 0.0, which is what you want
68
+ # since other_ball will rotate around ball
69
+ ball_array[1].position.x = cosine * difference.x + sine * difference.y
70
+ ball_array[1].position.y = cosine * difference.y - sine * difference.x
71
+ # rotate Temporary velocities
72
+ velocity_array = [Vec2D.new, Vec2D.new]
73
+ velocity_array[0].x = cosine * velocity.x + sine * velocity.y
74
+ velocity_array[0].y = cosine * velocity.y - sine * velocity.x
75
+ velocity_array[1].x = cosine * other_ball.velocity.x + sine * other_ball.velocity.y
76
+ velocity_array[1].y = cosine * other_ball.velocity.y - sine * other_ball.velocity.x
77
+ # Now that velocities are rotated, you can use 1D
78
+ # conservation of momentum equations to calculate
79
+ # the final velocity along the x-axis.
80
+ final_velocities = [Vec2D.new, Vec2D.new]
81
+ # final rotated velocity for ball
82
+ final_velocities[0].x = ((m - other_ball.m) * velocity_array[0].x + 2 * other_ball.m * velocity_array[1].x) / (m + other_ball.m)
83
+ final_velocities[0].y = velocity_array[0].y
84
+ # final rotated velocity for ball
85
+ final_velocities[1].x = ((other_ball.m - m) * velocity_array[1].x + 2 * m * velocity_array[0].x) / (m + other_ball.m)
86
+ final_velocities[1].y = velocity_array[1].y
87
+ # HACK: to avoid clumping
88
+ # ball_array[0].position.x += final_velocities[0].x
89
+ # ball_array[1].position.x += final_velocities[1].x
90
+ # Rotate ball positions and velocities back
91
+ # Reverse signs in trig expressions to rotate
92
+ # in the opposite direction
93
+ # rotate balls
94
+ final_positions = [Vec2D.new, Vec2D.new]
95
+ final_positions[0].x = cosine * ball_array[0].position.x - sine * ball_array[0].position.y
96
+ final_positions[0].y = cosine * ball_array[0].position.y + sine * ball_array[0].position.x
97
+ final_positions[1].x = cosine * ball_array[1].position.x - sine * ball_array[1].position.y
98
+ final_positions[1].y = cosine * ball_array[1].position.y + sine * ball_array[1].position.x
99
+ # update balls to screen position
100
+ other_ball.position = position + final_positions[1]
101
+ @position += final_positions[0]
102
+ # update velocities
103
+ velocity.x = cosine * final_velocities[0].x - sine * final_velocities[0].y
104
+ velocity.y = cosine * final_velocities[0].y + sine * final_velocities[0].x
105
+ other_ball.velocity.x = cosine * final_velocities[1].x - sine * final_velocities[1].y
106
+ other_ball.velocity.y = cosine * final_velocities[1].y + sine * final_velocities[1].x
107
+ end
108
+
109
+ def display
110
+ no_stroke
111
+ fill(204)
112
+ ellipse(position.x, position.y, r * 2, r * 2)
113
+ end
114
+ end
115
+
116
+
117
+
118
+ CircleCollision.new title: 'Circle Collision'
@@ -0,0 +1,92 @@
1
+ require 'propane'
2
+
3
+ # Example to show how to use the VecMath library.
4
+ # ruby replacement for PVector. Also features
5
+ # the use each_cons, possibly a rare use for this
6
+ # ruby Enumerable method?
7
+ # 2010-03-22 - fjenett (last revised by monkstone 2016-03-26)
8
+ # now uses 'zip' and 'each', in place of a custom Array object
9
+ # with a 'one_of_each' method
10
+ # Drawolver: draw 2D & revolve 3D
11
+ class Drawolver < Propane::App
12
+ attr_reader :drawing_mode, :points, :rot_x, :rot_y, :vertices
13
+
14
+ def setup
15
+ size 1024, 768, P3D
16
+ frame_rate 30
17
+ reset_scene
18
+ end
19
+
20
+ def draw
21
+ background 0
22
+ unless drawing_mode
23
+ translate(width / 2, height / 2)
24
+ rotate_x rot_x
25
+ rotate_y rot_y
26
+ @rot_x += 0.01
27
+ @rot_y += 0.02
28
+ translate(-width / 2, -height / 2)
29
+ end
30
+ no_fill
31
+ stroke 255
32
+ points.each_cons(2) { |ps, pe| line ps.x, ps.y, pe.x, pe.y }
33
+ return if drawing_mode
34
+ stroke 125
35
+ fill 120
36
+ lights
37
+ ambient_light 120, 120, 120
38
+ vertices.each_cons(2) do |r1, r2|
39
+ begin_shape(TRIANGLE_STRIP)
40
+ r1.zip(r2).each do |v1, v2|
41
+ vertex v1.x, v1.y, v1.z
42
+ vertex v2.x, v2.y, v2.z
43
+ end
44
+ end_shape
45
+ end
46
+ end
47
+
48
+ def reset_scene
49
+ @drawing_mode = true
50
+ @points = []
51
+ @rot_x = 0.0
52
+ @rot_y = 0.0
53
+ end
54
+
55
+ def mouse_pressed
56
+ reset_scene
57
+ points << Vec3D.new(mouse_x, mouse_y)
58
+ end
59
+
60
+ def mouse_dragged
61
+ points << Vec3D.new(mouse_x, mouse_y)
62
+ end
63
+
64
+ def mouse_released
65
+ points << Vec3D.new(mouse_x, mouse_y)
66
+ recalculate_shape
67
+ end
68
+
69
+ def recalculate_shape
70
+ @vertices = []
71
+ points.each_cons(2) do |ps, _pe|
72
+ b = points.last - points.first
73
+ # len = b.mag
74
+ b.normalize!
75
+ a = ps - points.first
76
+ dot = a.dot b
77
+ b *= dot
78
+ normal = points.first + b
79
+ c = ps - normal
80
+ # nlen = c.mag
81
+ vertices << []
82
+ (0..TAU).step(PI / 15) do |ang|
83
+ e = normal + c * cos(ang)
84
+ e.z = c.mag * sin(ang)
85
+ vertices.last << e
86
+ end
87
+ end
88
+ @drawing_mode = false
89
+ end
90
+ end
91
+
92
+ Drawolver.new title: 'Drawolver'
@@ -0,0 +1,79 @@
1
+ # Empathy
2
+ # original by Kyle McDonald
3
+ # http://www.openprocessing.org/visuals/?visualID=1182
4
+
5
+ # This sketch takes advantage of multiple processors by running calculations
6
+ # in a separate thread.
7
+ require 'propane'
8
+
9
+ CELL_COUNT = 5_000
10
+ SLOW_DOWN = 0.97
11
+ ROTATION = 0.004
12
+ LINE_LENGTH = 37
13
+
14
+ class Empathy < Propane::App
15
+
16
+ attr_reader :cells
17
+
18
+ def setup
19
+ size(500, 500)
20
+ stroke(0, 0, 0, 25)
21
+ @cells = create_cells(CELL_COUNT)
22
+ start_cell_updates
23
+ end
24
+
25
+ def create_cells(n)
26
+ (0..n).map do |i|
27
+ a = i + rand(PI / 9.0)
28
+ r = ((i / n.to_f) * (width / 2) * (((n - i) / n.to_f) * 3.3)) + rand(6.0)
29
+ Cell.new((r * cos(a) + width / 2).to_i, (r * sin(a) + height / 2).to_i)
30
+ end
31
+ end
32
+
33
+ def start_cell_updates
34
+ Thread.new { Kernel.loop { cells.each(&:update) } }
35
+ end
36
+
37
+ def draw
38
+ background 255
39
+ cells.each(&:draw_line) if started?
40
+ end
41
+
42
+ def started?
43
+ pmouse_x != 0 || pmouse_y != 0
44
+ end
45
+
46
+ def mouse_pressed
47
+ cells.each(&:reset)
48
+ end
49
+ end
50
+
51
+ ##
52
+ # The cell responds to mouse movement
53
+ ##
54
+ class Cell
55
+ include Propane::Proxy, Math
56
+ attr_reader :x, :y, :spin, :angle
57
+ def initialize(x, y)
58
+ @x, @y = x, y
59
+ reset
60
+ end
61
+
62
+ def reset
63
+ @spin, @angle = 0, 0
64
+ end
65
+
66
+ def update
67
+ det = ((pmouse_x - x) * (mouse_y - y) - (mouse_x - x) * (pmouse_y - y))
68
+ @spin += ROTATION * det.to_f / dist(x, y, mouse_x, mouse_y)
69
+ @spin *= SLOW_DOWN
70
+ @angle += spin
71
+ end
72
+
73
+ def draw_line
74
+ d = LINE_LENGTH * spin + 0.001
75
+ line(x, y, x + d * cos(angle), y + d * sin(angle))
76
+ end
77
+ end
78
+
79
+ Empathy.new(title: 'Empathy')
@@ -0,0 +1,56 @@
1
+ require 'propane'
2
+
3
+ class Fern < Propane::App
4
+ # The Fern Fractal
5
+ # by Luis Correia
6
+
7
+ attr_reader :bnds
8
+
9
+ def setup
10
+ size 500, 500
11
+ @bnds = Boundary.new(0, width)
12
+ no_loop
13
+ puts 'Be patient. This takes about 10 seconds to render.'
14
+ end
15
+
16
+ def draw
17
+ background 0
18
+ load_pixels
19
+ x0, y0 = 0.0, 0.0
20
+ x, y, r = 0.0, 0.0, 0.0
21
+ i, j = 0, 0
22
+ max_iterations = 200_000
23
+ max_iterations.times do
24
+ r = rand(0..100.0)
25
+ if r <= 1
26
+ x = 0.0
27
+ y = 0.16 * y0
28
+ elsif r <= 7
29
+ x = 0.2 * x0 - 0.26 * y0
30
+ y = 0.23 * x0 + 0.22 * y0
31
+ elsif r <= 14
32
+ x = -0.15 * x0 + 0.28 * y0
33
+ y = 0.26 * x0 + 0.24 * y0
34
+ else
35
+ x = 0.85 * x0 + 0.04 * y0
36
+ y = -0.004 * x0 + 0.85 * y0 + 1.6
37
+ end
38
+ i = height - (y * 45).to_i
39
+ j = width / 2 + (x * 45).to_i
40
+ pixels[i * height + j] += 2_560 if bnds.include?(i) && bnds.include?(j)
41
+ x0, y0 = x, y
42
+ end
43
+ update_pixels
44
+ end
45
+ end
46
+ # Abstract bnds checking to this
47
+ # lightweight class
48
+ #
49
+
50
+ Boundary = Struct.new(:lower, :upper) do
51
+ def include?(x)
52
+ (lower...upper).cover? x
53
+ end
54
+ end
55
+
56
+ Fern.new title: 'Fern'
@@ -0,0 +1,31 @@
1
+ # fractions.rb, by Martin Prout
2
+ require 'propane'
3
+
4
+ class Fractions < Propane::App
5
+ attr_reader :f, :add, :subtract, :multiply
6
+
7
+ def setup
8
+ size 640, 250
9
+ @f = createFont('Arial', 24, true)
10
+ third = 1 / 3r # since ruby 2.1.0 (and jruby-9.0.0.0)
11
+ quarter = 1 / 4r
12
+ format_add = '%s + %s = %s'
13
+ format_sub = format_add.gsub('+', '-')
14
+ format_mult = format_add.gsub('+', '*')
15
+ @add = format(format_add, third, quarter, third + quarter)
16
+ @subtract = format(format_sub, third, quarter, third - quarter)
17
+ @multiply = format(format_mult, third, quarter, third * quarter)
18
+ end
19
+
20
+ def draw
21
+ background 10
22
+ text_font(f, 24)
23
+ fill(220)
24
+ text('Math Blackboard Propane', 80, 50)
25
+ text(add, 110, 100)
26
+ text(subtract, 110, 150)
27
+ text(multiply, 110, 200)
28
+ end
29
+ end
30
+
31
+ Fractions.new(title: 'Fraction Sums')
@@ -0,0 +1,54 @@
1
+ require 'forwardable'
2
+
3
+ module Runnable
4
+ def run
5
+ reject!(&:dead?)
6
+ each(&:display)
7
+ end
8
+ end
9
+
10
+ class RainDrops
11
+ include Enumerable, Runnable
12
+ extend Forwardable
13
+
14
+ def_delegators(:@drops, :<<, :each, :reject!, :size)
15
+
16
+ attr_reader :drops, :width, :height #, :weight
17
+
18
+ def initialize(width, height)
19
+ @drops = []
20
+ @width = width
21
+ @height = height
22
+ end
23
+
24
+ def fill_up(weight)
25
+ # @weight = weight
26
+ drops << Drop.new(rand(width), rand(height / 2) - height / 2, weight)
27
+ end
28
+ end
29
+
30
+ class Drop
31
+ include Propane::Proxy
32
+ attr_reader :weight, :x, :y
33
+
34
+ def initialize(x, y, weight = nil)
35
+ @weight = weight || 10
36
+ @x, @y = x, y
37
+ end
38
+
39
+ def render
40
+ fill(100, 100, 200)
41
+ no_stroke
42
+ bezier(x, y, x - (weight / 2), y + weight, x + (weight / 2), y + weight, x, y)
43
+ end
44
+
45
+ def dead?
46
+ @y > height
47
+ end
48
+
49
+ def display
50
+ @y = y + weight
51
+ @x = x - rand(-3..3)
52
+ render
53
+ end
54
+ end
@@ -0,0 +1,59 @@
1
+ require 'propane'
2
+ require_relative 'lib/rain_drops'
3
+
4
+ class Raining < Propane::App
5
+ # raining after Rain1 by Thomas R. 'TomK32' Koll
6
+ #
7
+ # draws raindrops as bezier shapes and moves them downwards
8
+ #
9
+ # available key commands:
10
+ # + make raindrops heavier/bigger
11
+ # - make raindrops smaller
12
+ # a more raindrops
13
+ # s less raindrops
14
+ # <SPACE>
15
+ #
16
+ # License: Same as processing
17
+ #
18
+
19
+ attr_reader :drops, :weight, :drops_size, :paused
20
+
21
+ def setup
22
+ size 640, 480
23
+ frame_rate 30
24
+ @drops_size = 20
25
+ @weight = 20
26
+ @drops = RainDrops.new width, height
27
+ @paused = false
28
+ font = create_font('Georgia', 15)
29
+ text_font(font)
30
+ end
31
+
32
+ def draw
33
+ return if paused
34
+ # we fill up with new drops randomly
35
+ drops.fill_up(weight) while rand(drops_size / 3) < (drops_size - drops.size)
36
+ # the less drops the darker it is
37
+ background 127 + 127 * (drops.size / drops_size.to_f)
38
+ drops.run
39
+ form = '%d of %d drops with a size of %d'
40
+ text(format(form, drops.size, drops_size, weight), 10, 20)
41
+ end
42
+
43
+ def key_pressed
44
+ case key
45
+ when '+'
46
+ @weight += 5
47
+ when '-'
48
+ @weight -= 5 if weight > 10
49
+ when 'a'
50
+ @drops_size += 5
51
+ when 's'
52
+ @drops_size -= 5 if drops_size > 5
53
+ when ' '
54
+ @paused = !paused
55
+ end
56
+ end
57
+ end
58
+
59
+ Raining.new title: 'Raining'
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
  module Propane
4
- VERSION = '0.3.0.pre'.freeze
4
+ VERSION = '0.4.0.pre'.freeze
5
5
  end
data/pom.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'fileutils'
2
2
  project 'rp5extras', 'https://github.com/monkstone/propane' do
3
3
  model_version '4.0.0'
4
- id 'propane:rp5extras', '0.3.0'
4
+ id 'propane:rp5extras', '0.4.0.pre'
5
5
  packaging 'jar'
6
6
  description 'rp5extras for propane'
7
7
  organization 'ruby-processing', 'https://ruby-processing.github.io'
data/pom.xml CHANGED
@@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE
11
11
  <modelVersion>4.0.0</modelVersion>
12
12
  <groupId>propane</groupId>
13
13
  <artifactId>rp5extras</artifactId>
14
- <version>0.3.0</version>
14
+ <version>0.4.0.pre</version>
15
15
  <name>rp5extras</name>
16
16
  <description>rp5extras for propane</description>
17
17
  <url>https://github.com/monkstone/propane</url>
data/propane.gemspec CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.files << 'lib/rpextras.jar'
17
17
  gem.files << 'lib/core-2.2.1.jar'
18
18
  gem.files << 'lib/gluegen-rt-2.1.5-01.jar'
19
+ gem.files << 'lib/jogl-all-2.1.5-01.jar'
19
20
  gem.files << 'lib/gluegen-rt-2.1.5-01-natives-linux-amd64.jar'
20
21
  gem.files << 'lib/gluegen-rt-2.1.5-01-natives-macosx-universal.jar'
21
22
  gem.files << 'lib/jogl-all-2.1.5-01-natives-linux-amd64.jar'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: propane
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0.pre
4
+ version: 0.4.0.pre
5
5
  platform: java
6
6
  authors:
7
7
  - filib
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-21 00:00:00.000000000 Z
12
+ date: 2016-03-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: arcball
@@ -33,10 +33,13 @@ executables:
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
+ - ".github/CONTRIBUTING.md"
37
+ - ".github/ISSUE_TEMPLATE.md"
36
38
  - ".gitignore"
37
39
  - ".mvn/extensions.xml"
38
40
  - ".mvn/wrapper/maven-wrapper.properties"
39
41
  - ".travis.yml"
42
+ - CHANGELOG.md
40
43
  - Gemfile
41
44
  - LICENSE.txt
42
45
  - README.md
@@ -53,18 +56,25 @@ files:
53
56
  - examples/complete/kinetic_type.rb
54
57
  - examples/regular/Rakefile
55
58
  - examples/regular/arcball_box.rb
59
+ - examples/regular/circle_collision.rb
56
60
  - examples/regular/creating_colors.rb
61
+ - examples/regular/drawolver.rb
57
62
  - examples/regular/elegant_ball.rb
63
+ - examples/regular/empathy.rb
64
+ - examples/regular/fern.rb
58
65
  - examples/regular/flight_patterns.rb
66
+ - examples/regular/fractions.rb
59
67
  - examples/regular/grey_circles.rb
60
68
  - examples/regular/jwishy.rb
61
69
  - examples/regular/letters.rb
62
70
  - examples/regular/lib/boundary.rb
63
71
  - examples/regular/lib/particle.rb
64
72
  - examples/regular/lib/particle_system.rb
73
+ - examples/regular/lib/rain_drops.rb
65
74
  - examples/regular/liquidy.rb
66
75
  - examples/regular/mouse_button_demo.rb
67
76
  - examples/regular/polyhedrons.rb
77
+ - examples/regular/raining.rb
68
78
  - examples/regular/ribbon_doodle.rb
69
79
  - examples/regular/vector_math.rb
70
80
  - examples/regular/words.rb
@@ -76,6 +86,7 @@ files:
76
86
  - lib/gluegen-rt-2.1.5-01.jar
77
87
  - lib/jogl-all-2.1.5-01-natives-linux-amd64.jar
78
88
  - lib/jogl-all-2.1.5-01-natives-macosx-universal.jar
89
+ - lib/jogl-all-2.1.5-01.jar
79
90
  - lib/propane.rb
80
91
  - lib/propane/app.rb
81
92
  - lib/propane/helper_methods.rb