You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

city-reflection.cfdg 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. city-reflection.cfdg
  3. by AK, Jan 2009
  4. city.cfdg with reflections
  5. Variants: IOH, XCZ, ...
  6. */
  7. startshape city
  8. background { b -0.90 h 270 sat 0.5 }
  9. /** city has horizontal "skyline" strips vanishing into distance **/
  10. rule city {
  11. skyline{y -20}
  12. city { s -0.9 0.85 0.9 }
  13. }
  14. rule city 0.1{} // on average 10 skyline strips
  15. rule skyline{ // each strip consists of two half-strips back-to-back
  16. semiskyline{ x 9 }
  17. semiskyline { x 3 flip 90 }
  18. }
  19. rule semiskyline 2 {
  20. building_site{}
  21. semiskyline { x 15 }
  22. }
  23. rule semiskyline 2 {
  24. building_site{}
  25. semiskyline { x 20 }
  26. }
  27. rule semiskyline{} // on average 5 building sites per semiskyline
  28. /*************** building sites: some occupied, some vacant ***********/
  29. rule building_site 2{
  30. building{s 10 10 10} // building drawn in the plane z=10 with reflection drawn in the plane z=-10
  31. G{s 50 5 b 0 sat 1 h 60}
  32. haze {z 9.9 }
  33. haze {z 10.1 }
  34. }
  35. rule building_site 1{
  36. G{s 50 5 b 0 sat 1 h 60}
  37. haze {z 9.9 }
  38. }
  39. /* Each building has a random number of +/- 20% rescaling
  40. steps applied to it. */
  41. rule building 3{building{ s 1 0.8}}
  42. rule building 3{building {s 1 1.2}}
  43. rule building 2{building{ s 0.8 1}}
  44. rule building 2{building {s 1.2 1}}
  45. /* There are three types of buildings, of height 1, 2 or 4 units.
  46. Each has a matching reflection that is proportional
  47. to the building. */
  48. rule building{ B1{ z 1} R1{z -1} }
  49. rule building{ B2{z 1} R2{z -1} }
  50. rule building{ B3{z 1} R3{z -1} }
  51. rule B1{BOX{}}
  52. rule B2{B1{y 1}B1{}}
  53. rule B3{B2{y 2}B2{}}
  54. /* There are three different styles of reflection possible */
  55. // Style 1: reflections on rough water
  56. rule R1{RF{ s 1.2 -1.4 y -0.5 b 0.5 sat 0.3 h 180}}
  57. rule R2{RF{ s 1.2 -2.8 y -0.5 b 0.7 sat 0.3 h 180}}
  58. rule R3{RF{ s 1.2 -5.6 y -0.5 b 0.9 sat 0.3 h 180}}
  59. /* vvv----------- unused code --------vvv
  60. // Style 2: reflections on smooth water - not so good as different windows are lit
  61. rule R1{B1{h 240 sat 0.5 b -0.5 s -1}}
  62. rule R2{B2{h 240 sat 0.5 b -0.5 s -1}}
  63. rule R3{B3{h 240 sat 0.5 b -0.5 s -1}}
  64. // Style 3: tapered reflections on smooth water
  65. rule R1{BOX{h 240 sat 0.5 b -0.5 s -1}}
  66. rule R2{R1{ y -1 s 0.8 1} R1{ s 1.2 1} }
  67. rule R3{R2{ y -2 s 0.64 1 } R2{ s 1.44 1}}
  68. ^^^----------- unused code -----------^^^ */
  69. /* This is the element from which buildings are built. A box with windows. */
  70. rule BOX{
  71. SQUARE{ y 0.5 }
  72. wa{ y 0.5 s 0.8 1 z 0.1}
  73. }
  74. /* get windows on BOX by progressive subdivision */
  75. rule wa{ wb { s 1 0.5 y -0.25 } wb{ s 1 0.5 y 0.25 } }
  76. rule wb{ wc{ s 1 0.5 y -0.25 } wc{ s 1 0.5 y 0.25 } }
  77. rule wc{ wd{ s 0.5 1 x -0.25 } wd { s 0.5 1 x 0.25 }}
  78. rule wd{ we{ s 0.5 1 x -0.25 } we { s 0.5 1 x 0.25 }}
  79. /* but only some windows are lit */
  80. rule we 2 {}
  81. rule we{ win{}}
  82. /* some alternative window subdivision pathways that give all or no lit windows on a floor */
  83. rule wc 0.1{ wdx{ s 0.5 1 x -0.25 } wdx { s 0.5 1 x 0.25 }}
  84. rule wc 0.1{}
  85. rule wdx{ win{ s 0.5 1 x -0.25 } win { s 0.5 1 x 0.25 }}
  86. /* possibly tweak window colour and brightness */
  87. rule win 3{ win {b 0.2 }}
  88. rule win 3{ win {b -0.2 }}
  89. rule win { win {h 20 }}
  90. /* a window */
  91. rule win{
  92. SQUARE { size .8 0.7 b .5 sat +0.2 }
  93. SQUARE { s 0.1 0.8 b -1} // vertical divider
  94. // SQUARE { s 0.8 0.1 b -1} // horizontal divider
  95. }
  96. /* Reflection on rough water.
  97. The tear-drop shape comes from a shape
  98. being scaled non-proportionally
  99. while progressively shifted. */
  100. rule RF{
  101. SPARKLE{ s 2 0.1 x 1}
  102. SPARKLE{ s 2 0.1 b 0.2}
  103. RF[ y 1 s -0.9 0.96 y -1 b -0.02]
  104. }
  105. rule SPARKLE{ // shiny filler
  106. CIRCLE{ s 1.5 0.5 a -0.98}
  107. 6 * {r 60} SPARK { s 0.15 x 0.5 a -0.8}
  108. }
  109. rule SPARK{TRIANGLE{}}
  110. rule SPARK 5{SPARK{r 222}}
  111. rule SPARK 2{SPARK{x 1}}
  112. rule SPARKLE 5 {SPARKLE{r 223}}
  113. rule SPARKLE 2{
  114. SPARKLE{s 0.7 x 0.5}
  115. SPARKLE{s 0.7 x -0.5}
  116. }
  117. rule SPARKLE 0.5{}
  118. /* Ground - a generic blobby shape */
  119. rule G{ CIRCLE{} }
  120. rule G{ CIRCLE{}
  121. G{ y -0.5 s 0.7 0.7 r 60}
  122. G{ y -0.5 s 0.7 0.7 r -60} }
  123. rule G{ G {r 10}}
  124. rule G{G { flip 90}}
  125. rule G 0.2{}
  126. /* ------------ Ground level haze ------------*/
  127. rule haze { haze { x .1 }}
  128. rule haze { haze { x -.1 }}
  129. rule haze {
  130. hazecircle { }
  131. haze { s 1 0.3 x .5 b .3}
  132. haze { s 1 0.3 x -.5 b .3}
  133. }
  134. rule haze .5{}
  135. rule hazecircle { hazecircle { r 10 }}
  136. rule hazecircle { hazecircle { flip 90 }}
  137. rule hazecircle {
  138. CIRCLE { s 30 20 z 0.1 h 40 b 0.5 sat .2 a -0.98 }
  139. }