HTML5 / js - how to animate straight line between two coordinates?

前端 未结 5 2263
你的背包
你的背包 2021-02-07 23:37

Simple enough question (could be wrong)

im looking to animate between two points in a straight line, using HTML5 and/or Jquery.

ctx.beginPath();
ctx.mov         


        
5条回答
  •  生来不讨喜
    2021-02-07 23:43

    This works for me :

    HTML :

    
    
    
    
        
        
    
    
    

    JS :

    var c = document.getElementById('canvas');
    var ctx = c.getContext('2d');
    
    ctx.beginPath();
    ctx.moveTo(0, 0); // a
    ctx.lineTo(100, 100); // b
    ctx.stroke();
    

提交回复
热议问题