zoukankan      html  css  js  c++  java
  • vue实现3D词云

    1:定义数组存放展示的文字 

     2:页面

    补充:调节旋转方向<div class="wordCloud__home">

          <el-button type="danger" @click="handleSpeed('slow')">降低速度</el-button>
          <el-button type="primary" @click="handleRotate('-1')">横向顺时针</el-button>
          <el-button type="primary" @click="handleRotate('1')">横向逆时针</el-button>
          <el-button type="primary" @click="handleRotate('-2')">纵向顺时针</el-button>
          <el-button type="primary" @click="handleRotate('2')">纵向逆时针</el-button>
          <el-button type="danger" @click="handleSpeed('fast')">增加速度</el-button>
        </div>

     3:

     4:

     5:   rotateY () {

          const angleY = ['-2''2'].includes(this.direction)
            ? Math.PI / Infinity
            : Math.PI / (Number(this.direction) * Number(this.speed))
          const cos = Math.cos(angleY)
          const sin = Math.sin(angleY)
          this.contentEle = this.contentEle.map(t => {
            const x1 = t.x * cos - t.z * sin
            const z1 = t.z * cos + t.x * sin
            return {
              ...t,
              x: x1,
              z: z1
            }
          })
        },
        move () {
          const CX = this.width / 2
          const CY = this.height / 2
          this.contentEle = this.contentEle.map(singleEle => {
            const { xyz } = singleEle
            const fallLength = 500
            const RADIUS = (this.width - 50) / 2
            const scale = fallLength / (fallLength - z)
            const alpha = (z + RADIUS) / (2 * RADIUS)
            const left = `${x + CX - 15}px`
            const top = `${y + CY - 15}px`
            const transform = `translate(${left}${top}) scale(${scale})`
            const style = {
              ...singleEle.style,
              opacity: alpha + 0.5,
              zIndex: parseInt(scale * 10010),
              transform
            }
            return {
              x,
              y,
              z,
              style
            }
          })
        },
        handleRotate (value) {
          this.direction = value
        },
        handleSpeed (value) {
          const speedObj = {
            fast: -50,
            slow: 50
          }
          this.speed += speedObj[value]
          if (this.speed === 0) {
            this.speed = 50
          }
        }

     6:css

     .tagBall {
      margin50px auto;
      positionrelative;
      backgroundurl('./image1.png');
      background-positioncenter;
      background-repeatno-repeat;
      background-sizecontain;
    }

    .wordCloud__tag {
      displayblock;
      positionabsolute;
      left0px;
      top0px;
      colorgreen;
      text-decorationnone;
      font-size14px;
      font-family'微软雅黑';
      font-weightbold;

    }

    .wordCloud__home {
      displayflex;
      justify-contentcenter;
    }
    contentEle
  • 相关阅读:
    如何在CentOS系统中安装字体 51CTO.COM
    C++检查输入数据类型? 知乎
    义乌市爱因宝母婴用品有限公司_公司简介
    硬盘对拷必备 AGE USB/eSATA对拷机现卖场!_青岛行情中关村在线
    Download: Microsoft SQL Server Management Studio Express Microsoft Download Center Download Details
    今晚看啥
    nano接收器
    12306订票助手 (版本 3.5.0)
    Microsoft® SQL Server® 2008 Management Studio Express
    有线键盘和鼠标确实应该退出历史舞台了
  • 原文地址:https://www.cnblogs.com/binglove/p/13360797.html
Copyright © 2011-2022 走看看