Version 1.2 experimental color build is now available
Posted: Sun Jul 24, 2005 11:04 pm
By popular demand, a color version of Context Free/CFDG has been put on the download page. Special thanks to aaronstj and Stephen Deken for their patches. Mark (the curmudgeon) says "Please, no garish rainbows!"
The new version is considered experimental and is put along-side version 1.1. The reason behind this is that we are not sure that the color manipulation model is right. Not that there are bugs (never!), but that the whole way of handling color may need rework. Be warned, scripts written for the experimental builds might be broken by changes made to the color model.
The documentation for color is pretty sketchy. Its just this post and what can be gleaned from welcome.cfdg and rose.cfdg. Sorry. Improved documentation is probably the next important thing to do for Context Free/CFDG.
The color model is the hue-saturation-brightness-alpha color space. In addition to the existing brightness adjustment we have added hue(h), saturation(sat), and alpha(a) adjustments. Saturation and alpha work just like brightness. Hue is like a rotation: 0 is red, 120 is green, and 240 is blue. So 'sat 0.5' moved the saturation 50% closer to 1 while 'hue 5' simply adds 5 to the hue value.
You can also set color values absolutely. For example, 'hue =180' sets the hue to cyan, and 'b =0.75' sets the brightness to 75%. Here is an example:You will notice that there is stuff at the end of the startshape line. This is a new piece of syntax called a parameter. The 'color' parameter tells Context Free/CFDG to create a color canvas. There is also an 'alpha' parameter that should be used when alpha is used. The current version provides color+alpha if either parameter is present. With no parameters the old 8-bit grayscale canvas is used. We felt that it was important to keep the 8-bit canvas for people who want to create very large images.
The new version is considered experimental and is put along-side version 1.1. The reason behind this is that we are not sure that the color manipulation model is right. Not that there are bugs (never!), but that the whole way of handling color may need rework. Be warned, scripts written for the experimental builds might be broken by changes made to the color model.
The documentation for color is pretty sketchy. Its just this post and what can be gleaned from welcome.cfdg and rose.cfdg. Sorry. Improved documentation is probably the next important thing to do for Context Free/CFDG.
The color model is the hue-saturation-brightness-alpha color space. In addition to the existing brightness adjustment we have added hue(h), saturation(sat), and alpha(a) adjustments. Saturation and alpha work just like brightness. Hue is like a rotation: 0 is red, 120 is green, and 240 is blue. So 'sat 0.5' moved the saturation 50% closer to 1 while 'hue 5' simply adds 5 to the hue value.
You can also set color values absolutely. For example, 'hue =180' sets the hue to cyan, and 'b =0.75' sets the brightness to 75%. Here is an example:
Code: Select all
// We have to declare the color parameter in the startshape
// or else a grayscale canvas will be created.
startshape GarishRainbow {color}
rule rainbow {
// this draws the actual bow, as a full circle
CIRCLE { }
// this chops off the bottom half to make the "bow"
SQUARE {sat =0 y -0.5}
// rotate the color and fade to white
rainbow {s 0.99 hue 10 sat -0.04}
}
rule GarishRainbow {
rainbow { b 1 sat 1 }
}