| # http://gist.github.com/615896 | |
| # http://tinyurl.com/learn-ruby-processing | |
| require 'drb' | |
| DRb.start_service() | |
| o = DRbObject.new(nil, ENV['DRB_URL'] || 'druby://192.168.136.162:9000') | |
| o.stroke 255, 0, 0 #Red outline | |
| o.fill 0, 0, 255 #Blue center | |
| o.ellipse 100, 50, 200, 400 #Tall oval | |
| o.rect 350, 100, 400, 200 #Wide rectangle | |
| o.line 0, 0, o.width, o.height #line across screen | |
| # http://processing.org/reference/ |
| #"gem install rubyonacid" first! | |
| require 'drb' | |
| DRb.start_service() | |
| o = DRbObject.new(nil, ENV['DRB_URL'] || 'druby://192.168.136.162:9000') | |
| require 'rubyonacid/factories/example' | |
| f = RubyOnAcid::ExampleFactory.new | |
| o.no_stroke | |
| max_x, max_y = o.width, o.height | |
| loop do | |
| o.fill( | |
| f.get(:red, :max => 255), | |
| f.get(:green, :max => 255), | |
| f.get(:blue, :max => 255), | |
| f.get(:alpha, :min => 50, :max => 200) | |
| ) | |
| x = f.get(:x, :max => max_x) | |
| y = f.get(:y, :max => max_y) | |
| width = f.get(:width, :max => 200) | |
| height = f.get(:height, :max => 200) | |
| case f.choose(:shape, :rectangle, :ellipse) | |
| when :rectangle | |
| o.rect_mode 3 #CENTER | |
| o.rect x, y, width, height | |
| when :ellipse | |
| o.ellipse_mode 3 #CENTER | |
| o.ellipse x, y, width, height | |
| end | |
| end |
| require 'drb' | |
| DRb.start_service() | |
| o = DRbObject.new(nil, ENV['DRB_URL'] || 'druby://192.168.136.162:9000') | |
| o.stroke 0 | |
| o.background 0 | |
| o.fill 50, 255, 100 | |
| o.translate 200, 200 | |
| o.rotate 3.14 / 5.0 | |
| o.rect 50, 50, 75, 100 | |
| o.smooth | |
| o.ellipse 40, 20, 16, 16 | |
| o.line 90, 150, 80, 160 | |
| o.text_font o.create_font "Courier", 72, true | |
| o.text "foo", 10, 100 | |
| puts "mouse_x: #{o.mouse_x}, mouse_y: #{o.mouse_y}, pmouse_x: #{o.pmouse_x}, pmouse_y: #{o.pmouse_y}" | |
| puts "width: #{o.width}, height: #{o.height}" | |
| puts "random(255): #{o.random(255)}" | |
| puts "constrain(300, 0, 255): #{o.constrain(300, 0, 255)}" | |
| puts "millis: #{o.millis}" |
| require "ruboto.rb" | |
| confirm_ruboto_version(4, false) | |
| java_import "org.ruboto.embedded.RubotoView" | |
| require 'drb' | |
| DRb.start_service | |
| $activity.start_ruboto_activity "$druby" do | |
| setup_content do | |
| @service = DRbObject.new(nil, "druby://192.168.136.162:9000") | |
| RubotoView.new($druby) | |
| end | |
| handle_touch_event do |event| | |
| @service.fill 50, 255, 100 | |
| @service.stroke 50, 255, 100 | |
| @service.ellipse event.get_x, event.get_y, 16, 16 | |
| end | |
| end |
| URL = 'druby://0.0.0.0:9000' | |
| class Sketch < Processing::App | |
| def setup | |
| # render_mode P3D | |
| require 'drb' | |
| class <<self | |
| %w{ | |
| clone | |
| define_singleton_method | |
| display | |
| dup | |
| extend | |
| freeze | |
| instance_eval | |
| instance_exec | |
| instance_variable_defined? | |
| instance_variable_get | |
| instance_variable_set | |
| instance_variables | |
| public_send | |
| remove_instance_variable | |
| send | |
| tap | |
| library_loaded? | |
| load_java_library | |
| load_libraries | |
| load_library | |
| load_ruby_library | |
| }.each do |method| | |
| if method_defined?(method.to_sym) | |
| undef_method(method.to_sym) | |
| end | |
| end | |
| end | |
| background 100 | |
| DRb.start_service(URL, self) | |
| end | |
| def draw | |
| end | |
| end | |
| Sketch.new(:width => 1024, :height => 710, :title => 'http://gist.github.com/615896', :full_screen => false) |
| require 'drb' | |
| require 'tk' | |
| DRb.start_service() | |
| o = DRbObject.new(nil, ENV['DRB_URL'] || 'druby://192.168.136.162:9000') | |
| width, height = o.width, o.height | |
| canvas = TkCanvas.new(:width => 640, :height => 480) | |
| canvas.pack | |
| canvas.bind( | |
| "B1-Motion", | |
| lambda { |x, y| | |
| o.ellipse( | |
| width * (x.to_f / canvas.width), | |
| height * (y.to_f / canvas.height), | |
| 50, 50 | |
| ) | |
| }, | |
| "%x %y" | |
| ) | |
| Tk.mainloop |
This comment has been minimized.
This comment has been minimized.
|
Whoops! Right you are. Updated! |
This comment has been minimized.
This comment has been minimized.
|
Back to indra-mtn-rb IP address. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
it should be a 10.0.something.something address