-
Data: 2013-06-30 12:27:58
Temat: Re: przyjemna zagadka
Od: Adam Majewski <a...@o...pl> szukaj wiadomości tego autora
[ pokaż wszystkie nagłówki ]
Może przez wypełnienie konturu ?
int FillContour(double dXseed, double dYseed, unsigned char color,
unsigned char _data[])
{
/*
fills contour with black border using seed point inside contour
and horizontal lines
it starts from seed point, saves max right( iXmaxLocal) and max
left ( iXminLocal) interior points of horizontal line,
in new line ( iY+1 or iY-1) it computes new interior point :
iXmidLocal=iXminLocal + (iXmaxLocal-iXminLocal)/2;
result is stored in _data array : 1D array of 1-bit colors (
shades of gray)
it does not check if index of _data array is good so memory error
is possible
*/
int iXseed = (int)((dXseed - ZxMin)/PixelWidth);
int iYseed = (int)((dYseed - ZyMin)/PixelHeight);
int iX, /* seed integer coordinate */
iY=iYseed,
/* most interior point of line iY */
iXmidLocal=iXseed,
/* min and max of interior points of horizontal line iY */
iXminLocal,
iXmaxLocal;
int i ; /* index of _data array */;
/* --------- move up --------------- */
do{
iX=iXmidLocal;
i =f(iX,iY); /* index of _data array */;
/* move to right */
while (_data[i]==iInterior)
{ _data[i]=color;
iX+=1;
i=f(iX,iY);
}
iXmaxLocal=iX-1;
/* move to left */
iX=iXmidLocal-1;
i=f(iX,iY);
while (_data[i]==iInterior)
{ _data[i]=color;
iX-=1;
i=f(iX,iY);
}
iXminLocal=iX+1;
iY+=1; /* move up */
iXmidLocal=iXminLocal + (iXmaxLocal-iXminLocal)/2; /* new iX inside
contour */
i=f(iXmidLocal,iY); /* index of _data array */;
if ( _data[i]==iJulia) break; /* it should not cross the border */
} while (iY<iYmax);
/* ------ move down ----------------- */
iXmidLocal=iXseed;
iY=iYseed-1;
do{
iX=iXmidLocal;
i =f(iX,iY); /* index of _data array */;
/* move to right */
while (_data[i]==iInterior) /* */
{ _data[i]=color;
iX+=1;
i=f(iX,iY);
}
iXmaxLocal=iX-1;
/* move to left */
iX=iXmidLocal-1;
i=f(iX,iY);
while (_data[i]==iInterior) /* */
{ _data[i]=color;
iX-=1; /* move to right */
i=f(iX,iY);
}
iXminLocal=iX+1;
iY-=1; /* move down */
iXmidLocal=iXminLocal + (iXmaxLocal-iXminLocal)/2; /* new iX inside
contour */
i=f(iXmidLocal,iY); /* index of _data array */;
if ( _data[i]==iJulia) break; /* it should not cross the border */
} while (0<iY);
return 0;
}
HTH
Adam
Następne wpisy z tego wątku
- 30.06.13 12:31 Edek
- 30.06.13 13:10 firr
- 30.06.13 23:27 Edek
- 01.07.13 14:44 bartekltg
- 01.07.13 17:54 firr
- 04.07.13 14:19 firr
Najnowsze wątki z tej grupy
- TCL - problem z escape ostatniego \ w nawiasach {}
- Nauka i Praca Programisty C++ w III Rzeczy (pospolitej)
- testy-wyd-sort - Podsumowanie
- Tworzenie Programów Nieuprzywilejowanych Opartych Na Wtyczkach
- Do czego nadaje się QDockWidget z bibl. Qt?
- Bibl. Qt jest sztucznie ograniczona - jest nieprzydatna do celów komercyjnych
- Co sciaga kretynow
- AEiC 2024 - Ada-Europe conference - Deadlines Approaching
- Jakie są dobre zasady programowania programów opartych na wtyczkach?
- sprawdzanie słów kluczowych dot. zła
- Re: W czym sie teraz pisze programy??
- Re: (PDF) Surgical Pathology of Non-neoplastic Gastrointestinal Diseases by Lizhi Zhang
- CfC 28th Ada-Europe Int. Conf. Reliable Software Technologies
- Młodzi programiści i tajna policja
- Ada 2022 Language Reference Manual to be Published by Springer
Najnowsze wątki
- 2024-10-07 Wrocław => Konsultant wdrożeniowy ERP (Symfonia) <=
- 2024-10-07 policja szuka
- 2024-10-07 Nowy akt zasadniczy
- 2024-10-07 KIA nas dyma
- 2024-10-07 Warszawa => QA Inżynier <=
- 2024-10-07 Warszawa => Sales Development Representative (z j. niemieckim) <=
- 2024-10-06 miles per gallon
- 2024-10-06 Strefa czystego powietrza
- 2024-10-06 Prawdziwy ekologiczny samochód
- 2024-10-05 Stało się...
- 2024-10-05 skodeczka up
- 2024-10-04 Wieszanie się przy aktywnym SMP
- 2024-10-05 Warszawa => Senior Developer React Native <=
- 2024-10-05 Katowice => Administrator IT - Wirtualizacja i Konteneryzacja <=
- 2024-10-05 Warszawa => Senior Software Engineer (C, Java) <=