Drawing complex shapes - fl_arc

15 visualizações
Pular para a primeira mensagem não lida

pvr...@btinternet.com

não lida,
10 de abr. de 2024, 11:10:5810 de abr.
para fltk.general
From the documentation:

void fl_arc(double x, double y, double r, double start, double end)

Add a series of points to the current path on the arc of a circle; you can get elliptical paths by using scale and rotate before calling fl_arc(). The center of the circle is given by x and y, and r is its radius. fl_arc() takes start and end angles that are measured in degrees counter-clockwise from 3 o'clock. If end is less than start then it draws the arc in a clockwise direction.

This infers that the two calls:
fl_arc(0, 0, radius, 90, 180);
fl_arc(0, 0, radius, 180, 90);
result in the same drawing - the arc selected is from 9 o'clock clockwise to 12 o'clock. And indeed they do.

I coded:
fl_arc(0, 0, radius, 180, 450);
to achieve what I wanted which was to draw an arc clockwise from 12 o'clock to 9 o'clock.

My concern is that this is not properly documented. Should I have drawn two separate arcs from 180 to 360 and 0 to 90?

I also noticed that the code
fl_start_polygon();
fl_vector(0,0);
fl_arc(0,0, radius, 180, 450);
fl_end_polygon();

actually worked to give me the 3/4 of the pie even though it is a concave shape.

Phil.

Matthias Melcher

não lida,
13 de abr. de 2024, 06:59:1513 de abr.
para fltk.general
The API is from 1998 or earlier. I would implement things differently today, but we need to live with the behavior of `fl_arc` as it is for back compatibility. If you have an idea how to document the peculiarities of `fl_arc` in a better way, we would appreciate text suggestions here or as a PR on GitHub to improve documentation.

pvrose

não lida,
13 de abr. de 2024, 08:10:5613 de abr.
para fltkg...@googlegroups.com

On 13 April 2024, at 11:59, "'Matthias Melcher' via fltk.general" <fltkg...@googlegroups.com> wrote:

>The API is from 1998 or earlier. I would implement things differently today, but we need to live with the behavior of `fl_arc` as it is for back compatibility. If you have an idea how to document the peculiarities of `fl_arc` in a better way, we would appreciate text suggestions here or as a PR on GitHub to improve documentation.
>

Thanks Matthias.

My suggestion would be to add a statement or image on how to draw an arc counter-clockwise through 3 o'clock. Something on the lines of: if the second angle is less than the first, then add 360° to the second angle to maintain ccw drawing.

If that is indeed the supported method.

Regards Phil.
>--
>You received this message because you are subscribed to the Google Groups "fltk.general" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
>To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/c52e30a1-f25f-4446-aa5d-5ae92a3a493fn%40googlegroups.com.

Matthias Melcher

não lida,
14 de abr. de 2024, 08:09:5614 de abr.
para fltk.general
Thanks. I updated the docs with some different wording. I hope that the intention is clear now.
Responder a todos
Responder ao autor
Encaminhar
0 nova mensagem