| 百度

html5用canvas实现图片自动切换酷炫屌炸天

  html5用canvas实现图片自动切换酷炫屌炸天,想使html5更加活色生香canvas的炫酷爆炸特效飞散需要使用到js插件。达到的效果是这样:使用鼠标点击图片时,图片就会发生被子弹击穿的特效效果出来,那是相当炫酷。
  //移动图片
  context.drawImage(currentImage.imgObj,currentImage.x,currentImage.y,width,height);
  context.drawImage(currentImage.preImage.imgObj,currentImage.preImage.x,currentImage.preImage.y,width,height);
  context.drawImage(currentImage.nextImage.imgObj,currentImage.nextImage.x,currentImage.nextImage.y,width,height);
  context.fillStyle="rgba(100,150,185,0.5)";
  context.fillRect(0,0,100,height);
  context.fillRect(400,0,100,height);
  interval = setTimeout("intervalSlide()", 20);
  }
  );
  function drawFrame(){
  context.clearRect(0,0,canvas.width,canvas.height);
  //调用beginPath()确保不会接着上次绘制的图形绘制
  context.beginPath();
  context.drawImage(currentImage.imgObj,currentImage.x,currentImage.y,width,height);
  context.drawImage(currentImage.preImage.imgObj,currentImage.preImage.x,currentImage.preImage.y,width,height);
  context.drawImage(currentImage.nextImage.imgObj,currentImage.nextImage.x,currentImage.nextImage.y,width,height);
  context.drawImage(currentImage.preImage.preImage.imgObj,currentImage.preImage.preImage.x,currentImage.preImage.preImage.y,width,height);
  //遮罩
  context.fillStyle="rgba(100,150,185,0.5)";
  context.fillRect(0,0,100,height);
  context.fillRect(400,0,100,height);
  //每一帧的位置变动
  currentImage.x -= speed;
  currentImage.preImage.x -= speed;
  currentImage.nextImage.x -= speed;
  currentImage.preImage.preImage.x -= speed;
  if(currentImage.x == 200){
  currentImage.nextImage.x = 500;
  }
  //到达指定位置停止变动
  if(currentImage.x != stopX){
  autoTimeout = setTimeout("drawFrame()",timeoutInterval);
  }
  else{
  }
  }
  在这里关于怎么设置css,就没有详细的给您描述了。如果遇到不清楚或者不能处理的,请点击在线咨询告诉我们,我们会在第一时间给您全面的解释。成都点点通科技有限公司等您哦!

百度