thorvg / thorvg

Thor Vector Graphics is a lightweight portable library used for drawing vector-based scenes and animations including SVG and Lottie. It can be freely utilized across various software platforms and applications to visualize graphical contents.

Home Page:https://www.thorvg.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect results for gradient mask

mgrudzinska opened this issue · comments

    //Rect
    auto shape1 = tvg::Shape::gen();
    shape1->appendRect(100, 100, 600, 600);
    shape1->fill(0, 0, 255);
    shape1->strokeWidth(100);
    shape1->strokeFill(0, 255, 0);

    //Mask
    auto mask1 = tvg::Shape::gen();
    mask1->appendCircle(400, 400, 450, 450);

    auto fill1 = tvg::LinearGradient::gen();
    fill1->linear(0, 400, 800, 400);
    tvg::Fill::ColorStop colorStops1[2];
    colorStops1[0] = {0,255,0,0,255};
    colorStops1[1] = {1,0,0,255,255};
    fill1->colorStops(colorStops1, 2);

    mask1->fill(std::move(fill1));

    shape1->composite(std::move(mask1), tvg::CompositeMethod::AlphaMask);
    canvas->push(std::move(shape1));
Zrzut ekranu 2024-04-19 o 02 06 19

No gradient should be observed since AlphaMask should use only the alpha value and for both colors 255 is set

ThorVG composes a mask image using 8-bit channel data, currently, the gradient mask does not utilize this.