mask canvas

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

Post Reply
monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

mask canvas

Post by monte » Tue Mar 24, 2015 12:44 am

Is there any way to apply a mask to the canvas? At this stage I'm thinking specifically of drawing an image and then applying a mask to it like a circle. Perhaps we could draw an image into a path rather than just a rectangle?
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: mask canvas

Post by LCMark » Tue Mar 24, 2015 10:06 am

@monte: We do need to add a clip to path ability to the canvas which would be the easiest way to do this... For now you could try using the image as a pattern, and fill the path. If the pattern has a suitable transform (translated appropriately) then you should be able to get much the same effect.

LCMark
Livecode Staff Member
Livecode Staff Member
Posts: 1209
Joined: Thu Apr 11, 2013 11:27 am

Re: mask canvas

Post by LCMark » Tue Mar 24, 2015 11:20 am

@monte: Having thought about this for a bit, it is far more efficient to use the pattern approach if you only need to mask a single image. General soft clipping to an arbitrary path is a relatively expensive operation as the mask has to be precomputed (and intersected ahead of time with any existing clip region). Filling a path with a pattern requires no precomputation - rasterisation can occur scanline by scanline simultaneously using the data from the pattern and path.

I wonder if adding a 'draw image with mask' syntax might be a good idea here - the mask could either be an image (treated as a mask) or a path and the command can do the necessary twiddling to fill as a pattern rather than setting a clip and filling.

monte
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1564
Joined: Fri Jan 13, 2012 1:47 am
Contact:

Re: mask canvas

Post by monte » Wed Mar 25, 2015 12:02 am

@LCMark that sounds very nice
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Post Reply

Return to “LiveCode Builder”