canvas绘制正文形并填充-2
效果圖
html結(jié)構(gòu)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>canvas10</title>
<link rel="stylesheet" href="">
</head>
<body>
<canvas id="canvas" style ="border:1px solid #aaa;diplay:block;margin:50px auto;">
當(dāng)前瀏覽器不支持canvas,請(qǐng)更換瀏覽器后再試
</canvas>
</body>
</html>
js腳本
<script>
window.onload = function(){
var canvas = document.getElementById('canvas');
canvas.width = 800;
canvas.height = 800;
var context = canvas.getContext('2d');
drawRect(context,100,100,400,400,10,"#058","red");
}
function drawRect(context,x,y,width,height,borderWidth,borderColor,fillColor){
context.beginPath();
context.rect(x,y,width,height);
context.closePath();
context.lineWidth = borderWidth;
context.fillStyle = fillColor;
context.strokeStyle = borderColor;
context.fill();
context.stroke();
}
</script>
本文轉(zhuǎn)自 ?素顏豬 ?51CTO博客,原文鏈接:http://blog.51cto.com/suyanzhu/1892696
總結(jié)
以上是生活随笔為你收集整理的canvas绘制正文形并填充-2的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: [翻译]Axure-Basic Inte
- 下一篇: php拆分数字字符串方法