首页 > 其他分享 >使用pb制作图片之间的过渡效果

使用pb制作图片之间的过渡效果

时间:2023-01-06 17:35:40浏览次数:37  
标签:false pb visible photo1 过渡 var import 制作 con


<languageVersion : 1.0;>

kernel PBJBlend
< namespace : "Your Namespace";
vendor : "Your Vendor";
version : 1;
>
{
input image4 src;
output pixel4 dst;
parameter float con
<
minValue:1.0;
maxValue:10.0;
defaultValue:1.0;
>;

void
evaluatePixel()
{
dst = sampleNearest(src,outCoord());
dst*=con;
}
}


上面为pbj文件代码,增加一个con变量。

package 
{
import com.greensock.TweenLite;
import com.greensock.easing.Expo;

import flash.display.MovieClip;
import flash.display.Shader;
import flash.events.Event;
import flash.filters.ShaderFilter;
import flash.utils.ByteArray;


public class TestPBJ extends MovieClip
{

[Embed("PBJBlend.pbj",mimeType = "application/octet-stream")]
private var pbj:Class;

private var who:MovieClip;
public var photo1:MovieClip;
public var photo2:MovieClip;

private var shader:Shader;
private var filter:ShaderFilter;
public var con:Number = 1.0;

public function TestPBJ()
{
init();
}


private function init():void
{
shader=new Shader(new pbj() as ByteArray);
filter = new ShaderFilter(shader);
who = photo1;
photo2.visible = false;
trans(null);

}

private function trans(e:Event=null):void
{

if (con==5)
{
if (photo1==who)
{

photo2.visible = true;
photo1.visible = false;
who = photo2;
}
else
{
photo1.visible = true;
photo2.visible = false;
who = photo1;
}
}

if (con==1)
{
TweenLite.to(this,1,{con:5,ease:Expo.easeIn,onUpdate:onChange,onComplete:trans});
}
else
{
TweenLite.to(this,1,{con:1,ease:Expo.easeOut,onUpdate:onChange,onComplete:trans});
}
}

protected function onChange(event:Event=null):void
{
shader.data.con.value = [con];
who.filters = [filter];

}

}
}



下面修改为四张图片的效果

package 
{
import com.greensock.TweenLite;
import com.greensock.easing.Expo;

import flash.display.MovieClip;
import flash.display.Shader;
import flash.events.Event;
import flash.filters.ShaderFilter;
import flash.utils.ByteArray;
import flash.display.Sprite;


public class TestPBJ extends Sprite
{

[Embed("PBJBlend.pbj",mimeType = "application/octet-stream")]
private var pbj:Class;

private var who:MovieClip;
public var photo1:MovieClip;
public var photo2:MovieClip;
public var photo3:MovieClip;
public var photo4:MovieClip;

private var shader:Shader;
private var filter:ShaderFilter;
public var con:Number = 1.0;

public function TestPBJ()
{
init();
}


private function init():void
{
shader=new Shader(new pbj() as ByteArray);
filter = new ShaderFilter(shader);
who = photo1;
photo2.visible = false;
photo3.visible = false;
photo4.visible = false;
trans(null);

}

private function trans(e:Event=null):void
{

if (con==5)
{
switch (who)
{
case photo1:
photo1.visible = false;
photo2.visible = true;
photo3.visible = false;
photo4.visible = false;
who = photo2;
break;
case photo2:
photo1.visible = false;
photo2.visible = false;
photo3.visible = true;
photo4.visible = false;
who = photo3;
break;
case photo3 :
photo1.visible = false;
photo2.visible = false;
photo3.visible = false;
photo4.visible = true;
who = photo4;
break;
case photo4:
photo1.visible = true;
photo2.visible = false;
photo3.visible = false;
photo4.visible = false;
who = photo1;
break;
default :
break;
}
}

if (con==1)
{
TweenLite.to(this,1,{con:5,ease:Expo.easeIn,onUpdate:onChange,onComplete:trans});
}
else
{
TweenLite.to(this,1,{con:1,ease:Expo.easeOut,onUpdate:onChange,onComplete:trans});
}
}

protected function onChange(event:Event=null):void
{
shader.data.con.value = [con];
who.filters = [filter];

}

}
}



标签:false,pb,visible,photo1,过渡,var,import,制作,con
From: https://blog.51cto.com/u_15932543/5994468

相关文章

  • g++ 动态库的制作和使用
    动态库的生成代码//animal.hpp#ifndef_ANIMAL_HPP#define_ANIMAL_HPPtypedefunsignedintuint;classanimal{private:uintm_number;uintm_si......
  • windows下gradle下使用windows版普罗米修斯prometheus和metrics简单的制作一个监控jav
    1.引入依赖(如果是maven可以自行翻译):例如:compile'io.prometheus:simpleclient_hotspot:0.5.0'groupid为io.prometheusartifactid为......
  • 如何在UE4中制作赛博朋克LED效果
    我们日常生活中常见的LED灯,如何在UE4中实现呢?其实实现起来非常简单,今天就带大家制作一个赛博朋克LED效果。一、基础LED形状制作正常LED的形状是由一个个小圆形组成,然后......
  • 基于Linux的Buildroot 制作根文件系统(rootfs)【转】
    参考:https://blog.csdn.net/qq_39721016/article/details/123876398 、https://www.jianshu.com/p/a461adda7a43仅供参考学习使用要构建自己的开发板,首先要创......
  • 网格制作圆柱
            usingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;usingUnityEngine.UI;publicclassYuanZhu:......
  • 网格制作方形
    usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;usingUnityEngine.UI;publicclassRectangular:Graphic//这个类加上后自动添加渲染......
  • 制作正方体
    usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;usingUnityEngine.UI;publicclassTheCube:MonoBehaviour{publicMeshFilterme......
  • 程序转制作人——游戏设计课程导论
    手机游戏中的社交互动与任务剧情一个游戏数值策划的自白:我所理解的数值工作《刀塔传奇》付费设计分析​​如何设计出令人惊叹的关卡:来自策划、美术与程序的标准​​......
  • Ventoy制作启动盘和使用VMware测试启动盘(论文版)
    -1Ventoy1.1 Ventoy是什么Ventoy是可用于制作启动U盘的开源工具,在占用少量引导分区容量后,其他空间依旧可以正常当一般的U盘读写文件。它的最大特点是只要将iso、win......
  • 圣诞树拼图游戏unity制作
    2022年圣诞节到来啦,很高兴这次我们又能一起度过~一、前言提示:使用unity来制作一个拼图游戏,图片便是圣诞树。二、创意名圣诞树拼图游戏三、效果展示圣诞树拼图游戏最终效果。......