/* city-reflection.cfdg by AK, Jan 2009 city.cfdg with reflections Variants: IOH, XCZ, ... */ startshape city background { b -0.90 h 270 sat 0.5 } /** city has horizontal "skyline" strips vanishing into distance **/ rule city { skyline{y -20} city { s -0.9 0.85 0.9 } } rule city 0.1{} // on average 10 skyline strips rule skyline{ // each strip consists of two half-strips back-to-back semiskyline{ x 9 } semiskyline { x 3 flip 90 } } rule semiskyline 2 { building_site{} semiskyline { x 15 } } rule semiskyline 2 { building_site{} semiskyline { x 20 } } rule semiskyline{} // on average 5 building sites per semiskyline /*************** building sites: some occupied, some vacant ***********/ rule building_site 2{ building{s 10 10 10} // building drawn in the plane z=10 with reflection drawn in the plane z=-10 G{s 50 5 b 0 sat 1 h 60} haze {z 9.9 } haze {z 10.1 } } rule building_site 1{ G{s 50 5 b 0 sat 1 h 60} haze {z 9.9 } } /* Each building has a random number of +/- 20% rescaling steps applied to it. */ rule building 3{building{ s 1 0.8}} rule building 3{building {s 1 1.2}} rule building 2{building{ s 0.8 1}} rule building 2{building {s 1.2 1}} /* There are three types of buildings, of height 1, 2 or 4 units. Each has a matching reflection that is proportional to the building. */ rule building{ B1{ z 1} R1{z -1} } rule building{ B2{z 1} R2{z -1} } rule building{ B3{z 1} R3{z -1} } rule B1{BOX{}} rule B2{B1{y 1}B1{}} rule B3{B2{y 2}B2{}} /* There are three different styles of reflection possible */ // Style 1: reflections on rough water rule R1{RF{ s 1.2 -1.4 y -0.5 b 0.5 sat 0.3 h 180}} rule R2{RF{ s 1.2 -2.8 y -0.5 b 0.7 sat 0.3 h 180}} rule R3{RF{ s 1.2 -5.6 y -0.5 b 0.9 sat 0.3 h 180}} /* vvv----------- unused code --------vvv // Style 2: reflections on smooth water - not so good as different windows are lit rule R1{B1{h 240 sat 0.5 b -0.5 s -1}} rule R2{B2{h 240 sat 0.5 b -0.5 s -1}} rule R3{B3{h 240 sat 0.5 b -0.5 s -1}} // Style 3: tapered reflections on smooth water rule R1{BOX{h 240 sat 0.5 b -0.5 s -1}} rule R2{R1{ y -1 s 0.8 1} R1{ s 1.2 1} } rule R3{R2{ y -2 s 0.64 1 } R2{ s 1.44 1}} ^^^----------- unused code -----------^^^ */ /* This is the element from which buildings are built. A box with windows. */ rule BOX{ SQUARE{ y 0.5 } wa{ y 0.5 s 0.8 1 z 0.1} } /* get windows on BOX by progressive subdivision */ rule wa{ wb { s 1 0.5 y -0.25 } wb{ s 1 0.5 y 0.25 } } rule wb{ wc{ s 1 0.5 y -0.25 } wc{ s 1 0.5 y 0.25 } } rule wc{ wd{ s 0.5 1 x -0.25 } wd { s 0.5 1 x 0.25 }} rule wd{ we{ s 0.5 1 x -0.25 } we { s 0.5 1 x 0.25 }} /* but only some windows are lit */ rule we 2 {} rule we{ win{}} /* some alternative window subdivision pathways that give all or no lit windows on a floor */ rule wc 0.1{ wdx{ s 0.5 1 x -0.25 } wdx { s 0.5 1 x 0.25 }} rule wc 0.1{} rule wdx{ win{ s 0.5 1 x -0.25 } win { s 0.5 1 x 0.25 }} /* possibly tweak window colour and brightness */ rule win 3{ win {b 0.2 }} rule win 3{ win {b -0.2 }} rule win { win {h 20 }} /* a window */ rule win{ SQUARE { size .8 0.7 b .5 sat +0.2 } SQUARE { s 0.1 0.8 b -1} // vertical divider // SQUARE { s 0.8 0.1 b -1} // horizontal divider } /* Reflection on rough water. The tear-drop shape comes from a shape being scaled non-proportionally while progressively shifted. */ rule RF{ SPARKLE{ s 2 0.1 x 1} SPARKLE{ s 2 0.1 b 0.2} RF[ y 1 s -0.9 0.96 y -1 b -0.02] } rule SPARKLE{ // shiny filler CIRCLE{ s 1.5 0.5 a -0.98} 6 * {r 60} SPARK { s 0.15 x 0.5 a -0.8} } rule SPARK{TRIANGLE{}} rule SPARK 5{SPARK{r 222}} rule SPARK 2{SPARK{x 1}} rule SPARKLE 5 {SPARKLE{r 223}} rule SPARKLE 2{ SPARKLE{s 0.7 x 0.5} SPARKLE{s 0.7 x -0.5} } rule SPARKLE 0.5{} /* Ground - a generic blobby shape */ rule G{ CIRCLE{} } rule G{ CIRCLE{} G{ y -0.5 s 0.7 0.7 r 60} G{ y -0.5 s 0.7 0.7 r -60} } rule G{ G {r 10}} rule G{G { flip 90}} rule G 0.2{} /* ------------ Ground level haze ------------*/ rule haze { haze { x .1 }} rule haze { haze { x -.1 }} rule haze { hazecircle { } haze { s 1 0.3 x .5 b .3} haze { s 1 0.3 x -.5 b .3} } rule haze .5{} rule hazecircle { hazecircle { r 10 }} rule hazecircle { hazecircle { flip 90 }} rule hazecircle { CIRCLE { s 30 20 z 0.1 h 40 b 0.5 sat .2 a -0.98 } }