Last active
March 21, 2016 23:38
-
-
Save damrem/b67370f003442efc4bd8 to your computer and use it in GitHub Desktop.
generates a palette with nearly 256 colors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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