Sha256: d203b00e8b87952d5012fa88896104b39e18f6ddecb10c02c556f3c6bb83cf8e

Contents?: true

Size: 572 Bytes

Versions: 4

Compression:

Stored size: 572 Bytes

Contents

# Sine. 
# 
# Smoothly scaling size with the sin() function.


def setup    
  size 640, 360
  no_stroke
  @diameter = 84.0
  @sin = 0.0
  @angle = 0.0
  @rad_points = 90
  
end

def draw  
  background 153  	
  translate width / 2, height / 2  	
  fill 255
  ellipse 0, 0, 16, 16  	
  angle_rot = 0.0
  fill 51  	
  (0...5).each { |i|
    
    push_matrix
    rotate angle_rot - 45
    ellipse(-116, 0, @diameter, @diameter)
    pop_matrix
    angle_rot += TWO_PI/5
  }  	
  @diameter = 34 * sin( @angle ) + 168
  @angle += 0.02
  #@angle = 0.0 if @angle > TWO_PI  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-processing-2.4.4 samples/processing_app/basics/math/sine.rb
ruby-processing-2.4.3 samples/processing_app/basics/math/sine.rb
ruby-processing-2.4.2 samples/processing_app/basics/math/sine.rb
ruby-processing-2.4.1 samples/processing_app/basics/math/sine.rb