Giter VIP home page Giter VIP logo

Comments (3)

JSUYA avatar JSUYA commented on June 9, 2024 1

Hi @hermet

When using PathCommand (also Path APIs), there is a difference between drawing with {CubicTo, Close} and drawing with {MoveTo, CubicTo, Close}.
If CubicTo does not have an initial point (the previous last point(current point, ctrl point)), it may be decided invalid or an arbitrary initial point of 0,0 can be added internally. However, adding internally may differ from the user's intention.

In order to fix this issue, SVG can add logic that does not draw paths if the path does not start with MoveTo.
However, since the PathCommand rule must come first, please let me know your opinion.

Note: The rules(spec) for PathCommand do not strictly follow the SVG specification.

{CubicTo, Close} case

    tvg::PathCommand cmds2[2];
    cmds2[0] = tvg::PathCommand::CubicTo;
    cmds2[1] = tvg::PathCommand::Close;

    //CubicTo 1
    tvg::Point pts2[3];
    pts2[0] = {1, 1.5};      //Ctrl1
    pts2[1] = {1.5, 4.5};      //Ctrl2
    pts2[2] = {9.5, 1};                   //To
    auto shape2 = tvg::Shape::gen();
    shape2->appendPath(cmds2, 2, pts2, 3);     //copy path data
    shape2->fill(255, 255, 0);
    shape2->scale(50);
    if (canvas->push(std::move(shape2)) != tvg::Result::Success) return;

{MoveTo, CubicTo, Close} case

    tvg::PathCommand cmds2[3];
    cmds2[0] = tvg::PathCommand::MoveTo;
    cmds2[1] = tvg::PathCommand::CubicTo;
    cmds2[2] = tvg::PathCommand::Close;

    //CubicTo 1
    tvg::Point pts2[4];
    pts2[0] = {0, 0};      //Move 0 0
    pts2[1] = {1, 1.5};      //Ctrl1
    pts2[2] = {1.5, 4.5};      //Ctrl2
    pts2[3] = {9.5, 1};                   //To
    auto shape2 = tvg::Shape::gen();
    shape2->appendPath(cmds2, 3, pts2, 4);     //copy path data
    shape2->fill(255, 255, 0);
    shape2->scale(50);
    if (canvas->push(std::move(shape2)) != tvg::Result::Success) return;

from thorvg.

hermet avatar hermet commented on June 9, 2024 1

@MewPurPur I think your issue has been fixed. please double-check the issue with the upcoming v0.11.7 release. thanks.

from thorvg.

hermet avatar hermet commented on June 9, 2024

@JSUYA, Thanks your info. The renderer will not guarantee the rendering results when it receives invalid input. Therefore, I suggest the following:

  1. Enhance the Shape::appendPath() API to return 'InvalidArgument' if the first path command data does not start with MoveTo.
  2. Subsequently, the SVG loader should be modified to discard the paint instance building in case of appendPath() failure.

from thorvg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.