{Une méthode pour afficher un arbre en pascal écrit pour régis blanc et ses lubies par denis bertin (c) beelog 30.04.2010} procedure tformedb_arbo.draw(dc:hdc; gr:TGPGraphics; var ps_rect:trect; zoom_coef:single); var i,j,k,size_stepped:integer; abrush:hbrush; apencil:hpen; position,obtenue:tpoint; une_metaliste,deux_metaliste:u_object.metalist; un_td_point_angle:u_object.TDPoint_angle; un_angle:real; procedure Denis_Draw_branch_at_this_point_with_this_angle(xx,yy:integer; un_angle:real; size_affinage:integer; var obtenue:tpoint); var pen:TGPPen; begin obtenue.x:=xx+round(cos(un_angle)*size_stepped*2); obtenue.y:=yy-round(sin(un_angle)*size_stepped*2); if Self.en_couleur then pen:=TGPPen.Create(GDIPAPI.MakeColor(self.transparent,random(255),random(255),random(255)),(size_affinage div 2)/zoom_coef) else pen:=TGPPen.Create(GDIPAPI.MakeColor(self.transparent,GetRValue(self.brush1.lbColor),GetGValue(self.brush1.lbColor),GetBValue(self.brush1.lbColor)),(size_affinage div 2)/zoom_coef); pen.SetLineCap(LineCapRound, LineCapRound,0); gr.DrawLine(pen,xx/zoom_coef,yy/zoom_coef,obtenue.x/zoom_coef,obtenue.y/zoom_coef); pen.free; end; {Draw_branch_at_this_point_with_this_angle} begin size_stepped:=round((self.r/2)/pred(Self.nb_profondeur)); abrush:=Selectobject(dc,CreateSolidBrush(self.brush1.lbColor)); apencil:=Selectobject(dc,GetstockObject(NULL_PEN)); ellipse(dc,self.x-size_stepped,self.y-size_stepped,x+size_stepped,y+size_stepped); Selectobject(dc,apencil); position.x:=self.x; position.y:=self.y; une_metaliste:=u_object.metalist.create; for i:=0 to pred(Self.nb_branche) do begin un_angle:=i*utile.deuxpi/Self.nb_branche+Should_be_offseted_by_this_angle*utile.pisur180; Denis_Draw_branch_at_this_point_with_this_angle(position.x,position.y,un_angle,round(size_stepped*(Self.nb_profondeur)/Self.nb_profondeur),obtenue); une_metaliste.Add(u_object.TDpoint_angle.Create(obtenue.x,obtenue.y,un_angle)); end; for j:=0 to pred(Self.nb_profondeur) do begin deux_metaliste:=u_object.metalist.create; for i:=0 to pred(une_metaliste.count) do begin un_td_point_angle:=une_metaliste.at(i); for k:=0 to succ(j) do begin position.x:=un_td_point_angle.x; position.y:=un_td_point_angle.y; un_angle:=un_td_point_angle.angle+pi/2*k/Self.nb_profondeur-pi/4+random(Self.Angle_defaut_possible)*utile.pisur180+Should_be_offseted_by_this_angle*utile.pisur180; {-pi/4 pour une variation égale des branches} Denis_Draw_branch_at_this_point_with_this_angle(position.x,position.y,un_angle,round(size_stepped*((Self.nb_profondeur-j)/Self.nb_profondeur)),obtenue); deux_metaliste.Add(u_object.TDPoint_angle.Create(obtenue.x,obtenue.y,un_angle)); end; end; une_metaliste.free; une_metaliste:=deux_metaliste; end; deux_metaliste.Free; DeleteObject(Selectobject(dc,abrush)); end; {tformedb_arbo.Draw}