html5 canvas redraw on resize

后端 未结 3 1207
暗喜
暗喜 2020-12-09 12:56

I have two canvas elements and need them to be resized on buttons click.

3条回答
  •  佛祖请我去吃肉
    2020-12-09 13:24

    I decided to use a scale variable to resize my scales. I resize the canvas canvas.width *= 2; and then I redraw my scales.

    var scaleStep;

    and use add it into the code: ctx.lineTo(12*24*cScale+12, canvas.height-24); where the scaling needs to be done. The scaleStep is 2 when maximizing the canvas and 1 when returning to the original size.

提交回复
热议问题