Registriert seit: 15. Aug 2003
Ort: Bispingen
94 Beiträge
Delphi 7 Personal
|
Re: 'Hübsche' Teechart-Komponente
17. Jun 2004, 21:02
Schreib doch selber? Ist nicht wirklich schwer. Hatte mal sowas in nem Programm von mir gemacht.
Delphi-Quellcode:
procedure DrawPie(image: TImage;values:array of integer; thecolors: array of TColor;height: integer);
var
p1, p2: TPoint;
angle: array[0..3] of extended;
offset, i, max: integer;
begin
offset := (height) div 2+1;
Image.Canvas.Brush.Color := $005A5656;
Image.Canvas.FillRect(Image.Canvas.ClipRect);
Image.Canvas.Arc(0,height,image.width, image.height-offset*2 + height,
0,image.height div 2-offset+height,
image.width,image.height div 2-offset+height);
max := 0;
for i := 0 to 2 do
inc(max,values[i]);
if max > 0 then begin
angle[0] := 0;
angle[1] := 3.6 * (100 / max * values[0]);
angle[2] := 3.6 * (100 / max * values[1]) + angle[1];
angle[3] := 3.6 * (100 / max * values[2]) + angle[2];
for i := 0 to 2 do begin
if angle[i] <> angle[i+1] then begin
p2.x :=trunc(cos(pi/180 * angle[i]) * (image.Width div 2) + image.Width div 2);
p2.Y :=trunc(sin(pi/180 * angle[i]) * (image.Height div 2 -offset) + (image.Height div 2-offset));
p1.X :=trunc(cos(pi/180 * angle[i+1]) * (image.Width div 2) + image.Width div 2);
p1.Y :=trunc(sin(pi/180 * angle[i+1]) * (image.Height div 2-offset) + (image.Height div 2-offset));
Image.canvas.brush.Color := thecolors[i];
Image.Canvas.Pie(0,0, Image.Width, Image.Height-offset*2, p1.x,p1.y,p2.x,p2.y);
end;
end;
end else
Image.Canvas.Ellipse(0,0, Image.Width, Image.Height-offset*2);
Image.Canvas.Brush.Color := clWhite;
Image.Canvas.FloodFill(0,0,clBlack,fsBorder);
Image.Canvas.FloodFill(Image.Width-1,0,clBlack,fsBorder);
Image.Canvas.FloodFill(0,Image.Height-1,clBlack,fsBorder);
Image.Canvas.FloodFill(Image.Width-1,Image.Height-1,clBlack,fsBorder);
end;
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots.
So far, the Universe is winning.
|