Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
113 additions
and
125 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,57 +1,64 @@ | |||
load_library 'context_free' | load_library 'context_free' | ||
|
|
||
def setup_the_city | def setup_the_city | ||
@city = context_free do |
|
||
rule :whole do | @city = ContextFree.define do | ||
|
|||
rule :neighborhood do | |||
split do | split do | ||
quad :x => -0.25, :y => -0.25 | block :x => -0.25, :y => -0.25 | ||
rewind | rewind | ||
quad :x => 0.25, :y => -0.25 | block :x => 0.25, :y => -0.25 | ||
rewind | rewind | ||
quad :x => 0.25, :y => 0.25 | block :x => 0.25, :y => 0.25 | ||
rewind | rewind | ||
quad :x => -0.25, :y => 0.25 | block :x => -0.25, :y => 0.25 | ||
end | end | ||
end | end | ||
|
|
||
rule :quad do | rule :block do | ||
fill :size => 0.85 | buildings :size => 0.85 | ||
end | end | ||
|
|
||
rule :quad, 5 do | rule :block, 5 do | ||
whole :size => 0.5, :rotation => rand(4), :hue => rand(2), :brightness => rand(3) | neighborhood :size => 0.5, :rotation => rand(8)-4, :hue => rand(2), :brightness => rand + 0.75 | ||
end | end | ||
|
|
||
rule :quad, 0.1 do | rule :block, 0.1 do | ||
# Do nothing | # Do nothing | ||
end | end | ||
|
|
||
rule :fill do | rule :buildings do | ||
square | square | ||
end | end | ||
|
|||
end | end | ||
|
|||
end | end | ||
|
|
||
|
|
||
def setup | def setup | ||
size 600, 600 | size 600, 600 | ||
setup_the_city | |||
smooth | smooth | ||
setup_the_city | |||
@background = color 255, 255, 255 | @background = color 255, 255, 255 | ||
the_color = [0.1, 0.1, 0.1] | |||
@city.setup :start_x => width/2, :start_y => height/2, :size => height/3, :color => the_color | |||
draw_it | draw_it | ||
end | end | ||
|
|
||
|
|||
def draw | def draw | ||
# Do nothing | # Do nothing | ||
end | end | ||
|
|
||
|
|||
def draw_it | def draw_it | ||
background @background | background @background | ||
@city.render :whole | @city.render :neighborhood, | ||
:start_x => width/2, :start_y => height/2, | |||
:size => height/2.5, :color => [0.1, 0.1, 0.1] | |||
end | end | ||
|
|
||
|
|||
def mouse_clicked | def mouse_clicked | ||
draw_it | draw_it | ||
end | end |
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
-Xss8M |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,59 @@ | |||
load_library 'context_free' | |||
|
|||
def setup_the_vine | |||
|
|||
@vine = ContextFree.define do | |||
|
|||
shrink = 0.961 | |||
|
|||
rule :root do | |||
split do | |||
shoot :y => 1 | |||
rewind | |||
shoot :rotation => 180 | |||
end | |||
end | |||
|
|||
rule :shoot do | |||
square | |||
shoot :y => 0.98, :rotation => 5, :size => shrink + rand * 0.05, :brightness => 0.990 | |||
end | |||
|
|||
rule :shoot, 0.02 do | |||
square | |||
split do | |||
shoot :rotation => 90 | |||
rewind | |||
shoot :rotation => -90 | |||
end | |||
end | |||
|
|||
end | |||
end | |||
|
|||
|
|||
def setup | |||
size 700, 700 | |||
setup_the_vine | |||
no_stroke | |||
color_mode HSB, 1.0 | |||
smooth | |||
draw_it | |||
end | |||
|
|||
|
|||
def draw | |||
# Do nothing. | |||
end | |||
|
|||
|
|||
def draw_it | |||
background 0.75, 1.0, 0.15 | |||
@vine.render :root, :size => height/75, :color => [0.75, 0.1, 0.9], | |||
:start_x => width/2, :start_y => height/2 | |||
end | |||
|
|||
|
|||
def mouse_clicked | |||
draw_it | |||
end |