|
|
On 12/31/21 2:59 PM, Greg Ercolano
wrote:
On 12/31/21 2:21 PM, Albrecht Schlosser wrote:
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.
Thanks, I get that too.
Though still not sure how to achieve FLTK drawing coordinates.
So the solution is just leave the scale alone and use 1.0 for
line width.
The default *is* FLTK space, not normalized cairo space, lol.
Guess I was thinking too hard about it.
Apparently scale affects the line width too, so the tiny line
widths
in the cairo examples I was working with were for normalized
space
and weren't showing up because it was too thin, making me think
I was
in the wrong coordinate space.
So anyway, this works:
// Cairo rendering cb called during Fl_Cairo_Window::draw()
static void my_cairo_draw_cb(Fl_Cairo_Window *window, cairo_t *cr) {
const double xmax = (window->w() - 1);
const double ymax = (window->h() - 1);
// Draw green "X"
// Draws an X to four corners of resizable window.
//
cairo_set_antialias(cr, CAIRO_ANTIALIAS_BEST);
cairo_set_line_width(cr, 1.00); // line width for drawing XXX what coord space is this?!
cairo_set_source_rgb(cr, 0.0, 1.0, 0.0); // green
cairo_move_to(cr, 0.0, 0.0); cairo_line_to(cr, xmax, ymax); // draw diagonal "\"
cairo_move_to(cr, 0.0, ymax); cairo_line_to(cr, xmax, 0.0); // draw diagonal "/"
cairo_stroke(cr); // stroke the lines
}
int main(int argc, char **argv) {
Fl_Cairo_Window window(300, 300, "Cairo Draw 'X'");
window.color(FL_BLACK);
window.resizable(&window);
window.set_draw_cb(my_cairo_draw_cb);
window.show(argc, argv);
return Fl::run();
}
--
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/08869062-e859-23c1-4ead-fcc995e90306%40seriss.com.
[ Direct Link to Message ] | |
|
| |