<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>canvas动态绘制曲线</title>
</style>
</head>
<body>
<div class="wide-page-background">
<canvas id="tutorial" width="1600" height="1080"></canvas>
</div>
<script>
//单直线函数
function drawStraightLine(ctx, x, y, length, direct=0, step=1, sec=0, options={}) {
/**
* 动态绘制直线
* x,y 起点横纵坐标
* length 绘制长度
* step 步长 px
* direct 线条方向 0 水平 1 垂直
* sec 执行时间 秒
* options 配置项
* {
* lineColor 线条颜色
* lineWidth 线条宽度
* }
*/
// 设置线条样式
ctx.strokeStyle = options.lineColor ? options.lineColor : '#000'
ctx.lineWidth = options.lineWidth ? options.lineWidth : 1
ctx.beginPath()
// 计算绘制频率
let rate_sec = 5
if (sec) {
ra
canvas动态绘制曲线(类似与流动绘制任意曲线)
最新推荐文章于 2023-03-31 11:22:50 发布