CreateJS Updated to 1.5.0 - with BitmapData Class

The ZIM version of CreateJS has been updated to 1.5.0. This now includes the BitmapData class from Flash ported here:
https://github.com/u-kudox/BitmapData_for_EaselJS

with examples here:
https://github.com/u-kudox/BitmapData_for_EaselJS/tree/master/examples

and docs here:
https://airsdk.dev/reference/actionscript/3.0/

Look up BitmapData under All Classes. Press the properties and methods to see examples of each.

The basics have been added to the ZIM Docs as well under CODE and then a new subcategory of CREATEJS CLASSES.

https://zimjs.com/docs.html?item=BitmapData

// here is coloring a tile
// cache the tile to get a cacheCanvas for the BitmapData
STYLE = {color:white, borderColor:black, borderWidth:3, backdropColor:white, backdropPadding:20};
const tile = new Tile([new Circle(50), new Rectangle(100,100)],5,4,20,20).cache();

// Create a new createjs.BitmapData - needs a canvas
const bitmapData = new createjs.BitmapData(tile.cacheCanvas);

// Just a normal ZIM ColorPicker
STYLE = {shadowColor:-1};
const picker = new ColorPicker(250, [red,orange,green,yellow], 4)
    .pos(0,30,CENTER,BOTTOM);

// Make a Bitmap to show the bitmapData.canvas
const bitmap = new Bitmap(bitmapData.canvas).center().cur();
bitmap.on("mousedown", ()=>{
    // convert our mouse point to a point on the bitmap
    const point = bitmap.globalToLocal(F.mouseX, F.mouseY);
    // avoid pressing on a dark color
    const currentColor = bitmapData.getPixel(point.x, point.y);
    if (currentColor<convertColor(dark, "hexnumber")) return;
    // get the colorPicker color as hexstring - needed for floodFill
    const newColor = convertColor(picker.selectedColor, 'hexstring');
    // do a floodFill from the point with the new color
    bitmapData.floodFill(point.x, point.y, newColor);
    S.update();
});    

There are some other goodies in the BitmapData class including putting a rectangle around a color, palette options, etc. Actually, u-kudox (u-kudox) · GitHub has ported other Flash classes too including a couple 3D matrix and vector classes. Check the examples section of each of the repositories. I did not see anything beyond data examples - in the console - but it would be neat to see if these lead to 3D support - like P5js has.

1 Like

We will work on a NPM update once this gets tested a bit.

There was a hiccup in the launch - thanks @EZ123 - in the module version when we excluded the three createjs classes from the export we matched their ClassName and we needed to match createjs.ClassName. That has been patched. It only affected some commands and therefore some files.

waauw it works super! thanks @abstract
today and tomorrow is there a school exhibition in Belgium, https://www.sett-vlaanderen.be/nl/
I will spread the zapp to show what ZIM can do now also

1 Like

Great news!! :slight_smile:

1 Like