Shading

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

Moderators: MtnViewJohn, chris, mtnviewmark

Post Reply
karcher
Posts: 1
Joined: Wed Sep 23, 2009 1:00 pm

Shading

Post by karcher »

I cant figure out how to shade objects

Can anyone help?

User avatar
kipling
Posts: 91
Joined: Wed Jun 18, 2008 2:36 am

shading

Post by kipling »

Not sure what you mean. I am guessing you mean to get something other than black. The trick is that the default for each shape is black, which is hue=0 (if any colour, it will be red), saturation=0 (OK, forget about the colour), brightness = 0 (OK forget about even making it grey.)
So if you increase the brightness by putting the attribute "b 0.5" somewhere it will lift the brightness from 0 to 0.5. This is grey. If you want this to be coloured, you can combine the brightness with some saturation: "b 0.5 sat 0.5" which is redder or "b 0.5 sat 1" which is totally red (no grey), but still darkish so "b 1 sat 1" makes it fire-engine red.
Then you can play with the hue. Have a look at the manual for more information.

User avatar
kipling
Posts: 91
Joined: Wed Jun 18, 2008 2:36 am

or ...

Post by kipling »

... or do you mean getting different colours in the same object? Do do this you have to break it down into lots of regions, each of a different fixed colour, or by overlapping lots of translucent regions.

User avatar
Guigui
Posts: 50
Joined: Sat Aug 05, 2006 5:28 pm
Location: Annecy, France

Post by Guigui »

i was wondering if you could tell me how to shade certain parts of an image?
itd be great if you could help me out.
thanks a bunch,
karcher
CF has no instruction to shade objects or shapes. You can do it anyway by different custom methods, depending of what you really want (also a simulation of shading can be found accidently). The best is to look on the code of a design that match what you mean (choose one with few code ;^)

It's maybe away from the point, but as an answer, I take it like a small exercise:

You can watch and manipulate this in CF:

Code: Select all

 startshape K

// Make a column of 12 elements …
rule K {12*{y 1.5}AR{}}

// … separated in two parts, one on the right and one on the left.
rule AR {CH{x -.75}ER{x .75}}

// The one on the right is a row of non shaded shapes going on the right.
rule CH 3{NONSHADED{}CH{x -1.5}} //(continue the row)
rule CH {} //(stop it)

// The one on the left is a row of shaded shapes going on the left.
rule ER 3{SHADED{}ER{x 1.5}} //(continue the row)
rule ER {} //(stop it)

// Here is the non shaded shape, satureted with color.
rule NONSHADED {SHAPE {b 1 sat 1}}

// Here is the shaded shape, wich is NONSHADED+ SHADOW.
rule SHADED          {NONSHADED {} SHADOW{s .9 x .3 y -.3 z -1}}

// And here is the shadow.
rule SHADOW         {30*{s .99}SHAPE { alpha -.99}}

// The shape used for all.
rule SHAPE {SQUARE{}}
8^)

Post Reply