为什么不能用strokeStyle
来源:6-2 编程练习
慕仰8079247
2020-01-28 22:32:03
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>canvas渐变</title>
<style>
canvas{
border:red 1px solid;
}
</style>
</head>
<body>
<canvas id="canvas" width="800px" height="800px">您的浏览器不支持</canvas>
<script>
var canvas=document.getElementById("canvas");
var context=canvas.getContext("2d");
//此处补充代码
var str="前端路径课程";
var str1="字体的width时180px";
context.font="50px sans-serif";
context.strokeStyle="green";
context.textBaseline="top";
context.fillText(str,200,400);
context.fillText(str1,200,300);
/* context.strokeText(str,0,200);*/
</script>
</body>
1回答
好帮手慕码
2020-01-30
同学你好,代码效果没有实现。如下:
另,strokeStyle设置或返回用于笔触的颜色、渐变或模式,并不能实现背景的填充。
如果我的回答帮助到了你 欢迎采纳 祝学习愉快~
相似问题