Snapshot within a circle

Richard Gaskin ambassador at fourthworld.com
Fri Jan 3 15:13:45 EST 2014


Jim Hurley wrote:

 > So, at long last, my question. Is there a way within RunRev, by
 > script,  to erase all color pixels outside the circle before sending
 > it off to Preview?
 >
 > Here is the code (thanks to someone out there, I sorry about
 > forgetting who you are, I’m 81 now with ever diminishing cognitive
 > abilities) to get the image into Preview:
 >
 > on mouseUp
 >   ask "Please name this image." with "Kaleidoscope"
 >   hide group “showhidegroup” —Everything outside the oval rect is
 > hidden.
 >         if it is "" then exit mouseUP
 >         put "/" & it & ".png" into tName
 >         put specialFolderPath ( "desktop") & tName Into tPathAndName
 >         export snapshot from rect (rect of  graphic "oval") of this
 > card  to file tPathAndName as PNG
 >         launch document tPathANDNAME —That turns out to be Preview on
 > he Mac
 >         show group “showhidegroup” —Show the things previously hidden
 > end mouseUp

In Richmond's example, the key is using "...from <object>..." rather 
than "...from rect...":

    export snapshot from graphic "CC" to file "Circle.png" as PNG

The "from <object>" option was added in v2.7 during the first of several 
overhauls to the internal compositing subsystem, allowing the object 
specified to be rendered into its own export buffer directly, as opposed 
to the "from rect" option which grabs the specified portion of the 
composited card image.

Since "from <object>" will preserve any object transparency within the 
bounds of the specified object in most cases it's what we want, so much 
so that I consider "from rect" to be more or less obsolete, useful only 
in those rarer cases where the final composite of everything on the 
card, including the card itself, is actually what you want.

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  Follow me on Twitter:  http://twitter.com/FourthWorldSys





More information about the Use-livecode mailing list