CSS3-Canvas画布(文本)

<!DOCTYPE html5>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS3-Canvas画布(文本)</title>
<script>
window.onload=function () {

var canvas=document.getElementById("canvas");//获取canvas对象
var ctx=canvas.getContext("2d"); //创建二维的绘图上下文对象
ctx.font="50px Georgia";
ctx.strokeStyle="lightgreen";
ctx.strokeText("斜风细雨不须归",50,50);//无填充文本

//对齐方式 使用

ctx.fillStyle="lightpink";
ctx.fillText("人间有味是清欢",50,300);//有填充文本

}

</script>
</head>
<body>
<h2>Canvas画布(文本)</h2>
<canvas id="canvas" width="500" height="500" style="border:1px solid red ">
浏览器不支持canvas
</canvas>
</body>
</html>
原文地址:https://www.cnblogs.com/YoogaChan/p/6964732.html