我怎样才能将图片转换为另一张图片

时间:2018-02-04 16:11:04

标签: javascript

在javascript中;

function doSingle() {
var luck = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
    imagesArray = ['th/sr/1.png', 'th/sr/2.png', 'th/sr/3.png'];
  var ssrArray = ['th/ssr/1.png', 'th/ssr/2.png', 'th/ssr/3.png']; 
  lucknumber = Math.floor((Math.random() * luck.length));

  if (lucknumber < 8) { 
    //HERE IS WHERE I WANT THE FADE :)
    function displayImage() {
      var num = Math.floor(Math.random() * ssrArray.length);
      window.canvas.src = ssrArray[num];
    }

    displayImage();
  } else {
    //HERE IS WHERE I WANT THE FADE :)
    function displayImage() {
      var num = Math.floor(Math.random() * imagesArray.length);
      window.canvas.src = imagesArray[num];
    };

    displayImage();
  }
} 

在哪里可以看到HERE IS WERE I WANT THE FADE :),有没有办法让它显示2秒的图片,然后淡入随机图片?感谢

1 个答案:

答案 0 :(得分:2)

最简单的方法是使用jQuery:

["This is a test\nIncluding ",["bo","bold"],["ld",["italic","bold"]],[", ","italic"],["u",["underline","italic"]],["nderlined","underline"],", ",["strike-through","strike"],", and ",["italic","italic"],"\ntext:\n\n",["numbered lists",["underline","strike","italic","bold"]],["\n",[]],"as well as",["\n",[]],["non ordered lists","http:\/\/test.com"],["\n",[]],"it works very well",["\n",[]],["try it","http:\/\/google.com"],"\n",["http:\/\/google.com",["bold","http:\/\/google.com"]],"\n\n",["wow","bold"],"\n",["lol","bold"]]