Sha256: f52e96f88c1c8bd77651ae568aaca79e37a31abbec8e9bced996364b8acfd7f1

Contents?: true

Size: 727 Bytes

Versions: 4

Compression:

Stored size: 727 Bytes

Contents

require 'ruby-processing'

class MultipleTranslationsSketch < Processing::App

  def setup
    smooth
  end

  def draw
    background 255
    stroke 0
    fill 175

    # Grab mouse coordinates,  constrained to window
    mx = constrain(mouse_x, 0, width)
    my = constrain(mouse_y, 0, height)

    # Translate to the mouse location
    translate mx, my
    ellipse 0, 0, 8, 8

    # Translate 100 pixels to the right
    translate 100, 0
    ellipse 0, 0, 8, 8

    # Translate 100 pixels down
    translate 0, 100
    ellipse 0, 0, 8, 8

    # Translate 100 pixels left
    translate -100, 0
    ellipse 0, 0, 8, 8
  end

end

MultipleTranslationsSketch.new :title => "Multiple Translations", :width => 200, :height => 200

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-processing-1.0.1 samples/learning_processing/chapter_14/02_multiple_translations.rb
ruby-processing-1.0.2 samples/learning_processing/chapter_14/02_multiple_translations.rb
ruby-processing-1.0.3 samples/learning_processing/chapter_14/02_multiple_translations.rb
ruby-processing-1.0.4 samples/learning_processing/chapter_14/02_multiple_translations.rb