How to draw the three triangle in single page using canvas?

后端 未结 3 388
清歌不尽
清歌不尽 2021-01-24 10:58



        
3条回答
  •  旧时难觅i
    2021-01-24 11:31

    `

    
    
    
    Triangle Canvas Example
    
    
    
    
    
    

    `Try this

    Html :

    
    
    
        Triangle Canvas Example
    
    
        
    
    
    
    
    
    

    javascript :

        var canvasElement = document.querySelector("#myCanvas");
    var context = canvasElement.getContext("2d");
    
    // the triangle
    context.beginPath();
    context.moveTo(100, 100);
    context.lineTo(100, 300);
    context.lineTo(300, 300);
    context.closePath();
    
    // the outline
    context.lineWidth = 10;
    context.strokeStyle = '#666666';
    context.stroke();
    
    // the fill color
    context.fillStyle = "#FFCC00";
    context.fill();
    

提交回复
热议问题