直播平台搭建源码,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. 1.2.HBuilder软件与uniapp文件介绍

    uni-app官网地址 下载HBuilder 教程

  2. git操作出现 error: The following untracked working tree files would be overwritten by ...

    命令行:git clean -d -fx,作用是:删除没有git add 的文件 ,执行之后解决了 error: The following untracked working tree files ...

  3. UBUNTU18.04安装Pangolin

    https://github.com/stevenlovegrove/Pangolin

  4. 安卓逆向 IDA 动态调试 案例1

    adb forward tcp:23946 tcp:23946 adb devices adb shell su cd /data/local/tmp ./android_server adb she ...

  5. metasploit2-practice

    Metasploittable2打靶教程 本次靶机练习主要熟悉:高危端口利用:metasploit中search,show及各个模块使用. 一.环境准备 1.把靶场放在vmware打开,启用nat模式 ...

  6. JZOJ 2020.02.01【NOIP提高组】模拟A 组

    2020.02.01[NOIP提高组]模拟A 组 二月份第一场比赛 闲话 惨烈啊! 50+30+0=80分 一题都没A 唉 最高150? \(zzh\) 暴虐A组 总结: 若干新东西 \(T1\) 我 ...

  7. php pdo如何查询记录条数

    转载php中文网:https://www.php.cn/php-ask-457710.html php pdo查询记录条数的方法:1.使用fetchAll函数查询,其语法如"$rows=$q ...

  8. 基于JavaScript的OpenGL 01 之Hello Triangle

    1. 引言 本文基于JavaScript语言,描述OpenGL(即,WebGL)的绘制流程,这里描述的是OpenGL的核心模式(Core-profile) 笔者这里不过多描述每个名词.函数和细节,更详 ...

  9. 一文搞懂│http 和 https 的通信过程及区别

    目录 两者的区别 HTTP的通信过程 HTTPS的通信过程 两者的区别 端口: http 端口号是80,https 端口号是443 传输协议: http 是超文本传输协议,属于明文传输:https 是 ...

  10. LeetCode-475 供暖器

    来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/heaters 题目描述 冬季已经来临. 你的任务是设计一个有固定加热半径的供暖器向所有房屋供暖. ...