0

I have created a react app Which is very similar to office whiteboard. I would like to generate a thumbnail or card preview of each whiteboard and wondering how to go about it.

My initial thought was to just create a card component and render the shapes to that the same way I do for the real whiteboard. However, the points for each shape will be outside the stage and I can't think of how I can scale it down.

Any ideas?

cbutler
  • 833
  • 13
  • 36

1 Answers1

1

Take a look at the official canvas thumbnail demo from Konva.

You can use a similar approach with react-konva.

Create a special component for the preview.

I think this approach will work better and probably more performant (depending on your app). You just need to create another Stage and draw all objects into it. It will be better if you can draw simplified versions of the shape, because the drawing is much smaller, so not all details are visible.

You will have to calculate your own scale ratio.

Use image preview

Instead of making a full components tree for the whiteboard, you can just export the main stage into an image and show it. You have to do reexport from time to time.

lavrton
  • 18,973
  • 4
  • 30
  • 63
  • Hey thanks man! You've answered a few of my questions on react-konva now :) I will take a look into these options. – cbutler Oct 27 '20 at 17:08
  • I went for the first option and this works fine. I'm not sure how to draw a simplified version though, I have no way to tell what should be drawn vs what should not. Is it an idea to skip points and take every second x,y pair? – cbutler Nov 02 '20 at 11:39
  • It depends on your app. When I made something similar, I removed all texts, strokes and shadows on the preview. They all were not visible. Also removing them improved the performance. – lavrton Nov 02 '20 at 15:25