How to have an infinitely big canvas?

后端 未结 2 1179
野性不改
野性不改 2021-02-06 05:56

I am building a web app that uses a canvas to draw on. I would like to have an infinitly big drawing space (you can scroll as long as you want in any direction) AND save the dat

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-06 06:21

    I have made a library to deal with this called TiledCanvas It provides interfaces to zoom and move. And draw in an infinite space using all the canvas apis.

    It lets you load chunks dynamically based on coordinates, you just give it a function that gets as paramters a x, y and callback and you simply give it back something that can be drawn on a canvas.

    https://github.com/Squarific/TiledCanvas

提交回复
热议问题