直播平台搭建源码,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 ...
随机推荐
- (原创)【B4A】一步一步入门04:编译模式、打包为APK、私钥签名
一.前言 上篇 (原创)[B4A]一步一步入门03:APP名称.图标等信息修改 中我们将APP做成了标准的样子. 本篇文章会讲解如何将程序打包成APK文件以分发,同时讲解如何制作私钥并签名APP,以用 ...
- 分布式任务调度平台XXL-JOB安装
安装xxl-job-admin 1.拉取镜像 #拉取镜像 docker pull xuxueli/xxl-job-admin:2.3.0 #新建挂载目录 mkdir /usr/local/xxl-jo ...
- Oracle存储过程的创建实例和调用实例
--编写一个存储过程,给emp表中添加数据. --方法一:create or replace procedure add_employee( eno number, name ...
- LeetCode-429 N叉树的层次遍历
来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/n-ary-tree-level-order-traversal著作权归领扣网络所有.商业转载请联 ...
- 干货!超实用的 Linux 初始化脚本
咸鱼今天给大家分享一个无论是学习还是工作中都很实用的 Linux 系统初始化脚本,其实就是各种命令的集合 完整代码在文章最后哦 定义相关变量 配置 yum 镜像源 获取阿里云 yum 镜像源 判断 ...
- asp多模块功能代码,单调用插入的case方法
function getmodule(arg) select case arg case "pinyin" aaa="123" %><!--#插入页 ...
- Vue 非单文件组件(不常用)3步骤(创建、注册、使用)和几个注意点、组件的本质(VueComponent)
Vue中使用组件的三大步骤: 1.定义组件(创建) 2.注册组件 3.使用组件(写组件标签) 一.如何定义一个组件? 使用Vue.extend(options)创建,其中options 和 new V ...
- 01.JavaSE学习
一.java入门 java三大版本(write once,run anywhere) JavaSE:标准版(用于桌面开发,控制台开发) javaME:嵌入式开发(手机,小家电) javaEE:以jav ...
- 性能提升 40 倍!我们用 Rust 重写了自己的项目
前言 Rust 已经悄然成为了最受欢迎的编程语言之一.作为一门新兴底层系统语言,Rust 拥有着内存安全性机制.接近于 C/C++ 语言的性能优势.出色的开发者社区和体验出色的文档.工具链和IDE 等 ...
- MyCat2 读写分离
已经搭配好的主从数据库分别为:主:192.168.200.51:3306 从:mysql://192.168.200.53:3306 一. 登录数据客户端,创建逻辑库,配置数据源 create dat ...