Snapshot within a circle
Jim Hurley
jhurley0305 at sbcglobal.net
Fri Jan 3 16:13:12 EST 2014
Thanks Richard. I appreciate the details. I can see now how that would be more useful. I had to go to a lot of trouble to hide all the objects close to my oval graphic so that they would not be caught up in the Rect of the oval.
But I can’t seem to make this method work for me. It isn’t just the grc “oval” that I want to export to Preview, but the grc “oval” (which is just a black circle) but the kaleidoscopic the image “my image” that is painted on it.
I tried grouping the img and the grc as in the following script:
on mouseUp
ask "Please name this image." with "Kaleidoscope"
--hide group "showhidegroup"
if it is "" then exit mouseUP
put "/" & it & ".png" into tName
put specialFolderPath ( "desktop") & tName Into tPathAndName
-- put specialFolderPath("desktop") & "/Kaleidoscope.png" into tPathAndName3
-- put specialFolderPath("desktop") & tImageName into tPathAndName2
if there is a group "exportGroup" then delete group "exportGroup"
group img "myImage" and grc "oval"
set the name of last group to "exportgroup"
export snapshot from group "exportGrouP" to file tParthANdName as PNG
-- export snapshot from graphic "CC" to file "Circle.png" as PNG
-- export snapshot from rect (rect of graphic "oval") of this card to file tPathAndName as PNG
launch document tPathANDNAME
ungroup group "exportGroup"
end mouseUp
But nothing at all shows up in Preview. Is there some other way to put the img that rests atop the grc so that they may be exported together?
Thanks,
Jim
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