Skip to content

Tiling an image #724

Closed
Closed
@yutannihilation

Description

@yutannihilation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions