Context Free Art で立体を描く

ビル群

ちょっとした立体風のものを描いてみた。立体を描く方法は Design ideas - Context Free Art を参照した。

ソースはこちら。

startshape ALL

rule ALL{
  Buildings { hue 0 b .7}
}

rule Buildings{
  Building {}
  BuildingsRecur { hue 10 y 2 s .8 x 4 z -1}
  BuildingsRecur { hue 10 y 2 s .8 x -4 z -1}
}
rule BuildingsRecur .1{}
rule BuildingsRecur { Buildings{} }

rule Building{
  CUBESIDE {  }
  Building { y 1 }
}
rule Building .2{
  CUBETOP { }
  CUBESIDE {} 
}

rule CUBE{
  CUBETOP {}
  CUBESIDE {}
}

rule CUBETOP {
  TOP{b .7  sat .7}
}

rule CUBESIDE{
  SIDE{ b .8 sat .7 s -1 1 }
  SIDE{ b .5 sat .7}
}

rule SIDE {FACE{skew 0 30}}
rule TOP {FACE[s 1.413 .816 r 135]}
rule FACE {SQUARE{x .5 y -.5 h 30}}

バベルの塔

今度は円柱。縦に連ねて塔みたいなもの。

startshape BODY

rule BODY {
	CYLINDER { b .4  }
}

rule CYLINDER {
	CYLINDER_BOTTOM {}
}

rule CYLINDER_BOTTOM {
	CIRCLE { s 1 .2 }
	SQUARE { y .125 s 1 .25}
	CYLINDER_BODY { y .25}
}
rule CYLINDER_BODY {
	SQUARE { y .125 s 1 .25}
	CYLINDER_BODY { y .25 }
}
rule CYLINDER_BODY {
	CYLINDER_TOP {  }
}
rule CYLINDER_TOP {
	CIRCLE { s 1 .2 b .5 }
	CYLINDER { s .8  }
}

LEGO

同じ円柱を活用して分岐させてみた。レゴっぽい。

startshape BODY

rule BODY {
	CYLINDER { b .5 sat 1 }
}

rule CYLINDER {
	CYLINDER_BOTTOM {}
}

rule CYLINDER_BOTTOM {
	CIRCLE { s 1 .2 }
	SQUARE { y .125 s 1 .25}
	CYLINDER_BODY { y .25}
}
rule CYLINDER_BODY {
	SQUARE { y .125 s 1 .25}
	CYLINDER_BODY { y .25 }
}
rule CYLINDER_BODY {
	CYLINDER_TOP {  }
}
rule CYLINDER_TOP {
	CIRCLE { s 1 .2 b .5 sat 1 }
	CYLINDER { s .3 x -.25  z 3 hue 45 }
	CYLINDER { s .3 x  .25  z 3 hue 200 }
}