Re: Path_extents after coordinate system is rotated.

Stefan Salewski <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
On Wed, 2015-04-08 at 02:38 +0200, Stefan Salewski wrote:
> I tried to fill polygons or curves with mesh or hatch pattern.

OK, after modifying my example code I do now better understand what is
going on. Seems that new path_extents() after rotation is not calculated
from path itself, but from initial path_extents(). See

http://ssalewski.de/tmp/image2.png

// gcc test.c -o test `pkg-config --cflags --libs gtk+-3.0`
#include <cairo.h>

int main(void)
{
  cairo_surface_t *surface;
  cairo_t *cr;
  double x1, y1, x2, y2;

  surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 400, 400);
  cr = cairo_create(surface);
  cairo_set_source_rgb(cr, 1, 1, 1);
  cairo_paint(cr);
  cairo_set_source_rgb(cr, 0, 0, 0);
  cairo_set_line_width(cr, 4);
  cairo_move_to(cr, 300, 200);
  cairo_line_to(cr, 300, 300);
  cairo_line_to(cr, 250, 250);
  cairo_path_extents(cr, &x1, &y1, &x2, &y2);
  cairo_stroke(cr);
  cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1);
  cairo_stroke_preserve(cr);
  cairo_save(cr);
  cairo_rotate(cr, 0.8);
  cairo_path_extents(cr, &x1, &y1, &x2, &y2);
  cairo_new_path(cr);
  cairo_set_source_rgb(cr, 0.5, 0.5, 0.5);
  cairo_rectangle(cr, x1, y1, x2 - x1, y2 - y1);
  cairo_stroke(cr);
  cairo_restore(cr);
  cairo_surface_write_to_png(surface, "image.png");
  cairo_destroy(cr);
  cairo_surface_destroy(surface);
  return 0;
}

-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.