Here is my blog in which I will describe my experiments with ruby-processing, find out more about ruby-processing at:- http://wiki.github.com/jashkenas/ruby-processing and http://github.com/jashkenas/context_free for the cfdg DSL (context-free-art)

Thursday, 5 May 2011

Exploring screenX in ruby processing

I think there is a mistake in the version at the processing wiki (which I have flagged) because the 2D lines mentioned in the comments have six parameters (in my book that is 3D line even if Z is zero). You still get to see the parallax in my amended version, try it.


###################
# processing screenX example
# in ruby processing
###################

def setup
  size 100, 100, P3D
end

def draw
  background 204
  
  x = mouse_x
  y = mouse_y
  z = -100
  
  # Draw "X" at z = -100
  stroke 255
  line(x - 10, y - 10, z, x + 10, y + 10, z)
  line(x + 10, y - 10, z, x - 10, y + 10, z)
  
  # Draw line in 2D at same x value
  # Notice the parallax
  stroke 102
  line(x, 0, x, height)
  
  # Draw 2D line to match the x value
  # element drawn at z = -100
  stroke(0)
  the_x = screen_x(x, y, z)
  line(the_x, 0, the_x, height)    
end

0 comments:

Post a Comment

Followers

Blog Archive

About Me

My Photo
Consolidating my online identity as monkstone. I am a 64 bit linux user and advocate of open source software, you can sometimes find me on the processing forum.