Content-Length: 243892 | pFad | http://github.com/thorvg/thorvg/issues/3121

1C API: Introduce a Path class · Issue #3121 · thorvg/thorvg · GitHub
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

API: Introduce a Path class #3121

Open
hermet opened this issue Jan 13, 2025 · 2 comments
Open

API: Introduce a Path class #3121

hermet opened this issue Jan 13, 2025 · 2 comments
Assignees
Labels
APIs Update / Revise APIs refactoring Code refactoring / Exceptional handles
Milestone

Comments

@hermet
Copy link
Member

hermet commented Jan 13, 2025

This is a proposal to separate the Path feature from the Shape, enabling path instance reuse and providing a clearer user API. Meanwhile, here are some concerns regarding the potential downsides:

  • Increased Complexity: more class, more code and complexity.
  • Potential Overhead: memory fragmentation. 2x instances (shape/path) are required.
  • Duplication Risks: Some logic & APIs such as reference count are duplicated.
class Path
{    
    Result reset();

    //primitives
    Result moveTo(Point to);
    Result lineTo(Point to);
    Result curveTo(Point ctrl1, Point ctrl2, Point end);
    Result close();

    //preset
    Result append(const PathCommand* cmds, uint32_t cmdCnt, const Point* pts, uint32_t ptsCnt);
    Result appendCircle(Point center, Point radius);
    Result appendRect(Point pos, Point size, Point roundness);

    //TBD: Path combines (maybe after 1.0)
    Result add(Path* path);
    Result subtract(Path* path);
    Result intersect(Path* path);
    Result difference(Path* path);

    Result get(const PathCommand** cmds, uint32_t* cmdsCnt, const Point** pts, uint32_t* ptsCnt) const;

    Path* duplicate();
    Path* gen();

    //reference count
    uint32_t ref();
    uint32_t unref();
    uint32_t refCnt();
};
auto path = Path::gen();
...
Shape->path(path);
auto path = Shape->path();
//update the existing path
...
Shape->path(path);
@hermet hermet added the APIs Update / Revise APIs label Jan 13, 2025
@hermet hermet added this to the 1.0 milestone Jan 13, 2025
@hermet hermet added this to ThorVG Jan 13, 2025
@hermet hermet moved this to In Progress in ThorVG Jan 13, 2025
@hermet hermet self-assigned this Jan 13, 2025
@hermet hermet added the refactoring Code refactoring / Exceptional handles label Jan 13, 2025
@hermet hermet mentioned this issue Jan 13, 2025
20 tasks
@SergeyLebedkin
Copy link
Member

Result intersect(Path* path);
Result difference(Path* path);

Its looks like path merge and can be used for clipping/masking in general way for cross api

@hermet
Copy link
Member Author

hermet commented Jan 13, 2025

Its looks like path merge and can be used for clipping/masking in general way for cross

@SergeyLebedkin yes, ultimately.

@hermet hermet removed this from ThorVG Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APIs Update / Revise APIs refactoring Code refactoring / Exceptional handles
Projects
None yet
Development

No branches or pull requests

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/thorvg/thorvg/issues/3121

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy