Sha256: 00ef748c398aaf6c01abf48aa0423fa1920c9e1e71030481b704a164df8e5285

Contents?: true

Size: 722 Bytes

Versions: 5

Compression:

Stored size: 722 Bytes

Contents

#
# Pulses. 
# 
# Software drawing instruments can follow a rhythm or abide by rules independent
# of drawn gestures. This is a form of collaborative drawing in which the draftsperson
# controls some aspects of the image and the software controls others.
#

attr_reader :angle

def setup
  size(640, 360)
  background(102)
  noStroke
  fill(0, 102)
  @angle = 0
end

def draw
  # Draw only when mouse is pressed
  if mouse_pressed?
    @angle += 5
    val = cos(angle.radians) * 12.0
    (0 ... 360).step(75) do |a|
      xoff = cos(a.radians) * val
      yoff = sin(a.radians) * val
      fill(0)
      ellipse(mouse_x + xoff, mouse_y + yoff, val, val)
    end
    fill(255)
    ellipse(mouse_x, mouse_y, 2, 2)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/topics/drawing/pulses.rb
ruby-processing-2.6.2 samples/processing_app/topics/drawing/pulses.rb
ruby-processing-2.6.1 samples/processing_app/topics/drawing/pulses.rb
ruby-processing-2.6.0 samples/processing_app/topics/drawing/pulses.rb
ruby-processing-2.5.1 samples/processing_app/topics/drawing/pulses.rb