pathfinder
pathfinder copied to clipboard
sub-canvases drawn with draw_image cropped to the dimensions of the parent canvas
When using draw_image to draw a large canvas onto a smaller canvas the large canvas is unexpectedly cropped to the size of the small canvas.
For example, I expect this code to draw the tip of a red triangle in a black frame:
let mut canvas = Canvas::new(vec2f(500.0, 500.0)).get_context_2d(font_context.clone());
let mut sub_canvas = Canvas::new(vec2f(500.0, 750.0)).get_context_2d(font_context.clone());
let mut path = Path2D::new();
path.move_to(vec2f(0.0, 0.0));
path.line_to(vec2f(500.0, 0.0));
path.line_to(vec2f(250.0, 750.0));
path.close_path();
sub_canvas.set_fill_style(ColorU::new(255, 0, 0, 255));
sub_canvas.fill_path(path, FillRule::Winding);
canvas.draw_image(sub_canvas.into_canvas(), vec2f(0.0, -400.0));
let mut frame = Path2D::new();
frame.rect(RectF::new(vec2f(0.0,0.0), vec2f(500.0, 500.0)));
canvas.set_stroke_style(ColorU::new(0, 0, 0, 255));
canvas.set_line_width(3.0);
canvas.stroke_path(frame);
Instead it draws the triangle with the tip cut off:
Full example here: https://gist.github.com/alec-deason/7bd591d7f6442f92e84e56e732dd7014
I am testing this against 4c8699 because later commits hang when rendering due to #428