All available Commands?

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

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
Music2000
Posts: 26
Joined: Mon Oct 10, 2005 3:38 pm
Location: London

All available Commands?

Post by Music2000 »

Hi im a new user of Context Free, at the moment i am not very good at using the program but have noticed you use commands such as SQUARE and TRIANGLE to have an effect on the final result, so far i have been just editing values and swapping words around to generate images which has been quite fun but i would like to be able to code my own images, i could not find any documentation in the download area with all the available things i could use so is there a command list available or could someone please post a few of the these if possible, thanks :)

dzeni
Posts: 18
Joined: Wed Sep 28, 2005 2:18 pm
Location: Auckland, New Zealand
Contact:

Post by dzeni »

Hi,

If you go through the lessons and examples that come with CFDG you will be able get an idea of how to make it do a range of cool things.

below are some commands that I gleaned from the examples mentioned above.

I am assuming you understand about starting off with a "startshape" and you know about writing simple rules.

Shape Commands

CIRCLE{} - draws a circle
SQUARE{} - draws a square
TRIANGLE{} - draws a triangle

*note that you must use CAPS when typing in CIRCLE, SQUARE and TRIANGLE

Manipulating Shapes

CIRCLE{x 1} - the 'x 1' says to shift the circle one to the right (use -1 to go left)
CIRCLE {y 1} - the 'y 1' says shift the circle one up (-ve goes down)

* if you don't leave a space between the 'x' or 'y' and the number, you will get an error and the thing won't draw.

CIRCLE{skew 15 15} - This pushes a shape parallel to the x axis, y axis or both. You need to specify two numbers after the "skew" command, one for x and one for y. If you only want to skew it along the x axis, you would say CIRCLE{skew 3 0}

TRIANGLE{flip 180} - This reflects the image across a line at the given angle (180 degrees in my example above). If you do this to the preceding example, you will end up with a six sided star.

TRIANGLE{r 30} - This rotates the shape by the number of degrees specified.

Coloring Commands

CFDG uses HSB for color.

The 'H' stands for hue and can take values from 0 - 255
hue 0 = red
hue 30 = orange
hue 60 = yellow
and so on. You need to experiment to find the shade you want

The 'S' stands for saturation. s 1 will give you full colour, s 0.3 will look very washed out. Again, experiment and see what works

'B' stands for brightness. A brightness of 0 gives black, a brighness of 1 is white. Values in between will be various shades of grey.

Below are some examples

CIRCLE{hue 0 sat 1 b 1} - Red Circle
CIRCLE{hue 0 sat .1 b 1} - Pale Pink Circle
CIRCLE{hue 0 sat 1 b .5} - Dark Red Circle

Other Useful Stuff

If you have a really cool shape that you want to use in a design but don't want to put in all the code, you can use an include. This then lets you use rules specified in a separate cdfg file.

This is often how people will include letters or special shapes in their work.

eg:

Code: Select all

startshape ripples
include dot_ripple.cfdg
This lets me use the ripples generated in dot_ripple.cfdg in a new design called "ripples".


Finally, if you want to change the background colour of your image, you can do so by using code as follows:

Code: Select all

startshape ripples
[b]background[/b]{hue 60 sat .2 b 1}
If you want a black background, you would need to say
background{b -1}

For more hints and tips, you really need to go through the examples / lessons that come with cfdg.

If anyone out there sees any mistakes / errors / ommisions in the above, please say something!

G-d Bless

Dzeni :)

Music2000
Posts: 26
Joined: Mon Oct 10, 2005 3:38 pm
Location: London

Post by Music2000 »

Thanks Dzeni, this information helps a lot :) One more quick question, what are the 3 letter things by the render and save buttons for?

dzeni
Posts: 18
Joined: Wed Sep 28, 2005 2:18 pm
Location: Auckland, New Zealand
Contact:

Post by dzeni »

An excellent question! I have no idea. I get a new code each time I open a new file but it lets me change codes without changing the design. Perhaps Chris has an answer for this one.

User avatar
aaronstj
Posts: 66
Joined: Wed Jul 06, 2005 11:34 am
Location: Seattle

Post by aaronstj »

The code is used to seed the random number generator that chooses between overlapping rules. If your code has any random elements in it, you'll get a unique design for each three letter "variation code." If you use the same variation code on the same CFDG file, you'll get the same pattern, every time.

dzeni
Posts: 18
Joined: Wed Sep 28, 2005 2:18 pm
Location: Auckland, New Zealand
Contact:

Post by dzeni »

Thanks for that handy explanation! Now it all makes sense.

Music2000
Posts: 26
Joined: Mon Oct 10, 2005 3:38 pm
Location: London

Post by Music2000 »

Thanks :)

robo git
Posts: 47
Joined: Sat Jul 09, 2005 11:36 pm
Location: looking for his marbles
Contact:

Post by robo git »

Another thing to keep in mind is that each shape is relative to the previous shape. EG:

Code: Select all

startshape Shape1 {}

rule Shape1 {
      //Create a "Shape2" shape that has been rotated by 60 degrees
      // You would get the same result if you specified a rotation of
      //negative thirty degrees
      Shape2 { r 60}
}

rule Shape2 { 
      //Create a SQUARE stretched along the Y axis RELATIVE to the "Shape2" shape
      //and another stretched along the X axis (again relative)
      //so that in effect it's drawing a cross tilted at 60 degrees.
      SQUARE { skew 1 3 }
      SQUARE { skew 3 1 }
}

So any changes you do are additive.

There is a special syntax for specifying order of changes: Use square brackets. EG:

Code: Select all

startshape Shape3 {}

rule Shape3 {
      SQUARE {}
      SQUARE [ r -30 x 1 y 1 r 30 ]
}
should give 2 squares, one slightly below and well to the right, tilted at an angle.

Music2000
Posts: 26
Joined: Mon Oct 10, 2005 3:38 pm
Location: London

Post by Music2000 »

thanks robo git :)

Post Reply