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 · 2 comments
Open

Tiling an image #724

yutannihilation opened this issue Oct 27, 2024 · 2 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...!

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