Comments (3)
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.
@MewPurPur I think your issue has been fixed. please double-check the issue with the upcoming v0.11.7 release. thanks.
from thorvg.
@JSUYA, Thanks your info. The renderer will not guarantee the rendering results when it receives invalid input. Therefore, I suggest the following:
- Enhance the Shape::appendPath() API to return 'InvalidArgument' if the first path command data does not start with MoveTo.
- Subsequently, the SVG loader should be modified to discard the paint instance building in case of appendPath() failure.
from thorvg.
Related Issues (20)
- Memory problems that occur when the wasm class is destroyed HOT 2
- Corrupt radial gradient on Apple Silicon HOT 5
- Incorrect outline for specific curve HOT 1
- Hash collisions in SVG loader HOT 4
- Lottie regression bug HOT 1
- Add c/c++ test suites for lottie slot
- Apply clang-format HOT 1
- Lottie loader is not updating the canvas HOT 8
- Metal backend support?
- Adding a web build test CI HOT 2
- Lottie: Animation Segment(Marker) Support
- Lottie/slot: multiple properties in single slot not working
- broken lottie trimpath (individual)
- Feature Request: Clear canvas without deleting paints HOT 2
- Storing the address of local variable HOT 2
- CAPI: update colorspace interfaces
- Lottie: Support feasibility of accessing a specific Lottie node by identifier
- Lost compose effect when call canvas::draw second time
- lottie compatibility issue HOT 2
- Embedded compilers doesn't like `_A`, `_B`, and `_C` function names.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from thorvg.