|
|
|
< irregular polygons |
Colour |
animation > |
|
|
Control of colour is one thing that makes Tymless special. You can manipulate the red, green and blue parts of a colour quite separately using the $r, $g and $b system variables. Each of these holds a value between 0 and 1, saying how much of that primary colour is used to make up the compound colour. For example, here is one way to draw a red square: // a red square You can access the current colour using the $c system variable, and use the rgb function to set a whole colour at once: // a blue square! The value of these system variables really becomes apparent when you want to create gradients or other effects involving changes of colour: // a gradient from blue to red You can also control the hue, saturation and brightness components of a colour using $h, $s and $v. Hue represents the colour-wheel. Its value indicates the angle of the colour around the wheel (in radians). It takes values from 0 (red) to pi*2 (also red, being a full circle!). Values outside this range are equally acceptable, but the colours repeat. Saturation means the 'colourfulness' of the colour. The less saturation the more insipid the colour. A saturation of 0 will be white or grey. The maximum saturation is 1. Brightness is self-explanatory. A brightness of 0 means black, whatever the hue or saturation. The maximum brightness is 1. // a square colour wheel! This program draws a grid of squares and colours them according to their direction from a random point within the grid. The grid is drawn using two loops. The random point is created using the random function ??. The direction from the random point is found using the query-direction function !?. The hue of each square is set to this direction on the colour-wheel. Colours can also be assigned to variables, and manipulated via system properties.
|
|
< irregular polygons |
animation > |