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

Update documentation for offscreen rendering and update ref handling #152

Conversation

wcandillon
Copy link
Collaborator

No description provided.

// Draw callback
const onDraw = useDrawCallback(
(canvas, info) => {
if (typeof ref === "function") {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here ref callback aren't supported anyways.

@wcandillon
Copy link
Collaborator Author

@chrfalch no strong opinon on the ref thingy. We could revert it.

@wcandillon
Copy link
Collaborator Author

Here's a suggestion for the doc: #152 and to have ref instead of innerRef

Except for the docs, it's a green light for me 👍🏻

docs/docs/image.md Outdated Show resolved Hide resolved
export const Demo = () => {
const ref = useCanvasRef();
const onPress = useEffect(() => {
setTimeout(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just add a simple button taking a snapshot? Looks a bit strange with the setTimeout call :)


## Getting a Canvas Snapshot

You can save your drawings as an image, using `makeImageSnapshot`. This method will return an [Image instance](/docs/images#instance-methods). This instance can be used to do anything: drawing it via the `<Image>` component, or being saved or shared using binary or base64 encoding.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The image instance can be rendered using the Image component, saved to disk or passed along for further processing using binary or base64 encoding."

| encodeToBytes | Encodes Image pixels, returning result as UInt8Array |
| encodeToBase64 | Encodes Image pixels, returning result as a base64 encoded string |

## Offscreen Drawing
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be documented somewhere? Not sure where, but I think this info should be available somewhere - especially since it adds a few things on top of the available CanvasKit API.

@chrfalch chrfalch merged commit f5343b3 into feature/offscreen-surface-snapshots Jan 28, 2022
@chrfalch chrfalch deleted the feature/offscreen-surface-snapshots-docs branch January 28, 2022 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants