Skip to content

Instantly share code, notes, and snippets.

@damrem
Last active March 21, 2016 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save damrem/b67370f003442efc4bd8 to your computer and use it in GitHub Desktop.
Save damrem/b67370f003442efc4bd8 to your computer and use it in GitHub Desktop.
generates a palette with nearly 256 colors
class Test {
static function main() {
var canvas=new flash.display.Sprite();
flash.Lib.current.stage.addChild(canvas);
var gfx=canvas.graphics;
var x;
var y;
var c:Int;
var i;
var n=6;
var size=4;
var space=5;
var nbCols=25;
for(r in 0...n)
{
for(g in 0...n)
{
for(b in 0...n)
{
i=r*25+g*5+b;
x=i%nbCols*space;
y=Std.int(i/nbCols)*space;
var rr=Std.int(r*256/n);
var gg=Std.int(g*256/n);
var bb=Std.int(b*256/n);
c=(rr<<16)+(gg<<8)+bb;
gfx.beginFill(c);
gfx.drawRect(x,y,size,size);
gfx.endFill();
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment