FLTK logo

[fltk.general] Re: Issue with Fl_Widget::image() - misalignment

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: Issue with Fl_Widget::image() - misalignment "'pvr... 06:20 Apr 10  
 

On Tuesday, April 9, 2024 at 10:41:08 PM UTC+1 Matthias Melcher wrote:

    // alternatively, look at the "complex drawing function"
    // where you just set and angle and the draw a polygon (arrow)
    // which FLTK will rotate for you
  }


Thanks Matthias,

I started to look at this in the cold light of day and yes it's definitely easier just to draw the polygon for the North wind and rotate it by the required number of degrees. I found the code in unittest_complex_shapes.cxx rather difficult to follow, but running the unit test and seeing how it worked definitely helped.

One issue: I found I had to use fl_rotate(-(double)dirn) to get it to rotate successfully, whereas fl_vertex((-)[int],(-)[int]) worked OK drawing the arrow.

So as I understood the process - to draw an arrow with the head starting 3/4 the length and +/-5 pixels wide. It looks a lot better than my trying to work out the angles and hoping I was using the trig functions correctly.

fl_push_matrix();
// Set the drawing to be centred in the widget and rotated by the wind direction
fl_translate(x_zero, y_zero);
fl_rotate(-(double)dirn);
fl_begin_complex_polygon();
// Draw an arrow down from North
fl_vertex(1, -radius);
fl_vertex(1, radius/2);
fl_vertex(5, radius/2);
fl_vertex(0, radius);
fl_vertex(-5, radius/2);
fl_vertex(-1, radius/2);
fl_vertex(-1, -radius);
//
fl_end_complex_polygon();
fl_pop_matrix();



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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/64696d9e-339f-47ab-9cca-34e7240faccdn%40googlegroups.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.