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

Tiling an image #724

Open
yutannihilation opened this issue Oct 27, 2024 · 7 comments
Open

Tiling an image #724

yutannihilation opened this issue Oct 27, 2024 · 7 comments

Comments

@yutannihilation
Copy link
Contributor

Scene::fill() accepts peniko::BrushRef::Image as a brush, and I expect it fills the shape with repetition of the specified image if Extend::Repeated is specified. However, the following code doesn't fill. Is this the expected result? Is something wrong in my code?

    #[rustfmt::skip]
    let colors = [
        Color::RED,  Color::BLUE, Color::BLUE,
        Color::BLUE, Color::RED,  Color::BLUE,
        Color::BLUE, Color::BLUE, Color::RED,
    ];

    let mut blob: Vec<u8> = Vec::new();
    colors.iter().for_each(|c| {
        blob.push(c.r);
        blob.push(c.g);
        blob.push(c.b);
        blob.push(c.a);
    });

    let data = vello::peniko::Blob::new(Arc::new(blob));
    let image = vello::peniko::Image::new(data, vello::peniko::Format::Rgba8, 3, 3)
        .with_extend(vello::peniko::Extend::Repeat);
    let brush = vello::peniko::BrushRef::Image(&image);

    // Draw a filled circle
    let circle = Circle::new((400.0, 400.0), 200.0);
    scene.fill(
        vello::peniko::Fill::NonZero,
        Affine::IDENTITY,
        brush,
        None,
        &circle,
    );
    scene.stroke(
        &vello::kurbo::Stroke::new(10.0),
        Affine::IDENTITY,
        Color::WHITE,
        None,
        &circle,
    );

image

@DJMcNab
Copy link
Member

DJMcNab commented Oct 28, 2024

This isn't yet implemented. See also discussion in #722 - we currently only properly support the Pad extend mode, and even then not properly. The code which would need to change would be in that same part of fine.

I don't think there's an existing issue for this, thanks for reporting.

@yutannihilation
Copy link
Contributor Author

Oh, thanks for the explanation. I didn't catch up with the discussion in #722...!

@dfrg
Copy link
Collaborator

dfrg commented Nov 8, 2024

I have the code to get extend modes working in the fine shader but it’ll take more work to plumb it through the pipeline. I’d also like to support different extend modes for the x/y directions along with (at least) nearest neighbor sampling but those will require changes to peniko.

@marcpabst
Copy link

marcpabst commented Nov 13, 2024

Just jumping in to say this is a super useful feature! It’d be awesome to see both better support for the current API and the addition of extend_x and extend_y.

@marcpabst
Copy link

@dfrg any chance you have a branch with the changes to the fine shader?

@waywardmonkeys waywardmonkeys added this to the Vello 0.4 Release milestone Nov 22, 2024
@dfrg
Copy link
Collaborator

dfrg commented Dec 12, 2024

Sorry for the delay. I have a PR up for this at #766

@marcpabst
Copy link

Cool, thank you!

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

5 participants