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

Port analytical anti-aliased Path filling #8

Open
RazrFalcon opened this issue Nov 7, 2020 · 1 comment
Open

Port analytical anti-aliased Path filling #8

RazrFalcon opened this issue Nov 7, 2020 · 1 comment

Comments

@RazrFalcon
Copy link
Collaborator

Aka SkScan_AAAPath.cpp.

There are a lot of code, like 2000-2500 LOC, and this method used only in some specific cases. Mainly for polygons, afaiu. Not sure if it's worth it.

@Azervu
Copy link

Azervu commented Feb 7, 2022

Example of aliasing

fn main() {
    let mut paint = Paint::default();
    paint.anti_alias = true;
    paint.set_color_rgba8(255, 0, 0, 255);

    let mut n = 12;
    let mut pixmap = Pixmap::new(n, n).unwrap();
    let width = 1. / n as f32;
    for x in 0..n {
        for y in 0..n {

            let origin = ((x as f32) * (1.0 + width), (y as f32) * (1.0 + width));

            pixmap.fill_path(&{
                let mut pb = PathBuilder::new();
                pb.move_to(origin.0, origin.1);
                pb.line_to(origin.0, origin.1 + width);
                pb.line_to(origin.0 + width, origin.1 + width);
                pb.line_to(origin.0 + width, origin.1);
                pb.close();
                pb.finish().unwrap()
            }, &paint,FillRule::EvenOdd,Transform::identity(),None);
        }
    }

    pixmap.save_png("./image.png").unwrap();
}

Render (x10)
image

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

2 participants