1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| Radius := size DIV 2; // size c'est un côté de l'objet carré TImage utilisé pour afficher le cercle
RadiusSquared := Radius*Radius;
V := ValueLevel; // passé par la proc. appelante
RESULT.BeginUpdate(); // pour Lazarus
FOR j := 0 TO RESULT.Height-1 DO // balayage vertical de l'image destination
BEGIN
Y := Size - 1 - j - Radius; {Center is Radius offset} // Y va de 99 à -100 avec image 200x200
//row := pRGBQuad(RESULT.Scanline[Size - 1 - j]); // en Delphi
row := pRGBQuad(RESULT.RawImage.GetLineStart(Size - 1 - j)); // si HSV
rpw := pPointeurDeLigne(RESULT.RawImage.GetLineStart(Size - 1 - j)); // si LCh°
FOR i := 0 TO RESULT.Width-1 DO // les pixels de la ligne
BEGIN
X := i - Radius;
dSquared := X*X + Y*Y; // original
dSquared := (X*X -1) + (Y*Y -1); // croix
dSquared := (X*X +1) + (Y*Y +1); // 1 pixel seulement
dSquared := X*X + Y*Y + 3; // OK, plus rien
IF dSquared <= RadiusSquared
THEN BEGIN
// S := ROUND( (255 * SQRT(dSquared)) / Radius ); // si HSV
S := ROUND( (100 * SQRT(dSquared)) / Radius ); // si LCh°
// H := ROUND( 180 * (1 + ArcTan2(X, Y) / PI)); // 0..360 degrees si HSV
H := ROUND( 180 * (1 - ArcTan2(X, Y) / PI)); // si LCh° "-" pour tourner dans l'autre sens
// Shift 90 degrees so H=0 (red) occurs along "X" axis
//H := H + 90; // pour HSV
H := H + 210; // pour LCh°
IF H > 360 THEN H := H - 360;
//row[i] := HSVtoRGBQuad(H,S,V,255); // OK si appel de la proc avec 60 230 255
HSVtoRGB(H,S,V, R,G,B); // ajout pour LCh°
// row[i] := RGBtoRGBQuad(R,G,B,255); // test HSV, pour confirmer la conversion ligne précédente
rpw^[i] := optLCH2ColorwithClamp(22,S,H, False, False, 15);// // ajout pour LCh°, rendu sympathique
END; // if dSquared
END; // for i
END; // for j
RESULT.EndUpdate(); |
Partager