当前位置:网站首页>canvas 学习笔记
canvas 学习笔记
2022-04-21 10:23:00 【晓_枫】
html
<canvas style="border: solid 1px red" id="cvs"><canvas>
js
绘制一条线
let cvs = document.querySelect('#cvs'); // 获取画布元素
let ctx = ctx.getContent('2d'); //获取工具集
ctx.moveTo(40, 40); // (x, y) 选择起始点
ctx.lineTo(80, 80); // 绘制线到目标点
// 这时所有的操作都只是保存在内存里的,没有显示到页面
ctx.storke(); // 绘制,使上面的内容显示到页面中
绘制三角形并修改颜色、线条宽度
var cvs = document.getElementById('cvs'); // 获取画布元素
var ctx = cvs.getContext("2d"); // 获取工具集
ctx.moveTo(50, 50); // 定位开始位置
ctx.lineTo(150, 50); // 第一个点
ctx.lineTo(80, 100); // 第二个点
ctx.closePath(); // 闭合路径, 这里也可以使用 ctx.lineTo(50, 50) 效果相同
ctx.strokeStyle = 'red'; // 设置绘制图形的颜色
ctx.lineWidth = 20; // 设置线条宽度
ctx.stroke(); // 绘制
版权声明
本文为[晓_枫]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_18676843/article/details/124298341
边栏推荐
- SQL question set [(2)]
- L1-054 福到了 (15 分)
- SQL:树形三层职业分类表的SQL文件
- Operating system - thread safety - Learning
- [cloud resident co creation] database principle and application course of Huawei cloud database 11. Database system control
- zsh: segmentation fault 解决方法
- 7-2 符号配对|PTA
- Better than SQL, another domestic database language was born
- MKL and vs2019 configuration method
- [learn junit5 from official documents] [i] [overview] [learning notes]
猜你喜欢
Transaction isolation level and mvcc

AOT和单文件发布对程序性能的影响

Opencv -- template matching

每日一题(2022-04-20)——文件的最长绝对路径

【并发编程043】CAS存在的问题,ABA问题,如何解决的?

Rose again. In April, the salary of programmers across the country was released, and it became the salary ceiling of the industry? I'm excited after reading it

HMS Core 6.4.0版本发布公告

Ant a-table data synchronization

5_数据分析—数据可视化

MKL and vs2019 configuration method
随机推荐
24 pictures to conquer border image
Exon bed file acquisition
[cloud resident co creation] database principle and application course of Huawei cloud database 11. Database system control
2022信息与未来预备刷题1《New Online Judge 1112: 平面分割》
Promise handles complex asynchrony
比SQL還好用,又一門國產數據庫語言誕生了
Mapbox 创建多个可拖动的标记点
SQL题集[(2)]
内存模型和名称空间知识点总结
【数据库第十二次作业-存储过程】
【软件测试系列九】《压力测试申请需提供事项说明》
Rose again. In April, the salary of programmers across the country was released, and it became the salary ceiling of the industry? I'm excited after reading it
Mieux que SQL, un autre langage de base de données domestique est né
7-2 符号配对|PTA
[pytorch] Monai vit network graphic analysis
信号与系统2022春季学期:作业内容与参考答案
SQL:树形三层职业分类表的SQL文件
-bash: /home/lylg/bin/kf.sh: /bin/bash^M: bad interpreter: No such file or directory
管道通信
Ant a-table data synchronization