Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Hello, can somebody explain how the Canvas.Arc function works (I'm newbie)

THX

THX

from delphi help

TCanvas.Arc

TCanvas See also Example

Draws an arc on the image along the perimeter of the ellipse bounded by the specified rectangle.

procedure Arc(X1, Y1, X2, Y2, X3, Y3, X4, Y4: Integer );

Description

Use Arc to draw an elliptically curved line with the current Pen. The arc traverses the perimeter of an ellipse that is bounded by the points (X1,Y1) and (X2,Y2). The arc is drawn following the perimeter of the ellipse, counterclockwise, from the starting point to the ending point. The starting point is defined by the intersection of the ellipse and a line defined by the center of the ellipse and (X3,Y3). The ending point is defined by the intersection of the ellipse and a line defined by the center of the ellipse and (X4, Y4).

Note: On Windows 95, the sums X1 + X2 and Y1 + Y2 cannot exceed 32768. Also, the sum X1 + X2 + Y1 + Y2 cannot exceed 32768.

On NT, the drawing direction can be changed to clockwise using the Windows API call SetArcDirection.

and this example to draw arc on the form

procedure TForm1.Button1Click(Sender

var

R: TRect;

begin

R := GetClientRect; {Gets the boundaries of the current window}

Canvas.Arc(R.Left, R.Top, R.Right, R.Bottom, R.Right, R.Top, R.Left, R.Top);

end ;

Mohammed

Simply hand in the DC of the Canvas and it will work.

Only ensure that the Canvas is initialized by painting to it.

Arc has problems drawing small angles which amount to less than one pixel. It draws a full circle then.

THX

Make a form with 4 trackbars (keep them on the right side of the form, so they stay out of the way). Make Trackbar1 and Trackbar 2 go from Min 0 to Max 500, and Trackbar3 and Trackbar 4 go from Min 0 to Max 400. The first two are the x coordinates of your control points, and the second are the y coordinates.

Add this code:

var

ta : array[0..4] of TPoint;

procedure TForm1.FormShow(Sender: TObject);

begin

// Select a starting position....

TrackBar1.Position := 10;

TrackBar2.Position := 100;

TrackBar3.Position := 100;

TrackBar4.Position := 300;

TrackBar1Change(Sender);

end;

procedure TForm1.TrackBar1Change(Sen

begin

Form1.Canvas.Pen.Color := Form1.Color;

Form1.Canvas.PolyBezier(Sl

ta[0].x := 0;

ta[0].y := 0;

ta[1].x := TrackBar1.Position;

ta[1].y := TrackBar3.Position;

ta[2].x := TrackBar2.Position;

ta[2].y := TrackBar4.Position;

ta[3].x := 500;

ta[3].y := 400;

Form1.Canvas.Pen.Color := clBlack;

Form1.Canvas.PolyBezier(Sl

end;

Now, you can work with the values you want your final curve to have.

I just don't really get why you can't do like this canvas.arc(0,0,500,400,500

Thats actually why I asked if somebody can explain how to do this

THX

ta[0].x := 0;

ta[0].y := 0;

ta[1].x := 0;

ta[1].y := 400;

ta[2].x := 0;

ta[2].y := 400;

ta[3].x := 500;

ta[3].y := 400;

Form1.Canvas.PolyBezier(Sl

Note that ta[0] is one endpoint, ta[3] is the other, and the two middle points pull the curve in their direction to give the effect you want.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

The Arc procedure can be a bit difficult to use, but I will try and explain how.

1. The first thing to do is draw a rectangle on a piece of paper that would mark the boundaries of your ENTIRE ellipse if it were fully drawn on your canvas and mark out its top-left, top-right, bottom-left and bottom-right co-ordinates. From this rectangle you will need the top left and bottom right co-ordinates. These will become the first four parameters used in the arc procedure.

2. Once you've drawn the boundary rectangle you need to identify the starting point of your arc on the boundary rectangle. Remember that the arc moves anti-clockwise. From this you will need the x an y co-ordinates

3. Then identify the stopping point of your arc on the boundary rectangle. Remember that the arc moves anti-clockwise. From this you will need the x an y co-ordinates.

4. The x and y co-ordinates from steps 2 and 3 make up the last four parameters used in the arc procedure.

For example if my boundary rectangle was 200 pixels wide and 100 pixels high it's parameters would be 0,0,200,100 and if I wanted to draw a quarter arc in the top left of the rectangle then it would start at co-ordinate 100,0 and end at co-ordinate 0,50 (ie: both these co-ordinates intersect the boundary rectangle) so the final Arc parameters would be Canvas.Arc(0,0,200,100,100

Likewise if I wanted to draw a semi-circle type arc across the top of the rectangle then the starting position of the arc would change to 200,50 and the end co-ordinate would stay as 0,50 giving you an Arc Parameter of (0,0,200,100,200,50,0,50)

Hope this helps.

Jo