Skip to content

Instantly share code, notes, and snippets.

@monkstone
Last active January 15, 2017 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monkstone/56271a2310d40b3902d93655e1530b3f to your computer and use it in GitHub Desktop.
Save monkstone/56271a2310d40b3902d93655e1530b3f to your computer and use it in GitHub Desktop.
Sketches for Zaki
GRID_SIZE = 5.0
def settings
size 400, 400
end
def setup
sketch_title 'Static Sketch'
stroke 206
# grid is a convenience method of creating grid in JRubyArt
grid(width, height, GRID_SIZE, GRID_SIZE) do |i, j|
rect(i, j, GRID_SIZE, GRID_SIZE)
end
end
# global constant
GRID_SIZE = 5.0
def settings
size 400, 400
end
def setup
sketch_title 'Spot Class'
@spot_array = []
# grid is a JRubyArt convenience method of creating a grid
# NB: 'for loops' are frowned on in ruby
grid(width, height, GRID_SIZE, GRID_SIZE) do |i, j|
@spot_array << Spot.new(i, j)
end
end
def draw
@spot_array.each(&:meth) # easier if your method has no args
no_loop
end
# The class has one method
class Spot
include Processing::Proxy
def initialize(x, y)
@x = x
@y = y
end
def meth
stroke 206
rect(@x, @y, GRID_SIZE, GRID_SIZE)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment