FLTK logo

Re: [fltk.general] How to draw an "X" in cairo

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: How to draw an "X" in cairo Greg Ercolano Dec 31, 2021  
 


On 12/31/21 2:21 PM, Albrecht Schlosser wrote:
On 12/31/21 8:54 PM Greg Ercolano wrote:
Trying to just draw a simple "X" to all four corners of the Fl_Cairo_Window.
Having trouble getting this working.

My understanding is the default coordinate space of cairo is:

    (0.0, 0.0) = top/left
    (1.0, 1.0) = bottom/right

..and to use FLTK's coordinate space, you'd use cairo_scale(cr, w(), h())
to convert to the window's integer coordinate space.

Here's what I have (it doesn't work - weird behavior).
Am I missing something?


I don't know how the coordinate systems are (or should be) translated, but if I change only your two drawing code lines to

cairo_move_to(cr, 0.0, 0.0); cairo_line_to(cr, 1.0, 1.0); // draw diagonal "\"
cairo_move_to(cr, 0.0, 1.0); cairo_line_to(cr, 1.0, 0.0); // draw diagonal "/"

the "green X" works for me.

If you look at test/cairo_test.cxx you can see that all the "buttons" are drawn inside the (0.0 ... 1.0) coordinate space, using the same cairo_scale instruction as you do.

   Thanks, I get that too.

   Though still not sure how to achieve FLTK drawing coordinates.

   One would think if setting the scale to (w,h) gets you a (0,0,1,1) coord system,
   then a scale of (1.0/w, 1.0/h) would achieve a (0,0,w,h) coord system,
   but that doesn't seem to work. Or at least I'm not seeing anything.

   Maybe the scale is affecting the line width coordinate space, but doing
   the above and setting the line width to 1.0 doesn't work.. hmm.

   Anyway, that's what I'm struggling with.

--
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/c8289ef8-ceb1-ef36-3411-983b6eb11543%40seriss.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'.