Context Free Art

Shape adjustments

From Context Free Art

Jump to: navigation, search

Contents

Shape Adjustments: Geometry and Color

There are two categories of shape adjustments: geometric and color. Anywhere that you see num there can either be a numeric constant or a constant expression.

Geometry Adjustments

The geometry of shapes is defined by a two dimensional affine transform which is represented internally as a matrix.

Adjustment Meaning Notes
x num translation along the x-axis by num  
y num translation along the y-axis by num  
z num translation along the z-axis by num The z-axis position determines which shape is on top when they overlap.
The z-axis position is not stored in the affine transform matrix and does not affect the shape of objects.
size num
or
s num
scale in x and y by num  
size num1 num2
or
s num1 num2
scale in x by num1 and in y by num2  
size num1 num2 num3
or
s num1 num2 num3
scale in x by num1, in y by num2, and in z by num3 The z-axis scale is not stored in the affine transform matrix and does not affect the shape of objects.
rotate num
or
r num
rotate in the x/y plane num degrees  
flip num
or
f num
reflect in x/y plane across a line through the origin at num degrees  
skew num1 num2 shear transform in x/y plane num1 degrees from the y axis and num2 degrees from the x axis  


Color Adjustments

The color of a shape is represented by two points in the HSBA color space (HSB color plus alpha, or opacity). One point is the color that the shape is actually drawn in and the other point is a target that the drawing color trends toward. The HSBA coordinates are [0,360) for hue, [0,1] for saturation, [0,1] for brightness, and [0,1] for alpha (opacity).

hue num
add num to the drawing hue value, modulo 360
saturation num
range [-1,1]. If num<0 then change the drawing saturation num% toward 0. If num>0 then change the drawing saturation num% toward 1.
brightness num
range [-1,1]. If num<0 then change the drawing brightness num% toward 0. If num>0 then change the drawing brightness num% toward 1.
alpha num
range [-1,1]. If num<0 then change the drawing alpha num% toward 0. If num>0 then change the drawing alpha num% toward 1.
|hue num
add num to the target hue value, modulo 360
|saturation num
range [-1,1]. If num<0 then change the target saturation num% toward 0. If num>0 then change the target saturation num% toward 1.
|brightness num
range [-1,1]. If num<0 then change the target brightness num% toward 0. If num>0 then change the target brightness num% toward 1.
|alpha num
range [-1,1]. If num<0 then change the target alpha num% toward 0. If num>0 then change the target alpha num% toward 1.


Abbreviations: 'hue' can be abbreviated as 'h', 'saturation' can be abbreviated as 'sat', 'brightness' can be abbreviated as 'b', and 'alpha' can be abbreviated as 'a'.


Targeting a Color

There are four more drawing color adjustments for changing the drawing color components with respect to the target color. This useful is you have a recursive shape rule that adjusts a color component and you don't want to overshoot a value. For example, the drawing hue is red and you want the drawing hue to trend toward yellow, but never go past yellow to green.

hue num|
range [-1,1]. If num<0 then change the drawing hue num% toward the target hue moving clockwise around the color wheel. If num>0 then change the drawing hue num% toward the target hue counter-clockwise around the color wheel.
saturation num|
range [-1,1]. If num<0 then change the drawing saturation num% toward 0 or the target saturation, whichever is closer. If num>0 then change the drawing saturation num% toward 1 or the target saturation, whichever is closer.
brightness num|
range [-1,1]. If num<0 then change the drawing brightness num% toward 0 or the target brightness, whichever is closer. If num>0 then change the drawing brightness num% toward 1 or the target brightness, whichever is closer.
alpha num|
range [-1,1]. If num<0 then change the drawing alpha num% toward 0 or the target alpha, whichever is closer. If num>0 then change the drawing alpha num% toward 1 or the target alpha, whichever is closer.


Example: Targeting yellow

For example, the following code applied consistently when drawing shapes, will change the initial hue 0 (red) quickly to yellow (hue 60) but not let it go past yellow towards green:

MyShape { h 60|h 0.99 } // yellow hues


More on targeting colors can be found in the tutorial Targeting a color.

Some common hues

Remember that the initial hue is always 0, i.e red. Some common hues follow:

Hue number Primary Secondary Tertiary
0 Red    
30     Orange
("Red-Yellow")
60   Yellow  
90     Yellow-Green
120 Green    
150     Aqua
("Green-Cyan")
180   Cyan  
210     Turquoise
("Cyan-Blue")
240 Blue    
270     Violet
("Blue-Magenta")
300   Magenta  
330     Reddish Purple
("Magenta-Red")
360 (=0) Red    
Views
Personal tools
Navigation
Toolbox
MediaWiki
Attribution-Share Alike 2.5
book coverSee our book:
Community of Variation