File: Mondrian.es

package info (click to toggle)
structure-synth 1.0.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,072 kB
  • ctags: 1,176
  • sloc: cpp: 7,070; python: 167; makefile: 66; lisp: 25
file content (47 lines) | stat: -rw-r--r-- 1,047 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
Mondrian Cube. MHC 2007.

Has a few rendering bugs...
*/

 mondrian

rule mondrian {
  //  The six faces of the cube  
  a2 
  { x -0.5 z -0.5 ry  90 } a2
  { x +0.5 z -0.5 ry  90 } a2
  { z -1 } a2
  { y +0.5  z -0.5 rx  90 } a2
  { y -0.5  z -0.5 rx  90 } a2
}

rule a2 w 2 maxdepth 2 > d {
  // Split into two halves in x direction
  {  s 0.333 1 1 x -1   } a2
  {  s 0.666  1 1 x 0.26  } a2 
}

rule a2 w 2 maxdepth 2 > d {
  // Split into two halves in y direction
  {  s 1  0.333 1 y  -1   } a2
  {  s 1 0.666   1 y 0.26  } a2
}


rule a2 {  d }

// This rule chooses a random color.
rule d {  {   s 1 1 0.02 color #F00 } square  }
rule d {  {   s 1 1 0.02 color #0404A2  } square  }
rule d {  {   s 1 1 0.02 color #FFFE33 } square  }
rule d w 2 {  {   s 1 1 0.02 color #FFF  } square  }

// Draws a framed square
rule square {
  { s 0.95 0.95 1  }  box 
  { s 0.05 1 1 b 0 x -10 } box 
  { s 0.05 1 1 b 0 x 10 } box 
  { s 1.05  0.05  1 b 0 y -10 } box 
  { s 1.05  0.05  1 b 0 y 10 } box 
}