Liste des Groupes | Revenir à cl c |
Groovy hepcat Lew Pitcher was jivin' in comp.lang.c on Mon, 18 Mar 2024Safe and Unsafe means that Safe checks if the x,y is in the array of pixels, when Unsafe just writes without checking - i draw in array of unsigned 32 bit ARGB or GBRA (never remeber) pixels - then i blit that
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.]
>
Les messages affichés proviennent d'usenet.