canvas文字描边的视觉效果
2018-11-23 20:17:37
1284 次阅读
0 个评论
<canvas id="canvas" width="800" height="440" style="background:black;"></canvas>
<script>
var c = document.getElementById("canvas"),
ctx = c.getContext("2d");
//先设置文字字体和大小
ctx.font = "4.2rem Open Sans,Microsoft YaHei";
//设置画笔(绘制线条)操作的线条宽度,非必须;如果不写这句,那就是默认1
ctx.lineWidth = 3;
//实线文字
ctx.fillStyle = "green";
ctx.fillText("实线(实心)文字:fill",10,100);
//空心文字
ctx.strokeStyle = "red";
ctx.strokeText("空心文字:stroke",10,200);
//描边文字:实线与空心文字合起来就是描边啦!先写空心的和先写实心的视觉效果不同:
//1.空心+实心
ctx.strokeStyle = "red";
ctx.strokeText("描边:stroke+fill",10,300);
ctx.fillStyle = "green";
ctx.fillText("描边:stroke+fill",10,300);
//2.实心+空心
ctx.fillStyle = "green";
ctx.fillText("描边:fill+stroke",10,400);
ctx.strokeStyle = "red";
ctx.strokeText("描边:fill+stroke",10,400);
//2种描边效果的区分:简要来说就是:实心与空心谁后写,谁的效果更大!
</script>

00
相关话题
- Fabric.js文字效果
- 解决jquery的$.post或$.ajax发送同步请求时,loading的效果失效
- css实现下圆弧效果
- box-shadow多边阴影效果
- Fabric.js实作: 图片上传并透过拖曳进入canvas
- JS执行耗时任务Loading效果
- Java OCR使用Tess4J进行图片文字识别
- IE7/IE8浏览器纯CSS实现圆角效果
- Nginx的upstream支持的5种分配方式
- jsoup的Elements类
- Redis的bitMap命令
- FFmpeg的ffprobe参数
- spring配置文件中bean的属性name与id的区别
- Apache的commons-net实现FTP的文件上传下载
- 离职,领导的经典言论