Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create a custom shape in the canvas using lines #88

Open
kanajakala opened this issue Jul 23, 2024 · 0 comments
Open

Unable to create a custom shape in the canvas using lines #88

kanajakala opened this issue Jul 23, 2024 · 0 comments

Comments

@kanajakala
Copy link

kanajakala commented Jul 23, 2024

Hello, I am was trying to create a function that could generate a triangle in the canvas:

fn triangle(ctx: *capy.DrawContext, x: i32, y: i32, size: i16) void {
    ctx.line(x, y, x + size, y);
    ctx.line(x + size, y, x + size, y + size);
    ctx.line(x + size, y + size, x, y);
    ctx.fill();
}

It draws triangles but only as strokes resulting in a hollow shape. I do not know if it's supposed to be that way but maybe removing c.cairo_stroke(self.cr); from

pub fn line(self: *DrawContext, x1: i32, y1: i32, x2: i32, y2: i32) void {
        c.cairo_move_to(self.cr, @as(f64, @floatFromInt(x1)), @as(f64, @floatFromInt(y1)));
        c.cairo_line_to(self.cr, @as(f64, @floatFromInt(x2)), @as(f64, @floatFromInt(y2)));
        c.cairo_stroke(self.cr);
    }

in src/backends/gtk/Canvas.zig could help ? If this a not a solution is there any other way to draw custom shapes in the canvas ? Thanks for creating this awesome library btw :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant