直播平台搭建源码,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 画一条波浪线 进度条的更多相关文章

  1. WEB前端开发学习:源码canvas 雪

    WEB前端开发学习:源码canvas 雪 双旦节要到了,程序员们为了响应气氛,特别用代码制作了动态雪花,WEB前端开发学习的初学者们一起跟着案例做一遍吧! <!DOCTYPE html> ...

  2. Linux平台下源码安装mysql多实例数据库

    Linux平台下源码安装mysql多实例数据库[root@linux-node1 ~]# netstat -tlunp | grep 330tcp6 0 0 :::3306 :::* LISTEN 6 ...

  3. Hadoop学习笔记(10) ——搭建源码学习环境

    Hadoop学习笔记(10) ——搭建源码学习环境 上一章中,我们对整个hadoop的目录及源码目录有了一个初步的了解,接下来计划深入学习一下这头神象作品了.但是看代码用什么,难不成gedit?,单步 ...

  4. Android8.1 MTK平台 SystemUI源码分析之 网络信号栏显示刷新

    SystemUI系列文章 Android8.1 MTK平台 SystemUI源码分析之 Notification流程 Android8.1 MTK平台 SystemUI源码分析之 电池时钟刷新 And ...

  5. 【Java】用IDEA搭建源码阅读环境

    用IDEA搭建源码阅读环境 参考自CodeSheep的Mac源码环境搭建, https://www.bilibili.com/video/BV1V7411U78L 但是实际上在Windows搭建的差别 ...

  6. 部署zabbix监控平台(源码安装)

    案例:部署Zabbix监控平台 1 问题 本案例要求部署一台Zabbix监控服务器,一台被监控主机,为进一步执行具体的监控任务做准备: 安装LNMP环境 源码安装Zabbix 安装监控端主机,修改基本 ...

  7. Android 音视频深入 十六 FFmpeg 推流手机摄像头,实现直播 (附源码下载)

    源码地址https://github.com/979451341/RtmpCamera/tree/master 配置RMTP服务器,虽然之前说了,这里就直接粘贴过来吧 1.配置RTMP服务器 这个我不 ...

  8. LNMP搭建 源码包

    LNMP源码包搭建 linux    CentOS-6.5-x86_64-bin-DVD1 nginx   版本1.8.0  下载地址:http://nginx.org/en/download.htm ...

  9. Windows平台下源码分析工具

    最近这段时间在阅读 RTKLIB的源代码,目前是将 pntpos.c文件的部分看完了,准备写一份文档记录下这些代码的用处.处理过程.理论公式来源.注意事项,自己还没有弄明白的地方.目前的想法是把每一个 ...

  10. Netty环境搭建 (源码死磕2)

    [正文]netty源码  死磕2: 环境搭建 本小节目录 1. Netty为什么火得屌炸天? 1.1. Netty是什么? 1.2. Netty火到什么程度呢? 1.3. Netty为什么这么火? 2 ...

随机推荐

  1. mybatis学习日记2

    1.mybatis中的连接池 配置的位置:  主配置文件SqlMapConfig.xml中的dataSource标签,type属性就是用来表示采用何种连接方式 mybatis连接池提供了3种方式的配置 ...

  2. nodejs 环境变量配置

    1.下载 下载地址: https://nodejs.org/zh-cn/download/ 2.安装 安装一直下一步即可,建议安装路径不要包含中文 3.环境变量配置 1)右键[我的电脑],点击[属性] ...

  3. .net core 阿里云接口之拷贝文件

    紧接上文, 1).net core 阿里云接口之获取临时访问凭证_SunshineGGB的博客-CSDN博客 2).net core 阿里云接口之将指定的OSS文件下载到流_SunshineGGB的博 ...

  4. Eureka+SpringCloud微服务(入门一)

    项目地址 [CloudStudy项目](zko0/cloudStudy: Springcloud学习工程 (github.com)) 1.依赖版本 cloud:Hoxton.SR1 boot:2.2. ...

  5. Docker中Mysql容器忘记密码的处理方法

    今天非常的倒霉,因为学习了Vue的相关知识,想自己写一个后端服务器来练习一下Vue 然后 忘记了Docker中Mysql的密码... 很抽象 下面是我的解决方法 一.如果在本地的Navicat Pre ...

  6. JZOJ 3566. 【GDKOI2014】阶乘

    题目 求十进制 \(n!\) 在 \(m\) 进制下末尾 \(0\) 的个数 分析 签到题 只要看 \(n!\) 有多少个 \(m\) 的倍数就好了 考虑分解 \(m\) 的质因子 然后根号计算每个因 ...

  7. Cobalt Strike 之:会话管理

    郑重声明: 本笔记编写目的只用于安全知识提升,并与更多人共享安全知识,切勿使用笔记中的技术进行违法活动,利用笔记中的技术造成的后果与作者本人无关.倡导维护网络安全人人有责,共同维护网络文明和谐. Co ...

  8. CCRD_TOC_2008年第1期

    中信国健临床通讯 2008年第1期 目 录   类风湿关节炎 1 一种新型.实用的RA活动度评估方法:完成评估只需三分钟 Fleischmann RM, Schiff MH, Keystone EC, ...

  9. 在vs code中进行本地调试和开启本地服务器

    https://blog.csdn.net/tangxiujiang/article/details/80927699

  10. 支持管道、重定向、*匹配的miniShell

    先上成果图 源代码 仅供技术点的分享,抄袭者就算了,所以main.c就不贴了 /* * split_line.c */ #include <stdio.h> #include <st ...