App下載
首頁javascriptdrawing_settingsCanvas - 如何設置十六進制顏色值的筆畫樣式

Canvas - 如何設置十六進制顏色值的筆畫樣式

我們想知道如何設置十六進制顏色值的筆畫樣式。


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>//<![CDATA[ 
window.onload=function(){
    var context = canvas.getContext("2d");
    context.strokeStyle = '#000000';
    context.fillStyle = '#000000';
    context.moveTo(10, 10);
    context.lineTo(50, 10);
    context.save();
    context.lineWidth = 15;
    context.moveTo(10, 30);
    context.lineTo(50, 30);
    context.restore();
    context.moveTo(10, 50);
    context.lineTo(50, 50);
    context.stroke();
}//]]>  
</script>
</head>
<body>
      <canvas id="canvas" height="400" width="600">
      </canvas>
</body>
</html>