Sha256: 8e2808d754a030638be1349e38a2b27d5c1d753d29d010eef63537796910fcfe
Contents?: true
Size: 1.01 KB
Versions: 5
Compression:
Stored size: 1.01 KB
Contents
# city.rb after city.cfdg require 'cf3' # NB: requires ruby 1.9 for rand range def setup_the_city @city = ContextFree.define do shape :neighborhood do split do block x: -0.25, y: -0.25 rewind block x: 0.25, y: -0.25 rewind block x: 0.25, y: 0.25 rewind block x: -0.25, y: 0.25 end end shape :block do buildings size: 0.85 end shape :block, 5 do neighborhood size: 0.5, rotation: rand(-PI..PI), hue: rand(2), brightness: rand(0.75..1.75) end shape :block, 0.1 do # Do nothing end shape :buildings do square end end end def setup size 600, 600 smooth setup_the_city @background = color 255, 255, 255 draw_it end def draw # Do nothing end def draw_it background @background @city.render :neighborhood, start_x: width/2, start_y: height/2, size: height/2.5, color: [0.1, 0.1, 0.1] end def mouse_clicked draw_it end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
cf3-0.0.5 | samples/city.rb |
cf3-0.0.4 | samples/city.rb |
cf3-0.0.3 | samples/city.rb |
cf3-0.0.2 | samples/city.rb |
cf3-0.0.1 | samples/city.rb |