doppler Posted June 24, 2016 Share Posted June 24, 2016 Does anybody know how to subtract the alpha values from a shape? After hours of research, my best bet is to utilize an alpha filter (link) The current Shape.mask value does not seem to have an easy way to invert masks (link) Example of what I want to achieve: Quote Link to comment Share on other sites More sharing options...
Anders Athletic Design Posted June 28, 2016 Share Posted June 28, 2016 I have not yet worked with the alpha filters but for a normal mask I don't think there is an easy way of doing it. I would probably have made the inverted mask in Flash IDE and then exported it with Toolkit For CreateJS. That is, the exported mask would be a big rectangle with a cut out circle in the middle. A 100x100 rect with a 33 diameter circle in the middle produces the following code: this.shape = new cjs.Shape(); this.shape.graphics.beginFill("rgba(255,255,255,0.761)").beginStroke().moveTo(-50,50).lineTo(-50,-50).lineTo(50,-50).lineTo(50,50).closePath() .moveTo(-12.2,-12.1).curveTo(-17,-7.3,-17,-0.5).curveTo(-17,6.4,-12.2,11.1).curveTo(-7.3,16,-0.5,16).curveTo(6.4,16,11.1,11.1).curveTo(16,6.4,16,-0.5).curveTo(16,-7.3,11.1,-12.1).curveTo(6.4,-17,-0.5,-17).curveTo(-7.3,-17,-12.2,-12.1).closePath(); Quote Link to comment Share on other sites More sharing options...
doppler Posted June 28, 2016 Author Share Posted June 28, 2016 Thank you so much for creating that example! I didn't even think about using Adobe Animate (Adobe Flash) first haha I did some research and found another possible solution with the help of 'caching' http://jsfiddle.net/lannymcnie/17xec9y5/9/ Apparently containers have the ability to utilize updateCache("destination-out") to 'erase' pixels in the cache: // Listen for the image load testImg.image.onload = function() { cont.updateCache("source-over"); // Update cache once cont.removeChild(testImg); // Remove image stage.update(); // Draw the stage to see the image } // Create a sub-container that will hold the art and image var cont = stage.addChild(new c.Container()); art = new c.Shape(); // Art is just the shape cont.cache(0,0,600,400); // Cache the container instead cont.addChild(testImg, art); // Then, later update the container's cache (instead of the art) cont.updateCache(erase.checked ? "destination-out" : "source-over"); I'll see which one works best, thanks again! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.