Sha256: c4a95aaf08adcfd50f874e0e11414fd2b8f433d211b9ff8a965817a9384b6248

Contents?: true

Size: 779 Bytes

Versions: 6

Compression:

Stored size: 779 Bytes

Contents

#
# Tile Images
# 
# Draws an image larger than the screen by tiling it into small sections.
# The scaleValue variable sets amount of scaling: 1 is 100%, 2 is 200%, etc.
#
attr_reader :scaleValue, :x_offset, :y_offset


def setup
  size(600, 600)
  stroke(0, 100)
  @x_offset = 0     # x-axis offset
  @y_offset = 0     # y-axis offset
  @scaleValue = 3  # Multiplication factor
end

def draw
  scale(scaleValue)
  translate(x_offset * (-width / scaleValue), y_offset * (-height / scaleValue))
  line(10, 150, 500, 50)
  line(0, 600, 600, 0)
  setOffset
end

def setOffset
  save('lines-#{x_offset}#{y_offset}.png')
  @x_offset += 1
  if (x_offset == scaleValue)
    @x_offset = 0
    @y_offset += 1
    if (y_offset == scaleValue)
      exit
    end
  end
  background(204)
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/topics/file_io/tile_images.rb
ruby-processing-2.6.2 samples/processing_app/topics/file_io/tile_images.rb
ruby-processing-2.6.1 samples/processing_app/topics/file_io/tile_images.rb
ruby-processing-2.6.0 samples/processing_app/topics/file_io/tile_images.rb
ruby-processing-2.5.1 samples/processing_app/topics/file_io/tile_images.rb
ruby-processing-2.5.0 samples/processing_app/topics/file_io/tile_images.rb