首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将lottie动画渲染到画布对象

如何将lottie动画渲染到画布对象
EN

Stack Overflow用户
提问于 2020-03-09 23:00:48
回答 1查看 2.3K关注 0票数 0

我正在尝试使用vue-lottie来拍摄一个后效动画,并将其渲染到画布上。动画运行良好,但无论我做什么,我都不能让它渲染到画布上。它似乎只呈现了一个svg。我需要一种方法来渲染动画到画布,我不关心我怎么做。如果我需要转换库,那很好,我只需要一种在画布对象上获得动画的方法。这里的任何帮助都将不胜感激。下面是代码

代码语言:javascript
复制
<template>
  <div>
    <lottie
      :options="defaultOptions"
      :heigh="1920"
      :width="1080"
      v-on:animCreated="handleAnimation"
    />
    <div id="container"></div>
  </div>
</template>

<script>
import * as animationData from "../data.json";
var text1 = "I hate sand";
var text2 = "dope";
var text3 = "nope";
var text4 = "haha";
var text5 = "n";
animationData.layers[0].t.d.k[0].s.t = text1;
animationData.layers[1].t.d.k[0].s.t = text2;
animationData.layers[2].t.d.k[0].s.t = text3;
animationData.layers[3].t.d.k[0].s.t = text4;
animationData.layers[4].t.d.k[0].s.t = text5;
console.log(animationData);
export default {
  data() {
    return {
      defaultOptions: {
        animationData: animationData.default,
        container: "container",
        renderer: "canvas"
      },
      animationSpeed: 1
    };
  },
  methods: {
    handleAnimation: function(anim) {
      this.anim = anim;
    },

    stop: function() {
      this.anim.stop();
    },

    play: function() {
      this.anim.play();
    },

    pause: function() {
      this.anim.pause();
    },

    onSpeedChange: function() {
      this.anim.setSpeed(this.animationSpeed);
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
.hello {
  background-color: black !important;
}
</style>
EN

回答 1

Stack Overflow用户

发布于 2020-09-01 22:07:26

我不完全确定,但我认为问题一定来自动画,这是因为画布渲染器不支持蒙版。我目前正面临着类似的情况。

点击here阅读更多信息。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60603220

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档