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

Is there an easy way to make the canvasRGBA method cancellable? #37

Open
rodmccutcheon opened this issue Jul 5, 2020 · 4 comments
Open
Labels

Comments

@rodmccutcheon
Copy link

No description provided.

@brettz9
Copy link
Collaborator

brettz9 commented Jul 5, 2020

Sorry, what do you mean by cancelable? It's not an event, so not clear what you mean.

The method will silently exit early if the last (6th) argument is not a number (or a string that resolves to a number) or if it is less than 1--in case that's what you meant.

Or did you mean that you wanted a method that also fed getImageDataFromCanvas to processImageDataRGBA, but returned the resulting imageData instead of passing it to putImageData?

@rodmccutcheon
Copy link
Author

rodmccutcheon commented Jul 5, 2020 via email

@brettz9
Copy link
Collaborator

brettz9 commented Jul 5, 2020

Yes, the function is not implemented asynchronously, so there'd be no way to get alerted even if there were a flag that was checked (a callback could be added within the loops and passed some data, but it would run synchronously, and I wouldn't think that would be of any use).

The most granular option would be to make a separate asynchronous version of processImageDataRGBA, e.g., turning the method into a generator which instead of looping to build an ImageData object, yielded an individual pixel index and value which could in turn be set by the caller on their own ImageData object (and updated on the canvas as desired), and then, with the generator iterated further at whatever interval the caller wanted (avoiding lock-up)--and optionally canceled during such iteration.

@brettz9
Copy link
Collaborator

brettz9 commented Jul 5, 2020

Alternatively, perhaps #16 might help enough to avoid your issue in the first place.

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

No branches or pull requests

2 participants