Global color constants
The following global color constants exist: ldkblack, ldkwhite, ldkSemiTransparentBlack, ldkinvisible.

Defining a color
Colors are, by default, defined in the ARGB (alpha/red/green/blue) format, where each can have a value from 0-255. Note that having complex alpha effects can be slow on some browsers. You declare a new color like so: myColor=new color(a,r,g,b);
Colors have 4 variables and 2 methods. The 4 variables are a, r, g, and b. One of the two methods, hexSet, hopefully you'll never need to use. The other, hexGet, returns the hexidecimal value of the color. For example, a color with a r=255,g=0,b=0 returns "FF0000". Note that alpha information is ignored.

Defining a color using a hexidecimal code
To do this, the game object has this method: makeColor(h). h is a reference to a hexidecimal string. The function returns the newly-created color. By default, this color will have an alpha value of 255.

Merging 2 colors
If you want to create a gradient effect or something, use the mergeColors(c1,c2,m) function of the game object. c1 and c2 are the colors to be merged. m is the percentage of c1 that will make up the new color, while 100-m is the percentage of c2 that will make up the new color. A true mix of both colors has an m value of 0.5.

Javascript color constants
As you know, javascript has already defined a number of color constants. These are, however, not useable with ldk objects. You can of course import them using the makeColor method, where h is the name of the javascript color.

Last edited Dec 13, 2009 at 9:34 PM by larztheloser, version 1


No comments yet.