1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
// on créé les données bitmap aux dimensions du clip
var data:BitmapData = new BitmapData (toto.width, toto.height, true);
// On positionne le clip
var image:Bitmap = new Bitmap (data);
image.x += 310;
image.y += toto.y;
addChild( image);
// Permet d'éviter les débordements
var transfo:Matrix = toto.transform.matrix;
transfo.tx = 0;
transfo.ty = 0;
var debordement:Rectangle = toto.getBounds(toto);
transfo.translate(-debordement.x * toto.scaleX, -debordement.y * toto.scaleY);
// affiche sous forme bitmap les données vecto
data.draw( toto, transfo );
var couleur:uint;
/*Dans la boucle je teste chaque pixel avec getPixel,
bon pour gérer la transparence j'ai vérifié s'il y avait
la couleur blanche, y a surement une méthode qui le
fait tout seul ! Et après avec setPixel on remplace par
une couleur, si tu veux une couleur aléatoire pour
chaque couleur tu peux créer une variable aléatoire !*/
for(var i:int=0; i<data.width; i++){
for(var j:int=0; j<data.height; j++){
if(data.getPixel(i,j) == 0xffffff){
data.setPixel32(i,j, 0xffffff);
trace("blanc");
}
else
data.setPixel(i,j, 0x99bb22);
}
} |
Partager