【问题标题】:Is there a way to control which frame an APNG starts from using javascript?有没有办法使用 javascript 控制 APNG 从哪个帧开始?
【发布时间】:2020-03-06 07:44:59
【问题描述】:

我正在尝试在鼠标悬停时播放 APNG,然后在鼠标悬停时获取 APNG 所在的帧,然后使用该帧播放反转的 APNG,以便平滑过渡。我试着四处寻找,但真的找不到太多。

基本上我想做这样的事情:

<img src="regular_png.png" id="apng">
document.getElementById("apng").onmouseover = function() {
  this.src = "apng1.png";
}
document.getElementById("apng").onmouseout = function() {
  // Get the current frame the apng is on
  this.src = "apng2.png";
  // Start apng2.png from total # of frames - current frame from apng1.png
}

【问题讨论】:

    标签: javascript html apng


    【解决方案1】:

    您可以将 APNG 转换为 PNG[],其中的元素通过 canvas.drawImage(...) 顺序显示(计数器),并由 canvas.onmouseover 和 canvas.onmouseout 介导。

    【讨论】:

      猜你喜欢
      • 2010-12-25
      • 1970-01-01
      • 1970-01-01
      • 2016-12-19
      • 2016-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-05
      相关资源
      最近更新 更多