Last active
December 15, 2015 22:59
-
-
Save alexdean/5337168 to your computer and use it in GitHub Desktop.
fisica + ruby-processing bubble test demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ java -version | |
java version "1.6.0_43" | |
Java(TM) SE Runtime Environment (build 1.6.0_43-b01-447-11M4203) | |
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01-447, mixed mode) | |
$ rp5 run bubbles.rb | |
RUBY_VERSION: 1.9.3 | |
RUBY_PLATFORM: java | |
JRUBY_VERSION: 1.7.3 | |
JRUBY_REVISION: dac429b | |
FPoly fill methods ========== | |
[:set_no_fill, :setFillColor, :fill_color=, :fillColor=, :setNoFill, :set_fill_color] | |
FBlob fill methods ========== | |
[:set_no_fill, :setFillColor, :fill_color=, :fillColor=, :setNoFill, :set_fill_color] | |
Java::OrgJrubyExceptions::RaiseException | |
(NoMethodError) undefined method `set_fill' for #<Java::Fisica::FPoly:0x47fbad7> | |
RUBY.setup(bubbles.rb:51) | |
$ rp5 run --jruby bubbles.rb | |
RUBY_VERSION: 1.9.3 | |
RUBY_PLATFORM: java | |
JRUBY_VERSION: 1.7.3 | |
JRUBY_REVISION: dac429b | |
FPoly fill methods ========== | |
[:get_fill_color, :fill_color, :fill=, :applet_fill, :fillColor=, :setNoFill, :set_fill, :applet_fill_stroke, :set_fill_color, :getFillColor, :setFill, :set_no_fill, :setFillColor, :appletFillStroke, :appletFill, :fill_color=, :fillColor] | |
FBlob fill methods ========== | |
[:get_fill_color, :fill_color, :fill=, :applet_fill, :fillColor=, :setNoFill, :set_fill, :applet_fill_stroke, :set_fill_color, :getFillColor, :setFill, :set_no_fill, :setFillColor, :appletFillStroke, :appletFill, :fill_color=, :fillColor] | |
bubbles.rb:71 warning: ambiguous Java methods found, using fill(int) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Buttons and bodies | |
# | |
# by Ricard Marxer | |
# | |
# This example shows how to create a blob. | |
# | |
load_library :fisica | |
include_package 'fisica' | |
CIRCLE_COUNT = 20 | |
HOLE = 50 | |
TOP_MARGIN = 50 | |
BOTTOM_MARGIN = 300 | |
SIDE_MARGIN = 100 | |
attr_reader :world, :x_pos | |
def setup | |
size(400, 400) | |
smooth | |
@x_pos = 0 | |
Fisica.init(self) | |
puts "RUBY_VERSION: #{RUBY_VERSION}" | |
puts "RUBY_PLATFORM: #{RUBY_PLATFORM}" | |
puts "JRUBY_VERSION: #{JRUBY_VERSION}" | |
puts "JRUBY_REVISION: #{JRUBY_REVISION}" | |
puts | |
puts "FPoly fill methods ==========" | |
puts FBlob.instance_methods.select {|m| m.match /fill/i }.inspect | |
puts "FBlob fill methods ==========" | |
puts FBlob.instance_methods.select {|m| m.match /fill/i }.inspect | |
@world = FWorld.new | |
world.setGravity(0, -300) | |
l = FPoly.new | |
l.vertex(width/2-HOLE/2, 0) | |
l.vertex(0, 0) | |
l.vertex(0, height) | |
l.vertex(0 + SIDE_MARGIN, height) | |
l.vertex(0 + SIDE_MARGIN, height-BOTTOM_MARGIN) | |
l.vertex(width/2-HOLE/2, TOP_MARGIN) | |
l.set_static(true) | |
l.set_fill(0) | |
l.set_friction(0) | |
world.add(l) | |
r = FPoly.new | |
r.vertex(width/2 + HOLE/2, 0) | |
r.vertex(width, 0) | |
r.vertex(width, height) | |
r.vertex(width-SIDE_MARGIN, height) | |
r.vertex(width-SIDE_MARGIN, height-BOTTOM_MARGIN) | |
r.vertex(width/2 + HOLE/2, TOP_MARGIN) | |
r.set_static(true) | |
r.set_fill(0) | |
r.set_friction(0) | |
world.add(r) | |
end | |
def draw | |
background(80, 120, 200) | |
fill(0) | |
if ((frame_count % 40) == 1) | |
b = FBlob.new | |
s = rand(30 .. 40) | |
space = (width - SIDE_MARGIN * 2-s) | |
@x_pos = (x_pos + rand(s .. space/2.0)) % space | |
b.set_as_circle(SIDE_MARGIN + x_pos + s / 2, height - rand(100), s, 20) | |
b.set_stroke(0) | |
b.set_stroke_weight(2) | |
b.set_fill(255) | |
b.set_friction(0) | |
world.add(b) | |
end | |
world.step | |
world.draw | |
end | |
def key_pressed | |
save_frame("screenshot.png") | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment