GrassHopperPebbles.com Demos

gpColorSchemes - Examples

The following example displays the 34 preset color schemes stored in the gpColorSchemes Class. To use the gpColorSchemes class with the gpShapes class, simply remove the bgColor, borderColor, and borderSize options from the XML attributes and replace them with color scheme preset name of your choice.

< pStyles cType="shape1" nW="200" nH="100" shape_type="rectangle" corners="7,7,7,7" colorSchemeName="gpLimeGreen4" />

To use the gpColorSchemes class independently of the gpShapes class:


import flash.display.Sprite;
import com.grasshopper.utils.*;

var cScheme:gpColorSchemes = new gpColorSchemes('gpDarkGrey4', false);
var colorScheme:Object = cScheme.getColorScheme();

var sp:Sprite = new Sprite();
addChild(sp);
sp.x = 100;
sp.y = 100;

var matrix = new Matrix();
matrix.createGradientBox(100, 50, Math.PI/2, 0, 0);

sp.graphics.beginGradientFill(GradientType.LINEAR, colorScheme.bgColor, colorScheme.cAlphas, colorScheme.ratio, matrix);
sp.graphics.lineStyle(colorScheme.brdrSize, colorScheme.brdrColor, 1.0);
sp.graphics.drawRect(0, 0, 100, 50);

For documentation about the gpColorSchemes Class, view the blog post.

Tags

, , , , , ,