[futurebasic] Re: [FB] Great Mousepaint Challenge Take 2

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 2001 : Group Archive : Group : All Groups

From: tedd <tedd@...>
Date: Thu, 6 Sep 2001 10:01:47 -0400
>Any ideas?
>
>Robert Covington

Robert:

What you have is a airbrush -- a nice one too. Although, you have to 
figure out how to lighten when you go over a darker area.

What you want is something that doesn't overlap points on mousedown, right?

Then try to record every point drawn in an array (or linked list) and 
then compare each new point with what's been recorded. If there is a 
match, then don't draw -- if not, then draw.

However, I don't think that will solve everything, because what 
happens when you double back on a line and miss the recorded point by 
one? OR, for that matter, if you double back and miss a recorded 
point by less than a brush width? I think you'll get a double paint 
area regardless.

I would attempt to solve this by using (accumulating) regions.

As I imagine it, one would open a region upon starting the brush 
stroke (first point). Then close it (region 1 -- "the drawn region"). 
Then open another region (region 2). Move the mouse to another point. 
Close the new region. Compare region 1 with region 2, if no overlap, 
then draw point 2 and add regions 1 and 2 to make a new "drawn 
region". Then move to point three and repeat creating a region, 
closing a region and then comparing the new region with the previous 
"drawn region". If the new region is outside, then draw it and add 
the new region to the old and repeat.

I know that it sounds like a lot of region opening and closing, but 
the region toolbox calls are made for this sort of thing. Besides, 
you only have to keep two regions going, namely the "drawn region" 
and the "new region".

Now, I believe that the above algorithm will produce a perl necklace 
effect. You may not want that. So, you can change the size of the 
"new region" (reduce) before comparing it to the "drawn region" -- 
thereby allowing some overlap. Then expand the "new region" back to 
it's original size before adding it to the "drawn region".

I believe that therein is your answer. However, I don't know exactly 
what ratios you'll need to accomplish what you want.

tedd

-- 
http://sperling.com