Use of Colour

You can assign a colour by using (1) one of 16 inbuilt strings, (2) one of 148 inbuilt TColors or (3) your own red, green and blue values.

The easiest way to assign a colour is to use an inbuilt string with code such as Canvas.StrokeStyle := 'red';. See this Mozilla page for a large number of colours such as 'thistle' and 'darksalmon' that are recognised by the javascript translator.

You can look for an inbuilt TColor at the start of the W3Graphics unit (SmartCL.Graphics in Version 2.1 and System.Colors in Version 3.0). Examples include clAliceBlue, clAntiqueWhite, clAqua, clAquamarine, clAzure, clBeige and clBisque. Use one with code such as

Canvas.FillStyle := ColorToWebStr(clAliceBlue); 

An example of the use of your own RGB values is

Canvas.FillStyle := 'rgb(189, 200, 179)'; // RobinEggBlue    

An example with an alpha value is

Canvas.FillStyle := 'rgba(0, 255, 0, 0.5)';

The use of alpha values is vital in Alex Karet's BlendingEllipses.

Programming - a skill for life!

Commonly used routines for drawing on a canvas and the use of another unit, colour, different fonts and transforms