For my 3D context free application/library, I would like to be able to zoom using the mouse wheel, I had vaguely thought about using peasycam or proscene to provide that, and other functionality. In the first instance I wanted to create it myself. After a bit of research, this the sort of implementation I would do using the java classes/interfaces in ruby:-
# mouse_listener.rb
class JWheelListener
include java.awt.event.MouseWheelListener
attr_reader :zoom
def initialize(zoom)
@zoom = zoom
end
def mouse_wheel_moved(e)
@zoom += e.get_wheel_rotation * 10
end
end
class Mouse < Processing::App
attr_reader :wheel
def setup
size(1000, 1000)
@wheel = JWheelListener.new(10)
self.add_mouse_wheel_listener(@wheel)
end
def draw
background 0
fill 255, 0, 0
ellipse(width/2, height/2, wheel.zoom, wheel.zoom)
end
end
Mouse.new :title => "Mouse Wheel Listener"
Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0
Sunday, 12 September 2010
Subscribe to:
Post Comments (Atom)
Followers
Blog Archive
-
▼
2010
(73)
-
▼
September
(15)
- Basic Hair Example SunflowAPIAPI just using jruby
- Basic Hair Example SunflowAPIAPI in ruby processing
- SunflowAPIAPI in ruby processing
- A Staffordshire Knot Using Ruby Processing and A C...
- An Infinity Loop? With My 3D Context Free Library
- Revised 3D Context Free DSL Sketch, with Mouse Whe...
- A Mouse Wheel Listener in Ruby Processing
- 3D Context Free DSL Screen Saver?
- Translating the default.es to ruby processing DSL
- Testing the cube primitive in my context free DSL
- Experimental 3D Context Free DSL in ruby-processin...
- Using the control panel and Toxi Processing Libra...
- Tone map example of Gray-Scott diffusion using tox...
- Another Example of Using Toxi Processing Libraries
- Using the Toxi Processing Libraries in ruby proces...
-
▼
September
(15)
About Me
- monkstone
- I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2
No comments:
Post a Comment