Skip to content

Feature request: Accessor API in ThorVG.WebCanvas #240

@huming2207

Description

@huming2207

Hi all,

We need an API for traversing a rendered object tree and find the relevant object by given string ID. It's achievable by using ThorVG's Accessor API if that's in native C++. But it doesn't exist in this WebAssembly library.

I think I can make something by exposing the tvg_accessor_xxxxx() APIs by setting the EXPORTED_FUNCTIONS and call the exposed C APIs in the JS side.

But then I think it's not that trivial. Firstly I'm not sure how to handle function pointers in those exposed C API (i.e. how do I make a C callback and point it into tvg_accessor_set()? I'm not sure). Second is I don't know how to match the JS API

Maybe another way is to expose the ThorVG Paint object's hash ID to JS (i.e. make a tvg_paint_get_id() C API that returns the uint32 hash ID) and then port the hash algorithm to JS, then we do a match in JS, which is probably both more efficient and easier to implement.

I will continue working on this later this week and see what I can get it done. I may submit a PR afterwards if I make some progress on this. Please also provide some suggestions if you have any better suggestion. Thanks in advance.

Regards,
Jackson

Metadata

Metadata

Labels

APIsUpdate / Revise APIsquestion/ideaNew concepts / questions / suggestionswebcanvasWebCanvas

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions