Créer par denis bertin pour obtenir les dessins ainsi présentés:






{écrit par Denis Bertin le 4-5-6 Aout 2011 et amélioré par denis bertin le 2-3 juin 2012} procedure tformedk_raycircle.Draw(dc:hdc; gr:TGPGraphics; var ps_rect:trect; zoom_coef:single; dune_couleur:boolean; cette_couleur:tcolorref); var i,j,k,rayon:integer; da,db:integer; centre:tpoint; ray:integer; un_gdi_bitmap:TGPBitmap; lenght:real; angle,difference,angle_parfait,mesurated_inverse:real; modulated:integer; une_couleur:tcolorRef; position:tpoint; une_transparence:integer; angle_positionner:real; angle_voulu:real; determiner:integer; une_autre_distance:integer; tableau_coin:array [0..60] of tpoint; should_who_memorise:integer; long_way_to_memorise:integer; une_distance:integer; void_transparence:integer; begin modulated:=360 div self.val_nb_branche; centre.x:=round(self.x/zoom_coef); centre.y:=round(self.y/zoom_coef); ray:=round(self.r/zoom_coef) shl 1; if self.bool_dessin_multiple_coins then begin //pré-détermination des coins for i:=0 to pred(Self.val_nb_branche) do begin //non c'est pas toi ma petite chérie. if pred(Self.val_nb_branche)<>0 then begin angle:=i/pred(Self.val_nb_branche)*utile.deuxpi; tableau_coin[i].x:=centre.x+round(cos(angle)*ray); tableau_coin[i].y:=centre.y-round(sin(angle)*ray); end; end; end; //pré-détermination des coins {Création d'un bitmap transparent par défaut} un_gdi_bitmap:=TGPBitmap.Create(ray shl 1,ray shl 1); if self.bool_rayon then begin for i:=360 downto 0 do for rayon:=ray downto 1 do begin if true then une_transparence:=round(255*rayon/ray) else une_transparence:=255-round(255*rayon/ray); if (self.col_degra<>nil) and (self.col_degra.count>=2) then une_couleur:=self.col_degra.in_between_color(round(1000*rayon/ray), self.bool_with_hls,self.bool_with_exp,void_transparence) else if self.bool_multicolor then une_couleur:=hls_rvb.Get_HLS_RGB(360*rayon/ray,0.5,1) else une_couleur:=self.brush1.lbcolor; position.x:=ray+round(cos(i*pisur180)*rayon); position.y:=ray+round(sin(i*pisur180)*rayon); with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(une_couleur), getgvalue(une_couleur), getbvalue(une_couleur))); end; end else begin for i:=centre.x-ray to centre.x+ray do begin for j:=centre.y-ray to centre.y+ray do begin da:=longint(i)-longint(centre.x); db:=longint(j)-longint(centre.y); lenght:=sqrt(da*da+db*db); if self.bool_dessin_multiple_coins then begin //Une nouvelle réalisation de Denis Bertin Stéphane if (lenght<=ray) then begin position.x:=i-(centre.x-ray); position.y:=j-(centre.y-ray); long_way_to_memorise:=maxint; should_who_memorise:=-1; for k:=0 to pred(Self.val_nb_branche) do begin une_distance:=utile.idistance(i,j,tableau_coin[k].x,tableau_coin[k].y); if une_distance<long_way_to_memorise then //to Sincinaty oui. begin should_who_memorise:=k; long_way_to_memorise:=une_distance; end; end; if should_who_memorise<>-1 then begin if bool_condition_carre then une_transparence:=255-round(255*long_way_to_memorise/ray) else une_transparence:=round(255*long_way_to_memorise/ray); if (self.col_degra<>nil) and (self.col_degra.count>=2) then begin une_couleur:=self.col_degra.in_between_color( round(1000*long_way_to_memorise/ray),self.bool_with_hls,self.bool_with_exp,void_transparence); with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(une_couleur), getgvalue(une_couleur), getbvalue(une_couleur))); end else if self.bool_multicolor then //C'était facile pour toi de comprendre ceci car //Je l'ai écrit cette après midi tu répète. Merci de ta compréhension. begin une_couleur:=hls_rvb.Get_HLS_RGB(360*long_way_to_memorise/ray,0.5,1); with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(une_couleur), getgvalue(une_couleur), getbvalue(une_couleur))); end else with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(self.brush1.lbcolor), getgvalue(self.brush1.lbcolor), getbvalue(self.brush1.lbcolor))) end; end; end //Une nouvelle réalisation de Denis Bertin Stéphane else if self.bool_dessin_etoile_de_carte then begin position.x:=i-(centre.x-ray); position.y:=j-(centre.y-ray); angle_positionner:=utile.angle_degree(centre.x,centre.y,i,j); case integer(round(angle_positionner)) of 0..90: begin une_autre_distance:=utile.idistance(i,j,centre.x+ray,centre.y-ray); if une_autre_distance>ray then begin //une_transparence:=round(255*une_autre_distance/ray); une_transparence:=round(255*(une_autre_distance)/utile.idistance(0,0,ray,ray)); if self.bool_multicolor then begin une_couleur:=hls_rvb.Get_HLS_RGB(360*une_autre_distance/ray,0.5,1); with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(une_couleur),getgvalue(une_couleur),getbvalue(une_couleur))) end else with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(self.brush1.lbcolor), getgvalue(self.brush1.lbcolor), getbvalue(self.brush1.lbcolor))); end; end; 91..180: begin une_autre_distance:=utile.idistance(i,j,centre.x-ray,centre.y-ray); if une_autre_distance>ray then begin //une_transparence:=round(255*une_autre_distance/ray); une_transparence:=round(255*(une_autre_distance)/utile.idistance(0,0,ray,ray)); if self.bool_multicolor then begin une_couleur:=hls_rvb.Get_HLS_RGB(360*une_autre_distance/ray,0.5,1); with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(une_couleur),getgvalue(une_couleur),getbvalue(une_couleur))) end else with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(self.brush1.lbcolor), getgvalue(self.brush1.lbcolor), getbvalue(self.brush1.lbcolor))); end; end; 181..270: begin une_autre_distance:=utile.idistance(i,j,centre.x-ray,centre.y+ray); if une_autre_distance>ray then begin //une_transparence:=round(255*une_autre_distance/ray); une_transparence:=round(255*(une_autre_distance)/utile.idistance(0,0,ray,ray)); if self.bool_multicolor then begin une_couleur:=hls_rvb.Get_HLS_RGB(360*une_autre_distance/ray,0.5,1); with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(une_couleur),getgvalue(une_couleur),getbvalue(une_couleur))) end else with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(self.brush1.lbcolor), getgvalue(self.brush1.lbcolor), getbvalue(self.brush1.lbcolor))); end; end; 271..360: begin une_autre_distance:=utile.idistance(i,j,centre.x+ray,centre.y+ray); if une_autre_distance>ray then begin //une_transparence:=round(255*une_autre_distance/ray); une_transparence:=round(255*(une_autre_distance)/utile.idistance(0,0,ray,ray)); if self.bool_multicolor then begin une_couleur:=hls_rvb.Get_HLS_RGB(360*une_autre_distance/ray,0.5,1); with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(une_couleur),getgvalue(une_couleur),getbvalue(une_couleur))) end else with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(self.brush1.lbcolor), getgvalue(self.brush1.lbcolor), getbvalue(self.brush1.lbcolor))); end; end; end; {case} end else if bool_effet_escompter then begin if bool_condition_carre or (lenght<=ray) then begin une_transparence:=255-round(255*lenght/ray); position.x:=i-(centre.x-ray); position.y:=j-(centre.y-ray); with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(self.brush1.lbcolor), getgvalue(self.brush1.lbcolor), getbvalue(self.brush1.lbcolor))); {-----} angle_positionner:=utile.angle_degree(centre.x,centre.y,i,j); angle_voulu:=integer(round(angle_positionner)) mod 90; if (angle_voulu<20) then begin une_transparence:=round(255*angle_voulu/20); with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(self.couleur_pinceau), getgvalue(self.couleur_pinceau), getbvalue(self.couleur_pinceau))); end else if (integer(round(angle_voulu+20)) mod 90)<20 then begin determiner:=20-(integer(round(angle_voulu+20))) mod 90; une_transparence:=round(255*determiner/20); with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(une_transparence, getrvalue(self.couleur_pinceau), getgvalue(self.couleur_pinceau), getbvalue(self.couleur_pinceau))); end; end; end else begin {Si ce point est inscrit dans le cercle} if (lenght<=ray) then begin position.x:=i-(centre.x-ray); position.y:=j-(centre.y-ray); {To avoid double call, should be "faster"} angle:=utile.angle_radian(centre.x,centre.y,i,j)*_180surpi; angle_parfait:=round(angle) div modulated; angle_parfait:=angle_parfait*modulated; difference:=abs(angle_parfait-angle); case self.choix_du_dessin of wformedk.TCR_onduler: mesurated_inverse:=(ray-lenght)/ray*val_space_for_ray; wformedk.TCR_tubulaire: mesurated_inverse:=abs((ray-lenght*2)/ray*val_space_for_ray); else mesurated_inverse:=val_space_for_ray; end; if difference<mesurated_inverse then begin if bool_multicolor then begin une_couleur:=hls_rvb.Get_HLS_RGB(angle*barioler,0.5,1.0); une_couleur:=Deformat.IN_Between_longint_RGB( g_base.rgb_blanc,une_couleur,difference,mesurated_inverse); end else une_couleur:=Deformat.IN_Between_longint_RGB( self.couleur_pinceau,self.brush1.lbcolor,difference,mesurated_inverse); with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(self.transparent,getrvalue(une_couleur),getgvalue(une_couleur),getbvalue(une_couleur))); end else begin angle_parfait:=round(angle+val_space_for_ray) div modulated; angle_parfait:=angle_parfait*modulated; difference:=abs(angle_parfait-angle); if difference<mesurated_inverse then begin if bool_multicolor then begin une_couleur:=hls_rvb.Get_HLS_RGB(angle*barioler,0.5,1.0); une_couleur:=Deformat.IN_Between_longint_RGB( g_base.rgb_blanc,une_couleur,difference,mesurated_inverse); end else une_couleur:=Deformat.IN_Between_longint_RGB( self.couleur_pinceau,self.brush1.lbcolor,difference,mesurated_inverse); with position do un_gdi_bitmap.SetPixel(x,y, MakeColor(self.transparent,getrvalue(une_couleur),getgvalue(une_couleur),getbvalue(une_couleur))); end; end; end; end; end; end; end; {Dessin de l'image par points} gr.DrawImage(un_gdi_bitmap,centre.x-ray,centre.y-ray); un_gdi_bitmap.free; end; {tformedk_raycircle.Draw}