City

code:

// https://www.flickr.com/photos/33807726@N02/3152555332/
set background #FFF
{ x -4 y -4 z -0.5 s 1 1 0.1 z 0.5 color #FFF } mat
// Ground plane
{ x -0 y -0 z -0.5 s 100 100 0.01 color #000 } box
// make 6x6 blocks
rule mat {
12 * { x 1 hue 0 } 12 * { y 1 hue 0 } split
}
// do a z -0.5 to center cube around zero before doing scale
// - then translate back with z 0.5 at end of operation
// this way all bases line up.
// X-split
rule split w 5 maxdepth 3 > square {
{ z -0.5 s 1/3 1 1.3 x -1 color red z 0.5 } split
{ z -0.5 s 2/3 1 0.7 x 1/4 color blue z 0.5 } split
}
rule split w 5 maxdepth 3 > square {
{ z -0.5 s 2/3 1 1.3 x -1 color orange z 0.5 } split
{ z -0.5 s 1/3 1 0.7 x 1/4 color yellow z 0.5 } split
}
// Y-split
rule split w 5 maxdepth 3 > square {
{ z -0.5 s 1 1/3 0.8 y -1 color cyan z 0.5 } split
{ z -0.5 s 1 2/3 1.0 y 1/4 color green z 0.5 } split
}
rule split w 5 maxdepth 3 > square {
{ z -0.5 s 1 2/3 0.8 y -1 color magenta z 0.5 } split
{ z -0.5 s 1 1/3 1.0 y 1/4 color purple z 0.5 } split
}
// No split
//rule split w 0.2 { square }
rule square {
{ z -0.5 s 0.95 0.95 0.8 z 0.8 } box
onTopBox
}
// 20% height boxes
rule onTopBox { // 50/50 H/W
{ s 0.5 0.5 0.2 z 3 sat 0 } box
}
rule onTopBox { // 50/50 H/W + shifted
{ x 0.1 y 0.1 s 0.5 0.5 0.2 z 3 sat 0 } box
}
rule onTopBox { // 30/50 H/W - shifted
{ x -0.1 y -0.1 s 0.3 0.5 0.2 z 3 sat 0 } box
}
rule onTopBox { // 20/10 H/W + shifted
{ x 0.1 y 0.1 s 0.2 0.1 0.2 z 3 sat 0 } box
}
// 50% on top boxes
rule onTopBox { // 10/10 H/W + shifted
{ x 0.1 y 0.1 s 0.1 0.1 0.5 z 1.5 sat 0 } box
}
rule onTopBox w 2 { // 50/50 H/W
{ s 0.5 0.5 0.5 z 1.5 sat 0 } box
onTopBox2
}
// boxes on top of boxes
// 20 % height
rule onTopBox2 { // 30/30 H/W + shifted
{ x 0.05 y 0.05 s 0.3 0.3 0.2 z 5.5 color #FF0 } box
}
rule onTopBox2 { // 30/30 H/W - shifted
{ x -0.05 y -0.05 s 0.3 0.3 0.2 z 5.5 color #FF0 } box
}
// 80% height
rule onTopBox2 { // 10/10 H/W + shifted
{ x 0.05 y 0.05 s 0.1 0.1 0.8 z 1.7 color #F00 } box
}
rule onTopBox2 { // 10/10 H/W - shifted
{ x -0.05 y -0.05 s 0.1 0.1 0.8 z 1.7 color #F00 } box
}