fl_rotate

18 views
Skip to first unread message

holm.h...@gmail.com

unread,
Nov 26, 2021, 3:17:49 AM11/26/21
to fltk.general

Hello,

I have the following code :
    fl_push_matrix();
    fl_rotate(40);
    fl_arc(10, 10 , 400, 100, 0, 360);
    fl_pop_matrix();
 

The fl_rotate seems to have no effect.

What have I missed ?

Best regards
Håvard

Ian MacArthur

unread,
Nov 26, 2021, 3:49:39 AM11/26/21
to fltk.general
That fl_arc is a (so-called) "fast shape" drawing method, rather than a complex shape method. Quoting the docs about "fast shapes":

Drawing Fast Shapes

These functions are used to draw almost all the FLTK widgets. They draw on exact pixel boundaries and are as fast as possible. Their behavior is duplicated exactly on all platforms FLTK is ported. It is undefined whether these are affected by the transformation matrix, so you should only call these while the matrix is set to the identity matrix (the default).

The crux being the "It is undefined whether these are affected by the transformation matrix" part here, of course.

So, rather than fl_arc (int params) what you want is the not-at-all confusingly named fl_arc (double params) - this works, of course, because C++ is happy having multiple functions of the "same name" if their parameters differ and so they have a unique signature.

Note also that the two fl_arc variants take different parameters - the "fast" version takes (int x, int y, int w, int h, double a1, double a2) which is basically the bounding box and the start/end angles; whereas the "complex" one takes (double x, double y, double r, double start, double end) which is basically the centre and radius and the start/end angles...

 

holm.h...@gmail.com

unread,
Nov 26, 2021, 4:19:35 AM11/26/21
to fltk.general

Thanks again Ian,

works like a charm !

Håvard
Reply all
Reply to author
Forward
0 new messages