## Canvas arcs

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

### Canvas arcs

How can I draw a canvas arc given centre, radius, start angle and finish angle?

http://wiki.flightgear.org/Canvas_Nasal ... SmallCCWTo shows how to draw an arc between two points, but does not seem very helpful. All the examples appear to be at 90 degree intervals, and everything seems to be in cartesian co-ordinates. For an arc I would like to set centre point, radius and angle instead with polar coordinates.

I need to be able to vary the angle at run-time.

TIA

Alan
Alant

Posts: 784
Joined: Wed Jun 23, 2010 5:58 am
Location: Portugal
Callsign: Tarnish99
Version: from Git
OS: Windows 10

### Re: Canvas arcs

shows how to draw an arc between two points, but does not seem very helpful.

No? Some trigonometry helps...

center: (c1, c2), radius R, start and stop angles (phi1, phi2)

p1 = (c1 + R * sin(phi1), c2 + R * cos(phi1)
p2 = (c1 + R * sin(phi2), c2 + R * cos(phi2)

-> draw arc from p1 and p2
Thorsten

Posts: 10230
Joined: Mon Nov 02, 2009 8:33 am

### Re: Canvas arcs

Thanks Thorsten, but that seems rather excessive for what I had expected to find as a basic method.

Unless there is a undocumented polar co-ordinates method .I will have to do it that way.

Alan
Alant

Posts: 784
Joined: Wed Jun 23, 2010 5:58 am
Location: Portugal
Callsign: Tarnish99
Version: from Git
OS: Windows 10

### Re: Canvas arcs

You can write a wrapper and then you have a basic method... I have lots of self-defined drawing wrappers for what I need in my canvas code (among others curved arc with scale drawer routines).
Thorsten

Posts: 10230
Joined: Mon Nov 02, 2009 8:33 am