Drawing complex shapes: arcs with negative y-scaling factor.

32 views
Skip to first unread message

pvr...@btinternet.com

unread,
May 11, 2026, 8:55:46 AMMay 11
to fltk.general
In my application I am trying to draw an arc from, for example 9 o'clock to 6 o'clock.
I am using the complex shape drawing routines with a plot area with increasing Y values going up the page. 

In the attached example, I believe I am drawing the line from 9 o'clock (180 degrees) to
6 o'clock (270 degrees). Unfortunately it draws from 9 o'clock to 12 o'clock. 

Either there is something I've missed in the documentation and need to invert the mapping from degrees to drawn direction when using negative scaling for Y, or the implementation of fl_arc is wrong in this case.

I am using a clone of fltk that's a few months old.

What I am trying to achieve in my application is to draw the lines of equal reactance on a Smith chart. The transformation I've set is working when plotting the data points using a series of fl_vertex() calls.

Regards Phil Rose.


test_arc.cpp

Albrecht Schlosser

unread,
May 11, 2026, 9:44:18 AMMay 11
to fltkg...@googlegroups.com
On 5/11/26 14:55 'pvr...@btinternet.com' via fltk.general wrote:
In my application I am trying to draw an arc from, for example 9 o'clock to 6 o'clock.
I am using the complex shape drawing routines with a plot area with increasing Y values going up the page. 

In the attached example, I believe I am drawing the line from 9 o'clock (180 degrees) to
6 o'clock (270 degrees). Unfortunately it draws from 9 o'clock to 12 o'clock.

I tried your program. What I see is that it *seems* to draw "from 9 o'clock to 12 o'clock" in the screen's or window's original coordinate system, i.e. as the user sees it. However, if you flip the image top-down (the inverse operation of your scaling) it *looks* as you seem to expect. All the complex shape drawing are done in the scaled coordinate system.


Either there is something I've missed in the documentation and need to invert the mapping from degrees to drawn direction when using negative scaling for Y, 

Yes, that's IMHO the correct way, see above


or the implementation of fl_arc is wrong in this case.

I don't think this is the case.

Ian MacArthur

unread,
May 11, 2026, 10:26:21 AMMay 11
to fltk.general
On Monday, 11 May 2026 at 14:44:18 UTC+1 Albrecht-S wrote:
On 5/11/26 14:55 phil via fltk.general wrote:
In my application I am trying to draw an arc from, for example 9 o'clock to 6 o'clock.
I am using the complex shape drawing routines with a plot area with increasing Y values going up the page. 

In the attached example, I believe I am drawing the line from 9 o'clock (180 degrees) to
6 o'clock (270 degrees). Unfortunately it draws from 9 o'clock to 12 o'clock.

I tried your program. What I see is that it *seems* to draw "from 9 o'clock to 12 o'clock" in the screen's or window's original coordinate system, i.e. as the user sees it. However, if you flip the image top-down (the inverse operation of your scaling) it *looks* as you seem to expect. All the complex shape drawing are done in the scaled coordinate system.

Yup - I'm with Albrecht on this one: your fl_scale has flipped the y-axis, and the "complex" drawing routines will honour that, so I'd assume that's why the arc is "flipped".
The "fast" drawing routines mostly don't respect the scaling, etc. (except when they do of course, just to catch me out!)
 

pvr...@btinternet.com

unread,
May 11, 2026, 12:13:29 PMMay 11
to fltkg...@googlegroups.com



From: 'Albrecht Schlosser' via fltk.general <fltkg...@googlegroups.com>
Sent: Monday, May 11, 2026 2:44 PM
Subject: Re: [fltk.general] Drawing complex shapes: arcs with negative y-scaling factor.
 
On 5/11/26 14:55 'pvr...@btinternet.com' via fltk.general wrote:
In my application I am trying to draw an arc from, for example 9 o'clock to 6 o'clock.
I am using the complex shape drawing routines with a plot area with increasing Y values going up the page. 

In the attached example, I believe I am drawing the line from 9 o'clock (180 degrees) to
6 o'clock (270 degrees). Unfortunately it draws from 9 o'clock to 12 o'clock.

I tried your program. What I see is that it *seems* to draw "from 9 o'clock to 12 o'clock" in the screen's or window's original coordinate system, i.e. as the user sees it. However, if you flip the image top-down (the inverse operation of your scaling) it *looks* as you seem to expect. All the complex shape drawing are done in the scaled coordinate system.

A question that what it "seems" to the user, not being what it actually is then. I must admit, I simply took at face value what was in the description. I assumed that 12 o'clock was up as I looked at it, and NOT increasing in pixel y value. The drawings explaining the various angles infer this is what the user would see, REGARDLESS of the scaling.

Subtracting the angles from 360 degrees, before applying them to the fl_arc() function did produce the correct arcs, so I think clarity or at least a warning in the description would have helped. It took me ages to work out what was actually happening.

Regards Phil.

Either there is something I've missed in the documentation and need to invert the mapping from degrees to drawn direction when using negative scaling for Y, 

Yes, that's IMHO the correct way, see above

or the implementation of fl_arc is wrong in this case.

I don't think this is the case.

--

imm

unread,
May 11, 2026, 3:04:27 PMMay 11
to fltkg...@googlegroups.com
On Mon, 11 May 2026 at 17:13, Phil wrote:

>
> A question that what it "seems" to the user, not being what it actually is then. I must admit, I simply took at face value what was in the description. I assumed that 12 o'clock was up as I looked at it, and NOT increasing in pixel y value. The drawings explaining the various angles infer this is what the user would see, REGARDLESS of the scaling.
>
Well, I dunno - the figure in the docs is correct for the default
transform, so in that regard I'd say it's "correct."
Perhaps the difficulty arises perhaps because a lot of the complex
drawing methods don't explicitly say that they are affected by the
current transform?
I note that many of drawing methods (most of the "fast" shapes and the
text stuff, for example) say that they DON'T obey the current
transform (or that the behaviour is undefined...) but it might be
useful for the ones that do honour the transform to say so, too...
I suppose this might even be an artefact of how the complex drawing
methods came about - they more or less follow the Postscript style,
and that will always obey the transform, so I guess there might be
some implicit assumptions there that a user, coming to this later,
might not know about!

pvr...@btinternet.com

unread,
May 12, 2026, 4:44:01 AM (14 days ago) May 12
to fltkg...@googlegroups.com



Sent: Monday, May 11, 2026 8:05 PM
Subject: Re: [fltk.general] Drawing complex shapes: arcs with negative y-scaling factor.
 
Thinking about it later, it was the use of the terms "clockwise" and "counter-clockwise" to describe how the arc is drawn that led me to my wrong interpretation. If either X or Y is scaled negatively (but not both) then these become "counter-clockwise" and "clockwise" respectively. Maybe add a caveat on the drawings that exemplify the use of fl_arc() to remind the user about the mirror effect of negative scaling.


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.
Reply all
Reply to author
Forward
0 new messages