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

callback while rendering a path #3

Open
4mitabh opened this issue Mar 26, 2019 · 1 comment
Open

callback while rendering a path #3

4mitabh opened this issue Mar 26, 2019 · 1 comment
Labels
feature-request New feature or request

Comments

@4mitabh
Copy link

4mitabh commented Mar 26, 2019

Awesome work on the library.

I was wondering if it is possible to add a callback as a Path is rendered.
The onPaint callback is called after a entire path is completed.

I was trying to achieve results similar to this.

@biocarl biocarl added the feature-request New feature or request label Mar 26, 2019
@biocarl
Copy link
Owner

biocarl commented Mar 26, 2019

Thanks @4mitabh, I'm happy you like it!

Let me see if I understood correctly: You would like to have a callback which fires one frame before a specific part of a Path element is painted so that you can overlay something (e.g. a drawing hand which points to the end of the stroke).

As far as I understand it this is not possible:
Since the animation is controlled by an animation controller (possibly provided externally) I can't predict which element will be drawn beforehand (e.g. the animation controller can forward/reverse anytime). So if I would expose the callback as you described, then your overlay would always lag one frame behind.

But I will think about it a little bit more during the next days and possibly figure out a workaround. The first idea that comes to my mind is providing a callback which extends the current paint operation but still operating in the same frame. But this would mean that you need to manipulate the canvas directly (in your case probably something with drawImage). So your desired callback would be something like this:

onFrame:((canvas, pathSegment) => canvas.drawImage(img,pathSegment.path.computeMetrics().first.extractPath(length*0.99,length).getBounds().center, Paint()))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants