Last active
January 15, 2017 12:30
-
-
Save monkstone/56271a2310d40b3902d93655e1530b3f to your computer and use it in GitHub Desktop.
Sketches for Zaki
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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