[comp.sys.mac.programmer] The old "dragging a pict" problem...

phil@mva.cs.liv.ac.uk (03/08/90)

Has anyone used Superpaint, and noticed the efect you get when you drag a
picture that has a patterned filling around the screen?  The object moves - but
the pattern stays relative to a fixed point.  I'm writing
a program, which lets the user drag a picture around the screen.  Some of the
pictures are bitmaps, some are filled polygons or quite complicated quickdraw
pictures.  The system I'm using at the moment is to draw the picture once into
an offscreen bitmap, and then to blat it on at the correct location as themouse
moves around, while simultaneously redrawing the stuff that was underneath, and
copying new stuff out of the way.  My problem is that using this method, the
pattern gets out of sync.  Any sugggestion from anyone as to how to emulate
that SuperPaint system (for very complicated pictures, just redrawing the
picture over and over takes too long!)

If I get any useful replies I'll summarise them here.

Phil Jimmieson,           ***************************************************
Computer Science Dept.,   * JANET : PHIL@UK.AC.LIV.CS.MVA                   *
Liverpool University,     * ARPA  : PHIL%mva.cs.liv.ac.uk@cunyvm.cuny.edu   *
PO Box 147                ***************************************************
Liverpool  L69  3BX   "When correctly viewed, everything is lewd. I could tell
(UK) 051-794-3689     you things about Peter Pan, and the Wizard of Oz - there's
                      a dirty old man." - Tom Lehrer, "Smut!"

jherr@umbio.miami.edu (Jack Herrington) (03/16/90)

In article <5168.25f674b1@mva.cs.liv.ac.uk> phil@mva.cs.liv.ac.uk writes:
>         The system I'm using at the moment is to draw the picture once into
>an offscreen bitmap, and then to blat it on at the correct location as themouse
>moves around, while simultaneously redrawing the stuff that was underneath, and
>copying new stuff out of the way.  My problem is that using this method, the
>pattern gets out of sync.

When you draw the original image onto the screen, reset the origin to the
upper left hand corner of all of the objects you draw (watch out though, 
clipping will change, etc.)  Then wherever you draw your image the pattern
will always remain the same.

-Jack
--
"Slip kid, slip kid, second generation, I'm a soldier at sixty-three, no
 easy way to be free... No easy way to be free!!!!"
								-The WHO

zben@umd5.umd.edu (Ben Cranston) (03/17/90)

Thought I might mention "Animated BitMaps" by Scott Boyd, Page 67 of MacTutor
July 1987 (V3#7).  He describes several algorithms, and gives source code for
one which requires one full-screen-size offscreen bitmap, small offscreen
bitmaps for the object and its shadow, and two small scratch bitmaps.
-- 

"It's all about Power, it's all about Control
 All the rest is lies for the credulous"
-- Man-in-the-street interview in Romania one week after Ceaucescu execution.