a trouble with an optical illusion

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
Traven
Posts: 11
Joined: Wed Dec 26, 2007 6:28 pm
Location: Poitiers, France
Contact:

a trouble with an optical illusion

Post by Traven »

hello everybody and sorry for my bad english

I'm trying to make this picture here

but i'have a little trouble,
for each iteration i want to rotate then move from the center of the iteration of the moment and not from the center of the first iteration

this is my code, for the moment :

Code: Select all

startshape jj
background{hue 49 sat 0.98 b 0.1}

rule ellipse
{
180*{r 1}SQUARE{s 0.1 1 y 2 b 1}
180*{r 1}SQUARE{s 0.1 1 y -2 b -1}
}

rule base
{
ellipse{s 0.5 1}
CIRCLE{z +1 s 2 4.4 hue 216 sat 0.98 b 0.7333}
}

rule jj
{
13*{r -27.7 x 5} base{r -27.7}
}
thank for your help and have a good end of year

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

Post by MtnViewJohn »

You can't do this in Context Free right now. What you are trying to do is have the loop iterate with the {r -27.7} rotation and the {x 5} translation separately and combine them before invoking the base shapes. But Context Free can only loop through a single transform. Your best solution is to write a Perl or Python script to generate the jj rule, which would look something like this:

Code: Select all

rule jj
{
    base{r 0 x 0 y 0}
    base{r -27.7 x 5 y 0}
    base{r -55.4 x 10 y 0}
...
In Context Free 3.0 you will be able to access the loop index from inside the loop. So rule jj would look something like this:

Code: Select all

rule jj
{
    13* {y 5} {
        13* {x 5} base {r (-27.7 * ($0 + $1))}
    }
}
Where $0 represents the index of the inner {x 5} loop and $1 represents the index of the outer {y 5} loop. But, don't hold your breath for Context Free 3.0.

User avatar
Traven
Posts: 11
Joined: Wed Dec 26, 2007 6:28 pm
Location: Poitiers, France
Contact:

Post by Traven »

thanks a lot MtnViewJohn

i understand the trouble but as i don't know the perl and too few of python i will make my picture with the hand, each shape after each shape.

i will show you ;-)

Traven

Post Reply