CLOCK COMPOSITION

If you have a design you're proud of, share the cfdg file here. It's also a good place to ask for feedback and collaborate.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
User avatar
LaT3x
Posts: 68
Joined: Wed Jul 06, 2005 3:11 pm
Location: Madrid, Spain

CLOCK COMPOSITION

Post by LaT3x »

Enjoy it 8)

Image

Code: Select all

startshape cuadro
include i_pix.cfdg

rule cuadro
{ 
  reloj {}
  agujas {}
}

rule reloj
{
  esfera {}
  marcas {r 15}
  numerosEsfera {}
  minutero {}
  segundero {}
}

rule esfera 
{
  CIRCLE {s 36}
  CIRCLE {s 35.7 b 1}
  CIRCLE {s 35}
  CIRCLE {s 34 b 1}
}

rule numerosEsfera
{
  NUM_1_5by5  [x 8 y 13.8564]
  NUM_2_5by5  [x 13.8564 y 8]
  NUM_3_5by5  [x 16 y 0]
  NUM_4_5by5  [x 13.8564 y -8]
  NUM_5_5by5  [x 8 y -13.8564]
  NUM_6_5by5  [x 0 y -16]
  NUM_7_5by5  [x -8 y -13.8564]
  NUM_8_5by5  [x -13.8564 y -8]
  NUM_9_5by5  [x -16 y 0]
  NUM_10_5by5 [x -13.8564 y 8]
  NUM_11_5by5 [x -8 y 13.8564]
  NUM_12_5by5 [x 0 y 16]
}
rule NUM_10_5by5 {NUM_1_5by5{} NUM_0_5by5{x .75}}
rule NUM_11_5by5 {NUM_1_5by5{} NUM_1_5by5{x .75}}
rule NUM_12_5by5 {NUM_1_5by5{} NUM_2_5by5{x .75}}

rule marcas
{
  marcasReloj {}
  marcasReloj {r 90}
  marcasReloj {r 180}
  marcasReloj {r 270}
}

rule marcasReloj
{
  punto [x 16 y 0]
  punto [x 13.8564 y 8 r 30]
  punto [x 8 y 13.8564 r 60]
}
rule punto
{
  CIRCLE{s .2}
}

rule minutero {minuteroReloj {}}
rule minutero {minuteroReloj {r 90}}
rule minutero {minuteroReloj {r 180}}
rule minutero {minuteroReloj {r 270}}
rule minuteroReloj {aguja1 {s 2}}
rule minuteroReloj {aguja1 {s 2 r 10 }}
rule minuteroReloj {aguja1 {s 2 r 20 }}
rule minuteroReloj {aguja1 {s 2 r 30 }}
rule minuteroReloj {aguja1 {s 2 r 40 }}
rule minuteroReloj {aguja1 {s 2 r 50 }}
rule minuteroReloj {aguja1 {s 2 r 60 }}
rule minuteroReloj {aguja1 {s 2 r 70 }}
rule minuteroReloj {aguja1 {s 2 r 80 }}

rule segundero {segunderoReloj {}}
rule segundero {segunderoReloj {r 90}}
rule segundero {segunderoReloj {r 180}}
rule segundero {segunderoReloj {r 270}}
rule segunderoReloj {aguja2 {s 1.5}}
rule segunderoReloj {aguja2 {s 1.5 r 10 }}
rule segunderoReloj {aguja2 {s 1.5 r 20 }}
rule segunderoReloj {aguja2 {s 1.5 r 30 }}
rule segunderoReloj {aguja2 {s 1.5 r 40 }}
rule segunderoReloj {aguja2 {s 1.5 r 50 }}
rule segunderoReloj {aguja2 {s 1.5 r 60 }}
rule segunderoReloj {aguja2 {s 1.5 r 70 }}
rule segunderoReloj {aguja2 {s 1.5 r 80 }}

// ALEATORIEDAD de las agujas sueltas -------
rule agujas 
{
  aguja {}
  agujas { r 10 x 2 y 10}
}
rule agujas
{
  agujas { r -10 x -5 y -5}
}
rule agujas
{
  agujas { r 30 s .9 }
}
rule agujas
{
  aguja {}
  agujas { r -30 s .99 }
}

// aguja -----------------
rule aguja { pelota{} eje{} punta{} } 
rule aguja1 { pelota1{} eje{} punta1{} }
rule aguja2 { pelota2{} eje{} punta2{} }

// punta -------------
rule punta {punta1{}} 
rule punta {punta2{}} 
rule punta1
{
  TRIANGLE [ x 6 s .5 s 5 1 r 30 ]
}
rule punta2
{
  TRIANGLE [ x 6 s .5 s 5 1 r 30 ]
  TRIANGLE [ x 5.9 s .4 s 5 1 r 30 b 1 ]
}

// eje ---------------------
rule eje { SQUARE {r 90  x 2.5 s .05 5.5} }

// pelota ------------
rule pelota {pelota1{}}
rule pelota {pelota2{}}
rule pelota1
{
  CIRCLE {}
  CIRCLE {s 0.9 b 1} 
}
rule pelota2
{
  CIRCLE {}
}

boork
Posts: 14
Joined: Fri May 06, 2005 9:14 am
Location: london
Contact:

Post by boork »

wow, LaT3x you write sweet code indeed!

This is v nice!!

good stuff
when everything is connected, for better or for worse, everything matters.

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Post by MtnViewJohn »

Dali, eat your heart out.

User avatar
MtnViewJohn
Site Admin
Posts: 882
Joined: Fri May 06, 2005 2:26 pm
Location: Mountain View, California
Contact:

