Port Delphi Canvas Function
Posted 02 February 2013 - 08:48 AM
Canvas.Scale(1, 0.5); Canvas.BeginPath; Canvas.ArcF(200, 210, 100, 0, PI*2, false); Canvas.Scale(1, 2); Canvas.Stroke;
The second scale call restores the previous scale, and has to be done before the Stroke, otherwise the scale will also get applied to the stroke thickness.
Arc takes center coordinates followed by radius, so the scale ratio would be Abs((Y2-Y1)/(X2-X1)) if I'm not mistaken (and its inverse for the second scale call)
Posted 02 February 2013 - 07:32 PM
procedure TW3Canvas.Ellipse(const aRect : TRectF); begin var dx := aRect.Width; var dy := aRect.Height; var f := if dy<>0 then dx/dy else 1; FDC.beginPath(); FDC.scale(f, 1); FDC.arc((aRect.Right+aRect.Left)*0.5, (aRect.Top+aRect.Bottom)*0.5, dy*0.5, 0, 2*PI, false); FDC.scale(1/f, 1); FDC.stroke(); end;
That's starting from the bounding rect, if you start from center + x/y radius, things can be further simplified.
Posted 04 February 2013 - 02:08 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users