繁体   English   中英

如何使用引导程序使HTML5画布绘制应用程序响应?

[英]How to make a HTML5 canvas paint application responsive using bootstrap?

代码中的哪些更正可使其响应并使圆形和矩形出现在用户单击过的屏幕上。

<script>
   function mouseDown(e) {
     var a= e.pageX - this.offsetLeft;
     var b= e.pageY - this.offsetTop;
   }

   function c1()
   {
    ctx.arc(currX,currY,41,0, 2*Math.PI);
    ctx.stroke();
   }
   function r1(e)
   {
    var a= e.pageX - this.offsetLeft;
    var b= e.pageY - this.offsetTop;
    ctx.rect(a,b,Math.abs(prevX - currX), Math.abs(prevY - currY)); 
    ctx.stroke();
   }
</script>

您可以使用窗口的宽度和高度使此画布响应。

我在下面尝试了一些代码可以提供帮助。

<script>
 var canvas = document.getElementById('canvas_id'),
  ctx = canvas.getContext('2d');

 function init(){
   canvas.height = window.innerHeight(); //innerHeight is the viewable screen
   canvas.width = window.innerWidth();
 }

init(); //call this function when the page loads maybe in the body tag
</script>

关于制作圆形和矩形的一点我不确定您要的是什么。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM