Sha256: 6208818ce95cf17bacb1264742880d86f55f62cdfecfeca010da2fd55834f29d

Contents?: true

Size: 582 Bytes

Versions: 4

Compression:

Stored size: 582 Bytes

Contents

require 'ruby-processing'

class DepthRectangleSketch < Processing::App

  def setup
    @z = 0  # A variable for the z (depth) coordinate
    rect_mode CENTER
    render_mode P3D
  end

  def draw
    background 255
    stroke 0
    fill 175
    
    # Translate to a point before displaying a shape there
    translate width/2, height/2, @z
    rect 0, 0, 8, 8

    # Increment z (i.e. move the shape toward the viewer)
    @z += 1

    # Start rectangle over
    @z = 0 if @z > 200 
  end

end

DepthRectangleSketch.new :title => "Depth Rectangle", :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/03_depth_rectangle.rb
ruby-processing-1.0.2 samples/learning_processing/chapter_14/03_depth_rectangle.rb
ruby-processing-1.0.4 samples/learning_processing/chapter_14/03_depth_rectangle.rb
ruby-processing-1.0.3 samples/learning_processing/chapter_14/03_depth_rectangle.rb