How to rotate a shape ...

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

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
Nore
Posts: 4
Joined: Sun Sep 19, 2010 6:19 am

How to rotate a shape ...

Post by Nore »

Hi,
I'm new at Context Free Designing and i've got a few questions.
Here they are: (I just want to know wheather i'm right)
If you rotate a shape, do you rotate the asis, too?
e.g.:
startshape A
rule A{
2*[r 30 x 3 h 60] SQUARE{}
}

The point is that at this example the second square goes up and i just could explain it to me by rotating the x-asis of the square, too. Is this a right understanding?

another question is about the reflecting of a shape so that you got 2 images!
--> is there another, easier way than construct a second identic shape and rotate it about 90 degrees?

3. question:
is there any possibility to use usal counter, integer attributes?
e.g. i tried this following:
startshape line1

rule line1{
10*{x 1 b 0.2}SQUARE{}
line2{x 1 y 1}
}

rule line2{
9* {x 1 b 0.2} SQUARE{}
line3{x 1 y 1}
}

rule line3{
8*{x 1 b 0.2} SQUARE{}
}
...
but i think this is a bit too labour intensiv:(
So, I thougt about an integer attribut which decreases the number of the loop, but i don't know wheather those attributes exist.

thanks in anticipation

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

Re: How to rotate a shape ...

Post by MtnViewJohn »

1. [r 30 x 3] rotates the coordinate space 30 degrees and then translates (3,0) in the rotated coordinate space. [x 3 r 30] translates (3,0) and then rotates the coordinate space.

2. There is a flip adjustment that reflects the coordinate space; e.g., [flip 45] reflects across a 45 degree line. You can also flip across the x-axis or y-axis using the size adjustment: [size 1 -1] for x-axis and [size -1 1] for y-axis. However, for this to work the shape has to be nonrandom. If there is any variability in the shape then the two reflected shapes will be different variants.

3. This kind of loop control does not exist in Context Free 2.2, but will be introduced in Context Free 3. For now you either have to do it the tedious way or generate unwanted squares and use the size directive to clip them out of the canvas:

Code: Select all

startshape lines
size {s 10 x -4.5 y -4.5}

rule lines {
  10* {x 1 y 1} {
    10* {x 1 b 0.2} SQUARE{}
  }
}

Nore
Posts: 4
Joined: Sun Sep 19, 2010 6:19 am

Re: How to rotate a shape ...

Post by Nore »

Thanks for quick reply :)
But i don't understand why the size directive starts at x -4.5 y -4.5
I would have placed it at x 0 y 0 or if i had thought about it for a while at x -0.5 y -0.5, because of the point that the square is drawn form its middle, is'nt it?
It would be really kind if you explain it to me :)

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

Re: How to rotate a shape ...

Post by MtnViewJohn »

By default the center of the canvas is the origin (0,0), which is at the center of the bottom-left square. But I wanted the corner of the square 4 up and 4 to the right. So the canvas must be shifted (-4,-4) to get center the square 4 up and 4 to the right, and an additional (-0.5, -0.5) to center the upper-right corner of this square.

In retrospect I think I goofed in specifying the x,y shift part of the size directive. It would be easier to understand if the signs were reversed.

Nore
Posts: 4
Joined: Sun Sep 19, 2010 6:19 am

Re: How to rotate a shape ...

Post by Nore »

Ok, i don't understand that, not a bit :mrgreen:
i don't catch why you wanted to shift the canvas and, if you're about to shift it 4 up and 4 to the right, why must it be shifted (-4, -4) (the minus) .... is there an easier example to understand this?
If not, I hope this knowledge is not that important in CFDG and thats possible to avoid it.
perhaps, if i take a look at your explanation a second time after a while, i will get the clue, but now this is just ARABIC for me :D

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

Re: How to rotate a shape ...

Post by MtnViewJohn »

Yes, I have run off on a tangent. The main answer for your third question is that there is no way to have variable counts for loops, so you have to do it the labor-intensive way. This will be fixed in the next version.

Few people use the size directive. Most people prefer the default behavior of dynamically sized canvases. All I was saying is that the center of the 10x10 grid of squares is 4.5 up and 4.5 over from the center of the square that lies at the canvas origin.

Nore
Posts: 4
Joined: Sun Sep 19, 2010 6:19 am

Re: How to rotate a shape ...

Post by Nore »

Uhhhhhh :idea: , ok, sry
I looked up the Dokumentation:

" size {s width height x xpos y ypos}
This sets the canvas width and height in drawing units and sets the position of the center of the canvas to (-xpos, -ypos) "

ok now it makes sense to me :)
I've forgotten the matter with the x position and y position and so i didn't get why you shifted it about (-4.5 / -4.5) :)
Actually it's not that difficult :) you just have to remember :mrgreen:

Thanks for having patience with me :D

Post Reply