Scary trig constants

Post by MtnViewJohn »

You can use the transform ordering capability to eliminate all of the scary trig constants, and save yourself some time too.

Code: Select all

startshape cuadro 
include i_pix.cfdg 

rule cuadro 
{ 
  reloj {} 
  agujas {} 
} 

rule reloj 
{ 
  esfera {} 
  marcas {r 15} 
  numerosEsfera {} 
  minutero {} 
  segundero {} 
} 

rule esfera 
{ 
  CIRCLE {s 36} 
  CIRCLE {s 35.7 b 1} 
  CIRCLE {s 35} 
  CIRCLE {s 34 b 1} 
} 

rule numerosEsfera 
{ 
  NUM_1_5by5  [r 60 x 16 r -60] 
  NUM_2_5by5  [r 30 x 16 r -30] 
  NUM_3_5by5  [r -0 x 16 r  0] 
  NUM_4_5by5  [r -30 x 16 r 30] 
  NUM_5_5by5  [r -60 x 16 r 60] 
  NUM_6_5by5  [r -90 x 16 r 90] 
  NUM_7_5by5  [r -120 x 16 r 120] 
  NUM_8_5by5  [r -150 x 16 r 150] 
  NUM_9_5by5  [r -180 x 16 r 180] 
  NUM_10_5by5 [r -210 x 16 r 210] 
  NUM_11_5by5 [r -240 x 16 r 240] 
  NUM_12_5by5 [r -270 x 16 r 270] 
} 
rule NUM_10_5by5 {NUM_1_5by5{} NUM_0_5by5{x .75}} 
rule NUM_11_5by5 {NUM_1_5by5{} NUM_1_5by5{x .75}} 
rule NUM_12_5by5 {NUM_1_5by5{} NUM_2_5by5{x .75}} 

rule marcas 
{ 
  marcasReloj {} 
  marcasReloj {r 90} 
  marcasReloj {r 180} 
  marcasReloj {r 270} 
} 

rule marcasReloj 
{ 
  punto [r 0 x 16] 
  punto [r 30 x 16] 
  punto [r 60 x 16] 
} 
rule punto 
{ 
  CIRCLE{s .2} 
} 

rule minutero {minuteroReloj {}} 
rule minutero {minuteroReloj {r 90}} 
rule minutero {minuteroReloj {r 180}} 
rule minutero {minuteroReloj {r 270}} 
rule minuteroReloj {aguja1 {s 2}} 
rule minuteroReloj {aguja1 {s 2 r 10 }} 
rule minuteroReloj {aguja1 {s 2 r 20 }} 
rule minuteroReloj {aguja1 {s 2 r 30 }} 
rule minuteroReloj {aguja1 {s 2 r 40 }} 
rule minuteroReloj {aguja1 {s 2 r 50 }} 
rule minuteroReloj {aguja1 {s 2 r 60 }} 
rule minuteroReloj {aguja1 {s 2 r 70 }} 
rule minuteroReloj {aguja1 {s 2 r 80 }} 

rule segundero {segunderoReloj {}} 
rule segundero {segunderoReloj {r 90}} 
rule segundero {segunderoReloj {r 180}} 
rule segundero {segunderoReloj {r 270}} 
rule segunderoReloj {aguja2 {s 1.5}} 
rule segunderoReloj {aguja2 {s 1.5 r 10 }} 
rule segunderoReloj {aguja2 {s 1.5 r 20 }} 
rule segunderoReloj {aguja2 {s 1.5 r 30 }} 
rule segunderoReloj {aguja2 {s 1.5 r 40 }} 
rule segunderoReloj {aguja2 {s 1.5 r 50 }} 
rule segunderoReloj {aguja2 {s 1.5 r 60 }} 
rule segunderoReloj {aguja2 {s 1.5 r 70 }} 
rule segunderoReloj {aguja2 {s 1.5 r 80 }} 

// ALEATORIEDAD de las agujas sueltas ------- 
rule agujas 
{ 
  aguja {} 
  agujas { r 10 x 2 y 10} 
} 
rule agujas 
{ 
  agujas { r -10 x -5 y -5} 
} 
rule agujas 
{ 
  agujas { r 30 s .9 } 
} 
rule agujas 
{ 
  aguja {} 
  agujas { r -30 s .99 } 
} 

// aguja ----------------- 
rule aguja { pelota{} eje{} punta{} } 
rule aguja1 { pelota1{} eje{} punta1{} } 
rule aguja2 { pelota2{} eje{} punta2{} } 

// punta ------------- 
rule punta {punta1{}} 
rule punta {punta2{}} 
rule punta1 
{ 
  TRIANGLE [ x 6 s .5 s 5 1 r 30 ] 
} 
rule punta2 
{ 
  TRIANGLE [ x 6 s .5 s 5 1 r 30 ] 
  TRIANGLE [ x 5.9 s .4 s 5 1 r 30 b 1 ] 
} 

// eje --------------------- 
rule eje { SQUARE {r 90  x 2.5 s .05 5.5} } 

// pelota ------------ 
rule pelota {pelota1{}} 
rule pelota {pelota2{}} 
rule pelota1 
{ 
  CIRCLE {} 
  CIRCLE {s 0.9 b 1} 
} 
rule pelota2 
{ 
  CIRCLE {} 
}

User avatar
LaT3x
Posts: 68
Joined: Wed Jul 06, 2005 3:11 pm
Location: Madrid, Spain

Post by LaT3x »

Yeah!... the rules about the aleat position of the "manecillas" doesn't the best :)... I think in other thing when I wrote it

Post Reply