直播平台搭建源码,canvas 画一条波浪线 进度条
直播平台搭建源码,canvas 画一条波浪线 进度条
<template>
<view>
<canvas :style="{'width': width + 'rpx','height': height + 'rpx','backgroundColor': '#d2d8d2'}"
canvas-id="firstCanvas" id="firstCanvas"></canvas>
</view>
</template>
<script>
export default {
data() {
return {
ctx: null,
width: 600,
height: 400,
step: 2,
stepHeight: -60,
trigger: true
}
},
mounted() {
this.ctx = uni.createCanvasContext('firstCanvas', this)
//this.drawWave()
//this.drawWave()
this.moveWave()
},
computed: {
canvasWidth() {
return uni.upx2px(this.width)
},
canvasHeight() {
return uni.upx2px(this.height)
},
stepWave() {
return uni.upx2px(this.canvasWidth) / this.step
},
stepWaveHeight() {
return uni.upx2px(this.stepHeight)
},
canvasCenter() {
return {
x: this.canvasWidth / 2,
y: this.canvasHeight / 2
}
}
},
methods: {
//计算位移 波浪高度的值
moveWave() {
let offset = -this.stepWave * 2
setInterval(() => {
offset++
if (offset >= 0) {
offset = -this.stepWave * 2
}
if (this.stepHeight > -10) {
this.trigger = true
}
if (this.stepHeight < -50) {
this.trigger = false
}
if (this.trigger) {
this.stepHeight -= 0.2
} else {
this.stepHeight += 0.2
}
this.drawWave(offset)
}, 10)
},
drawWave(offset) {
// 遮罩开始
this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight);
this.ctx.save();
this.ctx.beginPath();
this.ctx.fillStyle = '#d5ffc5'
this.ctx.arc(this.canvasCenter.x, this.canvasCenter.y, 100, 0, Math.PI * 2, false);
this.ctx.closePath();
this.ctx.fill();
// this.ctx.setStrokeStyle("#d5ffc5")
// this.ctx.stroke();
this.ctx.clip();
//this.ctx.restore()
// 遮罩结束
this.ctx.beginPath()
//线条起点
this.ctx.moveTo(0 + offset, this.canvasCenter.y); //宽高
// this.ctx.setStrokeStyle("#002ae6") //颜色
this.ctx.setLineWidth(1)
for (let i = 0; i < this.step * 3; i++) {
if (i % 2 == 0) {
this.ctx.quadraticCurveTo(this.stepWave * (i) + this.stepWave / 2 + offset, this.canvasCenter.y + this
.stepWaveHeight, this.stepWave * (i + 1) + offset, this.canvasCenter.y)
} else {
this.ctx.quadraticCurveTo(this.stepWave * (i) + this.stepWave / 2 + offset, this.canvasCenter.y - this
.stepWaveHeight, this.stepWave * (i + 1) + offset, this.canvasCenter.y)
}
}
this.ctx.lineTo(this.stepWave * (this.step * 2 + 3) + offset, this.canvasHeight)
this.ctx.lineTo(0 + offset, this.canvasHeight)
this.ctx.closePath()
let grad = this.ctx.createLinearGradient(0, 0, 0, this.canvasHeight);
grad.addColorStop(0, '#1e92ea')
grad.addColorStop(1, '#2C405A')
// this.ctx.setFillStyle('#3cee06')
this.ctx.setFillStyle(grad)
this.ctx.fill()
this.ctx.restore();
//this.ctx.strokeStyle = "red"
//this.ctx.stroke()
this.ctx.draw()
},
}
}
</script>
<style scoped>
.canvas-view {}
</style>
以上就是 直播平台搭建源码,canvas 画一条波浪线 进度条,更多内容欢迎关注之后的文章
直播平台搭建源码,canvas 画一条波浪线 进度条的更多相关文章
- WEB前端开发学习:源码canvas 雪
WEB前端开发学习:源码canvas 雪 双旦节要到了,程序员们为了响应气氛,特别用代码制作了动态雪花,WEB前端开发学习的初学者们一起跟着案例做一遍吧! <!DOCTYPE html> ...
- Linux平台下源码安装mysql多实例数据库
Linux平台下源码安装mysql多实例数据库[root@linux-node1 ~]# netstat -tlunp | grep 330tcp6 0 0 :::3306 :::* LISTEN 6 ...
- Hadoop学习笔记(10) ——搭建源码学习环境
Hadoop学习笔记(10) ——搭建源码学习环境 上一章中,我们对整个hadoop的目录及源码目录有了一个初步的了解,接下来计划深入学习一下这头神象作品了.但是看代码用什么,难不成gedit?,单步 ...
- Android8.1 MTK平台 SystemUI源码分析之 网络信号栏显示刷新
SystemUI系列文章 Android8.1 MTK平台 SystemUI源码分析之 Notification流程 Android8.1 MTK平台 SystemUI源码分析之 电池时钟刷新 And ...
- 【Java】用IDEA搭建源码阅读环境
用IDEA搭建源码阅读环境 参考自CodeSheep的Mac源码环境搭建, https://www.bilibili.com/video/BV1V7411U78L 但是实际上在Windows搭建的差别 ...
- 部署zabbix监控平台(源码安装)
案例:部署Zabbix监控平台 1 问题 本案例要求部署一台Zabbix监控服务器,一台被监控主机,为进一步执行具体的监控任务做准备: 安装LNMP环境 源码安装Zabbix 安装监控端主机,修改基本 ...
- Android 音视频深入 十六 FFmpeg 推流手机摄像头,实现直播 (附源码下载)
源码地址https://github.com/979451341/RtmpCamera/tree/master 配置RMTP服务器,虽然之前说了,这里就直接粘贴过来吧 1.配置RTMP服务器 这个我不 ...
- LNMP搭建 源码包
LNMP源码包搭建 linux CentOS-6.5-x86_64-bin-DVD1 nginx 版本1.8.0 下载地址:http://nginx.org/en/download.htm ...
- Windows平台下源码分析工具
最近这段时间在阅读 RTKLIB的源代码,目前是将 pntpos.c文件的部分看完了,准备写一份文档记录下这些代码的用处.处理过程.理论公式来源.注意事项,自己还没有弄明白的地方.目前的想法是把每一个 ...
- Netty环境搭建 (源码死磕2)
[正文]netty源码 死磕2: 环境搭建 本小节目录 1. Netty为什么火得屌炸天? 1.1. Netty是什么? 1.2. Netty火到什么程度呢? 1.3. Netty为什么这么火? 2 ...
随机推荐
- rt-thread模糊到清晰系列: ipc.c
#include <rtthread.h> #include <rthw.h> #ifdef RT_USING_HOOK extern void (*rt_object_try ...
- Hugging Face 每周速递: 扩散模型课程完成中文翻译,有个据说可以教 ChatGPT 看图的模型开源了
每一周,我们的同事都会向社区的成员们发布一些关于 Hugging Face 相关的更新,包括我们的产品和平台更新.社区活动.学习资源和内容更新.开源库和模型更新等,我们将其称之为「Hugging Ne ...
- 什么是MES(Manufacturing Execution System)
"本文仅代表个人观点" 本文档将提供一个高层次的概述,以帮助阐明什么是MES,并触及通常被归为MES的周边领域. 整体情况 制造执行系统或MES软件是旨在帮助公司管理其制造过程的工 ...
- JZOJ 2114. 【GDKOI2011】反恐任务
\(\text{Problem}\) 给定一张无向图,\(q\) 次询问,删去一个点或一条相邻两点间的边,问两点是否连通 询问独立 \(\text{Solution}\) 明显的用圆方树把图变成树 然 ...
- select去除默认样式
select { /*Chrome同Firefox与IE里面的右侧三角显示的样式不同*/ border: solid 1px #ddd; /*将默认的select选择框样式清除*/ appearanc ...
- PostgreSQL中的row_number() 与distinct用法说明
一.示例 这两个SQL执行所得到的数据是一样的! select count(s.*) from ( select *, row_number() over (partition by fee_dat ...
- Ansible介绍以及基于角色搭建LNMP和zabbix
1 ansible 常用指令总结,并附有相关示例. /usr/bin/ansible 主程序,临时命令执行工具 /usr/bin/ansible-doc 查看配置文档,模块功能查看工具,相当于man ...
- html(Angular) 调用本地安装exe程序
1.写注册表 新建 .reg文件 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\creoparametric] "URL P ...
- js高德地图添加点Marker,添加线段Polyline,添加一个区域Polygon(面)
高德地图JS API 实例 亲测可用 参考网站=> 阿里云数据可视化平台(下载json用的):http://datav.aliyun.com/portal/school/atlas/area_ ...
- Django中models的字段
常见的field类型: 1.AutoField 自增字段,它是一个根据ID自增长的IntegerField字段,通常不用自己设置,如果没有设置主键,django会自动添加它为主键字段 2.CharFi ...