andyf2022 0 Posted October 22, 2022 Greetings coders, Using Delphi 7, old I know but it is all I have. I am wondering how to go about plotting a circle or an oval onto a canvas using code sin and cos, basically programmatically plotting points on the canvas around in a circle or oval of scroll bar selected sizes. ideally with two scroll bars setting the the dimensions, then click a plot button, maybe using a timer to show that it is creating the shape a point at a time. like to plot a 128x128 255x128 I am thinking in a 255x255 pixel area. As I do this I want to save the plot points into an array with horizontal and Vertical values Most of this I can figure but the sin cos functions and other math are beyond my experience. Share this post Link to post
Vandrovnik 215 Posted October 22, 2022 You can find some inspiration here: https://www.mathsisfun.com/geometry/unit-circle.html Sin and Cos in Delphi take argument in radians (not in degrees). 1 Share this post Link to post
Pat Foley 52 Posted October 22, 2022 20 minutes ago, Vandrovnik said: Sin and Cos in Delphi take argument in radians (not in degrees). Important to know. as is the unit circle! But let's not use theta or alpha Greek for angle today. The first argument is x offset set it to Width div 2 Second argument is y offset set it to Height div 2 third and fourth arguments if the same draw a circle otherwise draws ellipse Canvas.Ellipse(100,100,50,75); Share this post Link to post
angusj 126 Posted October 22, 2022 https://github.com/AngusJohnson/Image32/blob/8cd56aa2bc2b4f007157b1c2f2fce451003152b0/source/Img32.Vector.pas#L2737 1 Share this post Link to post