Run Rev's within() function--Was: Problem with mask

James Hurley jhurley0305 at sbcglobal.net
Fri Oct 24 12:34:00 EDT 2008


Wilheim,

I see what you mean about the those flipping (no vulgarity intended)  
flat spots, depending on the direction of the scan, left to right, or  
right to left.

I have no way to account for this. I suspect the flip flop must occur  
when setting the alphaData, but that is a wild guess.

I wrote a CARD script which seems to confirm that the TOP and LEFT of  
a rectangle are within (in the Run Rev within() fuction sense) while  
the right and bottom are not.

If you create a square graphic, 100 units on a side and make it  
opaque, you will find if you click into the square and run the mouse  
over the square, that the two within functions (user defined and Run  
Rev defined) do agree on the RIGHT and BOTTOM but they do not agree  
on the TOP and LEFT. Of course they agree everywhere within the  
boundary.

So the mystery goes on.


local myname, X0, Y0

on mouseDown
   put the name of the target into myName
   put myName
   put the topleft of myName into tXY
   put item 1 of tXY into X0
   put item 2 of tXY into Y0
end mouseDOwn

on mouseUP
   put "" into myName
end mouseUP

on mouseMove u,v
   if myName is "" then exit mouseMove
   put u,v into tPt
   --Get displacement from upper left corner
   put u - x0 into dx
   put v - y0 into dy

--User defined "within" function
   if dx > 0 and dx < 100 and dy > 0 and dy < 100 then
     put true into myWithin
   else
     put false into myWithin
   end if

--Built-in within() function
   if within(myName, tPt) then
     put true  into runRevWithin
   else
     put false into runRevWithin
   end if

   put myWithin & cr & runRevWIthin into msg box
end mouseMove

Jim Hurley

> Message: 10
> Date: Thu, 23 Oct 2008 23:15:05 +0200
> From: Wilhelm Sanke <sanke at hrz.uni-kassel.de>
> Subject: [ANN] and Re: Problem with mask
> To: use-revolution at lists.runrev.com
> Message-ID: <4900E959.4010203 at hrz.uni-kassel.de>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> I have uploaded a sample stack containing 8 different scripts for
> creating masks and generating oval images.
>
> <http://www.sanke.org/Software/ThreeMasks.zip>.
>
> Stack "Three Masks" demonstrates and lets you compare the  
> approaches of
> Jim Hurley, Scott Rossi, and my own.
>
> All examples use the same basic selelection procedure with a  
> draggable,
> resizable, and reshapable and already grouped selection graphic
> (applying the same routines I use for my selection graphic of  stack
> "Seamless Tiles 2"), which makes it easy  to compare the effects of a
> specific identical size and shape of the selection graphic across  
> the 8
> examples.
>
> There are three examples based on Jim's script:
>
> - The first uses his almost unchanged script, which produced the "mask
> problem" with flattened edges on the right and at the bottom.
> - In the second exampled I have reversed the direction of Jim's
> "within"-scan, with the result that now the edges appear on the  
> left and
> on top
>
> Because of the different edge effects I am not sure if  the "mask
> problem" is caused by a bug in the within-function or could rather be
> remedied by more precise (?) scan routines. I have tried to change  
> this
> part of the script in various ways, but without success. Maybe Bernd
> Niggemann' approach, which I could not yet include here, will show  
> other
> possibilities.
>
> - The workaround-solution of the "mask problem" in the third example
> based on Jim's script combines the two examples above. I use a scan in
> two directions producing two masks with edges at different places. I
> then combine the two masks, which then results in a perfectly rounded
> mask without any flattened edges.
> All oval images produced by the above examples display a slight  
> "roughness".
>
> Scott Ross's approach, taking a snapshot from the rect of the  
> selection
> graphic, produces oval images with a very smooth fringe.
> As my selection tool is already a grouped one, in my minor necessary
> adaptation of Scott's script the grouping and later ungrouping of the
> oval graphic was no longer needed, as was also the resetting the
> templategroup.
> I am wondering if we could avoid or suppress the flickering that  
> appears
> when taking the snapshot?
>
> In my own 4 examples no masks are created by script. I use  
> prefabricated
> masks in the form of imported invisible images that are then  
> adapted to
> the size and shape of the oval selection graphic. Hence, basically  
> only
> 4 script lines are needed to crop the image and apply the mask.
> The masks selected as examples are named "plain oval", "small fringe",
> "wide fringe", and "transition".
>
> Best regards,
>
> Wilhelm Sanke
> <http://www.sanke.org/MetaMedia>
>
>




More information about the use-livecode mailing list