Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@monkstone
Last active June 9, 2017 07:52
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/40944916940eff071a2a7bb661779170 to your computer and use it in GitHub Desktop.
Save monkstone/40944916940eff071a2a7bb661779170 to your computer and use it in GitHub Desktop.
Using Create Graphics and Grid methods propane
#!/usr/bin/env jruby
# frozen_string_literal: false
require 'propane'
class GridDemo < Propane::App
attr_reader :tile # attr_accessor is frowned on in ruby circles
def settings
size(700, 100)
end
def setup
sketch_title 'Grid Demo'
@tile = create_graphics(50, 50)
background(0)
end
def draw
run_tile
grid(width, height, 50, 50) do |x, y| # exclusively JRubyArt and propane method
image(tile, x, y)
end
end
def run_tile
x = rand(20..tile.width-20)
y = rand(20..tile.height-20)
tile.begin_draw
tile.no_stroke
tile.fill(0, 20)
tile.rect(0, 0, tile.width, tile.height)
tile.fill(255)
tile.ellipse(x, y, 10, 10)
tile.end_draw
end
end
GridDemo.new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment