[cairo] cairo_in_fill w/rotate?
Mark Olesen
markjolesen at gmail.com
Sat Feb 6 06:15:01 CET 2016
Is cairo_in_fill supposed to work with rotation?
The following code gets hits on the un-rotated rectangle.
It's like the rotation is ignored. Thanks in advance.
libcairo.so.2.11400.6
#include <gtk/gtk.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
gboolean
motion_notify_callback(GtkWidget *widget,
GdkEventMotion *event,
gpointer user_data)
{
GtkWindow *l_win;
int l_hit;
cairo_t *cr;
l_win = (GtkWindow *)user_data;
cr = gdk_cairo_create(gtk_widget_get_window(GTK_WIDGET(l_win)));
cairo_new_path(cr);
cairo_rotate(cr, 45.0); // ROTATION SEEMS TO BE IGNORED
cairo_rectangle(cr, 0.0, 0.0, 100.0, 100.0);
// only gets hits on un-rotated rectangle
l_hit = cairo_in_fill(cr, (*event).x, (*event).y);
printf("rect hit=%d %lf %lf\n", l_hit, (*event).x, (*event).y);
cairo_destroy(cr);
return 1;
}
gboolean
draw_callback(GtkWidget *widget, cairo_t *cr, gpointer data)
{
cairo_save(cr);
cairo_rotate(cr, 45.0);
cairo_rectangle(cr, 0.0, 0.0, 100.0, 100.0);
cairo_stroke(cr);
cairo_restore(cr);
return FALSE;
}
int
main(int argc, char *argv[])
{
gtk_init(&argc, &argv);
GtkWindow *g_win = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL));
g_signal_connect(G_OBJECT(g_win), "destroy", G_CALLBACK(gtk_main_quit),
NULL);
GtkBox *box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0));
GtkDrawingArea* g_drawing_area = gtk_drawing_area_new();
gtk_box_pack_start(box, GTK_WIDGET(g_drawing_area), 1, 1, 0);
gtk_container_add(GTK_CONTAINER(g_win), GTK_WIDGET(box));
gtk_widget_set_size_request(g_drawing_area, 300, 300);
g_signal_connect(G_OBJECT(g_drawing_area), "draw",
G_CALLBACK(draw_callback), NULL);
g_signal_connect(G_OBJECT(g_drawing_area), "motion-notify-event",
G_CALLBACK(motion_notify_callback), g_win);
gtk_widget_add_events(
g_drawing_area,
gtk_widget_get_events(g_drawing_area) |
GDK_POINTER_MOTION_MASK);
gtk_widget_show_all(GTK_WIDGET(g_win));
gtk_main();
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20160205/25f22da9/attachment.html>
More information about the cairo
mailing list