Clone statement for random shapes

If you're having trouble using Context Free or don't understand the language, ask for help here.

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
User avatar
DeFleur
Posts: 41
Joined: Sat Feb 07, 2009 7:49 am
Location: Switzerland

Clone statement for random shapes

Post by DeFleur »

I tried

Code: Select all

startshape TestClone
CF::Impure=1

shape RANd 
rule {CIRCLE [h 0 sat 1 b 1]}
rule {SQUARE [h 120 sat 1 b 1]}
rule {TRIANGLE [h 240 sat 1 b 1]}

shape TestClone {
loop 3 [y -1] loop 2 [x 1] clone [b -1] RANd [ ]
} 
hoping that in column x=1 same random shapes (a clone)
to appear (in black) as in column x=0. However,
the code does not provide this result and all 6 shapes are
random and colored. I try to achieve that a random shape
can be clone-repeated for adjustments (color, skew etc).
Advise is very much appreciated.
kind regards from DeFleur

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

Re: Clone statement for random shapes

Post by MtnViewJohn »

When you clone shapes you need to have an adjustment for each clone:

Code: Select all

startshape TestClone
CF::Impure=1

shape RANd 
rule {CIRCLE [h 0 sat 1 b 1]}
rule {SQUARE [h 120 sat 1 b 1]}
rule {TRIANGLE [h 240 sat 1 b 1]}

shape TestClone {
 clone [x 0 0], [x 1 0], 
       [x 0 1], [x 1 1], 
       [x 0 2], [x 1 2] RANd[b -1]
}
There is no construct for cloning loops.

User avatar
DeFleur
Posts: 41
Joined: Sat Feb 07, 2009 7:49 am
Location: Switzerland

Re: Clone statement for random shapes

Post by DeFleur »

I see. So I tried

Code: Select all

startshape TestClone
CF::Impure=1

shape RANd 
rule {CIRCLE [h 0 sat 1 b 1]}
rule {SQUARE [s .95 h 120 sat 1 b 1]}
rule {TRIANGLE [h 240 sat 1 b 1]}


shape TestClone {
clone [x 0 y 0], [x 1 y 0 s .5 h 60 b -.5] RANd [ ]
clone [x 0 y 1], [x 1 y 1 s .5 h 60 b -.5] RANd [ ]
clone [x 0 y 2], [x 1 y 2 s .5 h 60 b -.5] RANd [ ]
}
I can visualize the impact of the shape adjustment (s .5 h 60) on
shapes x=1 but can't get the impact on brightness reduction b -.5
to get them darker. I use CF 3.0.5. Any advice ?
kind regards from DeFleur

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

Re: Clone statement for random shapes

Post by MtnViewJohn »

The default brightness is 0, so b -0.5 does nothing. Furthermore, the b 1 in your RANd rules always sets the brightness to 1.

Code: Select all

startshape TestClone
CF::Impure=1

shape RANd 
rule {CIRCLE [h 0 sat 1]}
rule {SQUARE [s .95 h 120 sat 1]}
rule {TRIANGLE [h 240 sat 1]}


shape TestClone {
clone [x 0 y 0 b 1], [x 1 y 0 s .5 h 60 b .5] RANd [ ]
clone [x 0 y 1 b 1], [x 1 y 1 s .5 h 60 b .5] RANd [ ]
clone [x 0 y 2 b 1], [x 1 y 2 s .5 h 60 b .5] RANd [ ]
}

User avatar
DeFleur
Posts: 41
Joined: Sat Feb 07, 2009 7:49 am
Location: Switzerland

Re: Clone statement for random shapes

Post by DeFleur »

Clear and straight. Admit that default b 0 I could have known.
Thank you for your effort.
kind regards from DeFleur

Post Reply