Sha256: 60fba3aad5b653f19f26318377f6ab4108fc0f96a823b201e5eab75831ac1982

Contents?: true

Size: 730 Bytes

Versions: 10

Compression:

Stored size: 730 Bytes

Contents

# Arm. 
# 
# The angle of each segment is controlled with the mouseX and
# mouseY position. The transformations applied to the first segment
# are also applied to the second segment because they are inside
# the same push_matrix and pop_matrix group.

def setup    
  size 640, 360    
  @x, @y = width * 0.3, height * 0.5
  @angle1, @angle2 = 0.0, 0.0
  @seg_length = 100
  stroke_weight 30
  stroke 255, 160
end

def draw    
  background 0  	
  @angle1 = (mouse_x / width.to_f - 0.5) * -PI
  @angle2 = (mouse_y / height.to_f - 0.5) * PI  	
  push_matrix  	
  segment @x, @y, @angle1
  segment @seg_length, 0, @angle2
  pop_matrix
end

def segment ( x, y, a )  	
  translate x, y
  rotate a  	
  line 0, 0, @seg_length, 0 
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/basics/transform/arm.rb
ruby-processing-2.6.2 samples/processing_app/basics/transform/arm.rb
ruby-processing-2.6.1 samples/processing_app/basics/transform/arm.rb
ruby-processing-2.6.0 samples/processing_app/basics/transform/arm.rb
ruby-processing-2.5.1 samples/processing_app/basics/transform/arm.rb
ruby-processing-2.5.0 samples/processing_app/basics/transform/arm.rb
ruby-processing-2.4.4 samples/processing_app/basics/transform/arm.rb
ruby-processing-2.4.3 samples/processing_app/basics/transform/arm.rb
ruby-processing-2.4.2 samples/processing_app/basics/transform/arm.rb
ruby-processing-2.4.1 samples/processing_app/basics/transform/arm.rb