Deutsch   English   Français   Italiano  
<311nck-im1.ln1@hendrix.foo>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Peter 'Shaggy' Haywood <phaywood@alphalink.com.au>
Newsgroups: comp.lang.c
Subject: Re: filling area by color atack safety
Date: Tue, 19 Mar 2024 10:57:55 +1100
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <311nck-im1.ln1@hendrix.foo>
References: <ut3669$21eur$1@i2pn2.org> <ut4020$2s8ov$1@dont-email.me> <ut6ul9$3gr73$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8Bit
Injection-Info: dont-email.me; posting-host="5e1e56d172a68dadc8bf3b021a3d2b9d";
	logging-data="896254"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX180yMOYV2aukgN37H/EbgtKa+fthZmZiuE="
User-Agent: KNode/0.10.9
Cancel-Lock: sha1:NTHgpKWO5Hsva5aZkD46pyEcGBY=
Bytes: 2458

Groovy hepcat Lew Pitcher was jivin' in comp.lang.c on Mon, 18 Mar 2024
01:27 am. It's a cool scene! Dig it.

>> On 16/03/2024 04:11, fir wrote:

  [Snip.]

>>> int RecolorizePixelAndAdjacentOnes(int x, int y, unsigned old_color,
>>> unsigned new_color)
>>> {
>>>  if(old_color == new_color) return 0;
>>> 
>>>  if(XYIsInScreen( x,  y))
>>>  if(GetPixelUnsafe(x,y)==old_color)
>>>  {
>>>  SetPixelSafe(x,y,new_color);
>>>  RecolorizePixelAndAdjacentOnes(x+1, y,  old_color, new_color);
>>>  RecolorizePixelAndAdjacentOnes(x-1, y,  old_color, new_color);
>>>  RecolorizePixelAndAdjacentOnes(x, y-1,  old_color, new_color);
>>>  RecolorizePixelAndAdjacentOnes(x, y+1,  old_color, new_color);
>>>  return 1;
>>>  }
>>> 
>>>  return 0;
>>> }

  [Snippity doo dah.]

> Take fir's example code above; a simple single call to
> RecolorizePixelAndAdjacentOnes() will effectively recolour the
> origin cell multiple times, because of how the recursion is handled.

  No, I don't think so. You seem to have missed the fact that it checks
the colour of the "current" pixel, and only continues (setting new
colour & recursing) if it is the old colour.
  Of course, I'm infering (guessing) the functionality, at least
partially (Unsafe? Safe?), of GetPixelUnsafe() and SetPixelSafe() based
on their names.

  [Snip Lew's examples.]

-- 


----- Dig the NEW and IMPROVED news sig!! -----


-------------- Shaggy was here! ---------------
              Ain't I'm a dawg!!