[comp.sys.mac.programmer] lasso effect?

tim@hoptoad.uucp (Tim Maroney) (12/29/89)

I'm using a C version of David Berry's marquee selection code on some
MacPaint documents (thanks, dwb!)  It works very well.  Now how do I do
a lasso effect?  I don't mean the tracking and region computation.  I
mean the weird shimmering that MacPaint and HyperCard do once the item
is selected.

I've tried to reverse engineer it with MacsBug, but MP and HC don't
seem to be using traps to do it.  Neither HyperCard nor MacPaint seem
to be calling any relevant traps.  Step Spy mode shows a sort of
diagonal striping that is strangely context sensitive; e.g., it doesn't
happen on solid black regions, but does on "dotted" regions.

Anyone know what's going on here?
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

FROM THE FOOL FILE:
"Women's wages are 56% of men's -- but that's not necessarily evidence
 of discrimination in employment."
  -- Clayton Cramer in news.groups and soc.women

ewing@tramp.Colorado.EDU (EWING DAVID JAMES) (01/01/90)

In article <9423@hoptoad.uucp> tim@hoptoad.uucp (Tim Maroney) writes:
>I'm using a C version of David Berry's marquee selection code on some
>MacPaint documents (thanks, dwb!)  It works very well.  Now how do I do
>a lasso effect?  I don't mean the tracking and region computation.  I
>mean the weird shimmering that MacPaint and HyperCard do once the item
>is selected.

If you have a region you can get the effect by simply calling FrameRgn() with
successive patterns (using PenPat() of course).  If you've created a disjoint
region with CalcMask() and BitMapToRegion(), then this will look just the way
you want it.  There's probably another way to do this using CalcMask and
CopyMask (i.e. without a region), but I can't figure it out right away.

Dave Ewing
ewing@tramp.colorado.edu  (128.138.238.33)
..!hplabs!boulder!onecom!tyvax!iftech!dave (My Mac IIx running uupc & MacOS!)
AppleLink: D2408	  (D2408@applelink.apple.com)

jackiw@cs.swarthmore.edu (Nick Jackiw) (01/01/90)

tim@hoptoad.uucp (Tim Maroney) writes:
> Now how do I do
> a lasso effect?  I
> mean the weird shimmering that MacPaint and HyperCard do once the item
> is selected.
> 
> I've tried to reverse engineer it with MacsBug, but MP and HC don't
> seem to be using traps to do it.  Neither HyperCard nor MacPaint seem
> to be calling any relevant traps.  Step Spy mode shows a sort of
> diagonal striping that is strangely context sensitive; e.g., it doesn't
> happen on solid black regions, but does on "dotted" regions.

I'm using MacPaint 2.0 (zebrawoman version) and I get rightward marching
diagonal white stripes on any lassoed black solid. I get double-thick
white lines marching leftward with a 1-2-1 pixel step on solid gray
regions.  If this is the behavior you seek to emulate, it seems to me
it could be done by displaying (copyBits,srcCopy) a copy of the image
bit ANDed with a solid pattern along the lines of

01011111
10101111
11010111
11101011
11110101
11111010
01111101
10111110

At each step, rotate the entire pattern one bit rightwards, reAnd your
source, and recopy to destination. Rotating the pattern is best done by
just incrementing your initial index into an 8-byte wraparound pattern
array. The variance between solid black behavior and solid gray would be
accounted for, in this model, by the occasional synchopation of the diagonals in
the striping pattern with the implicit white diagonals in a gray pattern,
creating a moire effect.  The lack of traps in HC and MP could reflect
the fact that it would be much faster to extend the pattern into a 32 longword
array, and directly mask the image in memory (AND.L (A0)+) rather than do it
with quickdraw (PenMode(patAnd), FrameRect(stripePattern)).

Disclaimer:
I've no idea how either of the programs you reference do it, but it seems
like this method would duplicate MacPaint 2.0's behavior.


  
> 
> Anyone know what's going on here?
> -- 
> Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com
> 
> FROM THE FOOL FILE:
> "Women's wages are 56% of men's -- but that's not necessarily evidence
>  of discrimination in employment."
>   -- Clayton Cramer in news.groups and soc.women


-- 
     _  _|\____    Nick Jackiw | Visual Geometry Project | Math Department
   / /_/   O>  \   ------------+-------------------------+ Swarthmore College
   |       O>   |  215-328-8225| jackiw@cs.swarthmore.edu| Swarthmore PA 19081
    \_Guernica_/   ------------+-------------------------+                 USA

yahnke@vms.macc.wisc.edu (Ross Yahnke, MACC) (01/02/90)

In article <9423@hoptoad.uucp>, tim@hoptoad.uucp (Tim Maroney) writes...
-I'm using a C version of David Berry's marquee selection code on some
-MacPaint documents (thanks, dwb!)  It works very well.  Now how do I do

DuBois's TransSkel project, available from sumex et al, has some
working Think C code that demonstrates how this is done.

>>>      Internet: yahnke@macc.wisc.edu        <<<
>>>   Mille voix chuchottent <<c'est vrai>>    <<<