Deutsch   English   Français   Italiano  
<t7hick-t14.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: Sun, 17 Mar 2024 18:03:57 +1100
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <t7hick-t14.ln1@hendrix.foo>
References: <ut3669$21eur$1@i2pn2.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7Bit
Injection-Info: dont-email.me; posting-host="13a0669b382a7d0e07fe158547944872";
	logging-data="3722673"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/FzXsAmsmiJy8ks9n/mOqkX2TBHJeRpBI="
User-Agent: KNode/0.10.9
Cancel-Lock: sha1:iNeFpCiKv4bRWPeJ2DY55qzDCoY=
Bytes: 2358

Groovy hepcat fir was jivin' in comp.lang.c on Sat, 16 Mar 2024 03:11
pm. It's a cool scene! Dig it.

> i was writing simple editor (something like paint but more custom for
> my eventual needs) for big pixel (low resolution) drawing
> 
> it showed in a minute i need a click for changing given drawed area of
> of one color into another color (becouse if no someone would need to
> do
> it  by hand pixel by pixel and the need to change color of given
> element is very common)

  Not really a C question, but I'll forgive that for now.
  What you're looking for (and can easily find on Google, Duck Duck Go
or any other search engine, if you but utilise any of those services)
is called a "flood fill" algorithm.
  But a word of advice: recursion can be tricky if you don't understand
the effect. Your method creates a very large recursive chain. This is
best avoided. Try it out "by hand". Get a piece of graph paper and draw
some shapes on it, including some complex ones. Now choose one of these
shapes and choose a starting pixel within this area and try applying
your algorithm. With a coloured pencil, colour in each square as you
go, just as the algorithm would. Also make note of the level of
recursion as you go. I think you'll be amazed. Repeat for all the
shapes on your graph paper.

-- 


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


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