jakubfiala / atrament

A small JS library for beautiful drawing and handwriting on the HTML Canvas.
http://fiala.space/atrament/demo
MIT License
1.55k stars 116 forks source link

Stream the canvas as the drawing is made #51

Closed MisterDA closed 4 years ago

MisterDA commented 4 years ago

Hi!

I’d like to stream the drawing as it’s being made to other clients. I’m looking for ways to do that.

One way would be to capture the stream of the canvas, and stream it via WebRTC.

Another would be to get real-time information of the drawing (points, colors, etc) and replay the movements on listener devices.

What would be your advice? Thanks!

jakubfiala commented 4 years ago

Hi there @MisterDA, thanks for submitting your question! This is a very interesting proposition, I think both techniques you mention are sensible. I guess it depends on your use case. Capturing the stream would allow you to broadcast anything that happens to the canvas (not just Atrament drawing), and crucially, the timing would be much more precise. With compression I think the bandwidth also wouldn't be a huge issue.

On the other hand, sending the stroke data would let you save the state on the client's device, allowing you to replay the drawing step by step or even modifying it.

If you can share more about your project, I'd be happy to think about it a bit more :)

MisterDA commented 4 years ago

On the other hand, sending the stroke data would let you save the state on the client's device, allowing you to replay the drawing step by step or even modifying it.

Does Atrament have a "real time" event watcher that would allow sending the drawing moves as they are made?

If you can share more about your project, I'd be happy to think about it a bit more :)

Of course, I’d like to do a simple online Pictionary :) Atrament seems the nicest sketchpad lib out there.

jakubfiala commented 4 years ago

Amazing! Atrament does indeed support stroke recording, see the section on Programmatic Drawing in the README. Let me know if you have any further questions :)

jakubfiala commented 4 years ago

closing this as it seems the question has been answered :pray: