Commit ad14da346b6d8b11c0e8fed4b9055d69ace761a3

Thomas de Grivel 2023-11-26T20:46:50

flying toasters

diff --git a/libc3/window/cairo/cairo_sprite.c b/libc3/window/cairo/cairo_sprite.c
index 34bb248..14c22a4 100644
--- a/libc3/window/cairo/cairo_sprite.c
+++ b/libc3/window/cairo/cairo_sprite.c
@@ -18,6 +18,8 @@ void cairo_sprite_blit (const s_cairo_sprite *sprite, uw frame,
 {
   uw frame_x;
   uw frame_y;
+  cairo_matrix_t matrix;
+  cairo_pattern_t *pattern;
   assert(sprite);
   assert(frame < sprite->frame_count);
   assert(cr);
@@ -29,12 +31,15 @@ void cairo_sprite_blit (const s_cairo_sprite *sprite, uw frame,
   frame_x *= sprite->w;
   frame_y *= sprite->h;
   /* printf("%lu %lu\n", frame_x, frame_y); */
-  cairo_set_source_surface(cr, sprite->surface,
-                           (f64) frame_x, (f64) frame_y);
-  /* printf("x y %lu %lu\n", x, y); */
-  cairo_rectangle(cr, (f64) x, (f64) y,
-                  (f64) sprite->w, (f64) sprite->h);
+  pattern = cairo_pattern_create_for_surface(sprite->surface);
+  cairo_matrix_init_translate(&matrix, frame_x, frame_y);
+  cairo_pattern_set_matrix(pattern, &matrix);
+  cairo_set_source(cr, pattern);
+  /* printf("x y w h %lu %lu %lu %lu\n", x, y, sprite->w,
+         sprite->h); */
+  cairo_rectangle(cr, x, y, sprite->w, sprite->h);
   cairo_fill(cr);
+  cairo_pattern_destroy(pattern);
 }
 
 void cairo_sprite_clean (s_cairo_sprite *sprite)
diff --git a/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/flaps.png b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/flaps.png
index d6fd09b..b7b9be5 100644
Binary files a/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/flaps.png and b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/flaps.png differ
diff --git a/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/toast.png b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/toast.png
index 021511b..19c3c90 100644
Binary files a/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/toast.png and b/libc3/window/cairo/quartz/demo/c3_window_cairo_quartz_demo.app/Contents/img/toast.png differ