Design Challenge -- Round Corner mask on images

Alejandro Tejada capellan2000 at gmail.com
Tue Mar 29 01:13:55 EDT 2016


Hi All,

By trial and error, (the worse kind of error)
I finally find a script that mask an image using 
a vector graphic. Follow these steps to make
it work.

1)  create a new stack and import an image

2) over this image, draw a closed vector graphic
using any drawing tool (including freehand
or freehand polygon)

3) in this same stack, (that only have two objects:
an image and a single vector graphic)
create a button and set the script of this button
to this:

on mouseUp

    set the locklocation of img 1 to true
   import snapshot from img 1
   set the loc of img 2 to the loc of img 1
   delete img 1
   -- after deleting img 1, img 2 becomes img 1 
  
   crop img 1 to the rect of grc 1
   
   set the opaque of grc 1 to true
   set the foregroundColor of grc 1 to black
   set the linesize of grc 1 to 0
   set the ink of grc 1 to srcCopy
   set the width of grc 1 to the width of img 1
   set the height of grc 1 to the height of img 1
   
   import snapshot from grc 1 -- this snapshot created image 2

   set the alphadata of image 1 to the alphadata of image 2
   
   delete grc 1 -- vector graphic 
   delete img 2 -- image 
end mouseUp

Works fine here, but could be enhanced
in many ways, for example:

Who wants to extend this script to mask
images using the alphadata from
transparent png and static transparent 
gif images?

Thanks in advance!

Alejandro




--
View this message in context: http://runtime-revolution.278305.n4.nabble.com/Design-Challenge-Round-Corner-mask-on-images-tp4702659p4702723.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list