From: "Earl F. Glynn" Subject: Re: Arcs, Pies and Circles Date: Monday, June 05, 2000 10:17 AM "King Chugg" wrote in message news:393ba8f4@dnews... > procedure Pie( ACanvas: TCanvas; ACenter: TPoint; ARadius: Integer; > AStartDeg, AEndDeg: Float ); > > which draws a pie as a section of a circle starting at AStartDeg dregrees (0 > being straight up - or whatever) and ending at AEndDeg (360 beging straight > up - or whatever) using ACanvas default drawing parameters (brush and pen). The TCanvas.Pie can be used to get what you want -- with a little trig. The following has 0 degrees being to the right (as in trig classes) with a positive angle in the counterclockwise direction (as in trig classes): USES Math; // DegToRad PROCEDURE DrawPieSlice(CONST Canvas: TCanvas; CONST Center: TPoint; CONST Radius: INTEGER; CONST StartDegrees, StopDegrees: Double); CONST Offset = 0; // to make 0 degrees start to the right VAR X1,X2,X3,X4: INTEGER; Y1,Y2,Y3,Y4: INTEGER; BEGIN X1 := Center.X - Radius; Y1 := Center.Y - Radius; X2 := Center.X + Radius; Y2 := Center.Y + Radius; // negative signs on "Y" values to correct for "flip" from normal // math defintion for "Y" dimension X3 := Center.X + Round( Radius*COS( DegToRad(Offset+StartDegrees) ) ); Y3 := Center.y - Round( Radius*SIN( DegToRad(Offset+StartDegrees) ) ); X4 := Center.X + Round( Radius*COS( DegToRad(Offset+StopDegrees) ) ); Y4 := Center.y - Round( Radius*SIN( DegToRad(Offset+StopDegrees) ) ); Canvas.Pie(X1,Y1, X2,Y2, X3,Y3, X4,Y4); END {Pie}; procedure TForm1.Button1Click(Sender: TObject); VAR Center: TPoint; Bitmap: TBitmap; Radius: INTEGER; begin ASSERT (Image1.Width = Image1.Height); // Assume square for now Bitmap := TBitmap.Create; TRY Bitmap.Width := Image1.Width; Bitmap.Height := Image1.Height; Bitmap.PixelFormat := pf24bit; Bitmap.Canvas.Brush.Color := clRed; Bitmap.Canvas.Pen.Color := clBlue; Center := Point(Bitmap.Width DIV 2, Bitmap.Height DIV 2); Radius := Bitmap.Width DIV 2; DrawPieSlice (Bitmap.Canvas, Center, Radius, 0, 30); DrawPieSlice (Bitmap.Canvas, Center, Radius, 90, 120); Image1.Picture.Graphic := Bitmap FINALLY Bitmap.Free; END end; -- efg Earl F. Glynn Overland Park, KS USA efg's Computer Lab: http://www.efg2.com/Lab