So I might have this all wrong: I'm currently having to rescale new Bitmaps of a cacheCanvas to match the caching-level it was originally created with. For example, if I do this...
container.cache(x, y, w, h, 4), where 4 is the caching-level
...then later if I do this...
const bm = new zim.Bitmap(container.cacheCanvas)
...I am also compelled to do this, to get a 1:1 scale of the original...
bm.scaleX = bm.scaleY = .25;
...am I missing something, or is this a normal requirement? If it is a requirement to rescale the new Bitmap, is there a property of cacheCanvas that lets me know what caching-level it was created with?
If you cache and object with a scale it will maintain the original scale. If you then use the cacheCanvas and pass that in to a Bitmap, then it will be the size of the cacheCanvas - which is scaled bigger in your case. I do not know of any property of the cacheCanvas that would know the scale - so probably have to set a custom property or use a variable.
Hi @josephd - patched in a cacheScale property on the ZIM Bitmap() so, setting a scale parameter when passing a DisplayObject to Bitmap() will remember this scale.
const t = new Triangle(100,100,100,red).center();
const b = new Bitmap({image:t, scale:3});
b.sca(1/b.cacheScale).center().drag();
// bitmap scaled down to the same size as the original triangle