Problem with mask

Wilhelm Sanke sanke at
Tue Oct 21 17:38:57 EDT 2008

In the meantime Jim has sent me the essential script offlist from which 
I recreated a test stack.

He wrote (to this list):

> Well, my problem with mask is no more.
> Turns out the Run Rev within() function is a bit strange.
> The masked ellipse is flat on the right side and the bottom because 
> within() counts the left and top  of a graphic to within the graphic, 
> but not the right and bottom.

Well, among the variations I tried with your script there is one where I 
reversed the direction of "scanning" the graphic.

"put the topLeft of img 1 into tTopLeft
  put item 1 of tTopLeft into x0
  put item 2 of tTopLeft into y0
# repeat with j = 1 to tHeight
  # repeat with i = 1 to tWidth
#now. reversed direction
  repeat with j =  tHeight down to 1
    repeat with i =  tWidth down to 1
      put x0+i,y0+j into tPt
      if within(grc 1, tPt) then
        put tClear after tData
        put tBlock after tData
      end if
    end repeat
  end repeat"

The result of this change of direction is that now the flat edges appear 
on the left and on top, meaning we still need to define a "within" bug 
more accurately, but I don't know how.

 Increasing the rect of the image so that it extends to outside the rect 
of the graphic does not make any difference.

In the case of Photo Patchworks such a strategy worked with a "padded" 
corresponding template image whose transparency mask was then used for 
the cropped image of the same size.
Only the "edges" I got from a non-padded mask image are different from 
Jim's: I get black lines by the side and not flattened edges.

Joe Lewis Wilkins pepetoo at wrote:

> Hi James,
> In one of this threads first responses, I implied as much when I said 
> that you probably needed to subtract one from all right and bottom 
> coordinates, since this has been a problem for a very long time. Of 
> course, I don't know if just a minus one would have cured everything, 
> but it may have helped.


if what you mean is a change in the script  like here

repeat with j = 1 to tHeight -1
   repeat with i = 1 to tWidth -1

then you get a distorted mask because the mask data  to not fit exactly 
into the rect of the image.

I am still puzzled by this bug.

Best regards,

Wilhelm Sanke

More information about the Use-livecode mailing list