AS3的代码绘制滤镜,AS3中包含下面滤镜,
Drop Shadow --投影滤镜
Blur --模糊滤镜
Glow --发光滤镜
Bevel --斜角滤镜
Gradient bevel --渐变斜角滤镜
Gradient glow --渐变发光滤镜
Color matrix --颜色矩阵滤镜
Convolution --卷积滤镜
Displacement map--转换图滤镜
关于Blur的使用情况
var blur:BlurFilter=new BlurFilter(5,5,3);
var filters:Array=new Array();
filters.push(blur);
sprite.filters=filters;
关于Gradient bevel的使用情况
import flash.display.*;
import flash.geom.*;
var fType:String = GradientType.LINEAR;//用指定线性渐变填充的值
var colors:Array = [ 0xF1F1F1, 0x666666 ];
var alphas:Array = [ 1, 1 ];
var ratios:Array = [ 0, 255 ];
var matr:Matrix = new Matrix();
matr.createGradientBox( 200, 20, 0, 0, 0 );
var sprMethod:String = SpreadMethod.PAD;
var sprite:Sprite = new Sprite();
var g:Graphics = sprite.graphics;
g.beginGradientFill( fType, colors, alphas, ratios, matr, sprMethod );
g.drawRect( 0, 0, 400, 200 );
addChild( sprite );
关于使用DropShadowFilter制作投影
var color:Number = 0x000000;//投影的颜色
var angle:Number = 45;//投影的角度
var alpha:Number = 0.8;//投影的透明度
var blurX:Number = 8;//水平模糊量,0不模糊
var blurY:Number = 8;//垂直模糊量,0不模糊
var distance:Number = 15;//投影的距离
var strength:Number = 1;//强度
var inner:Boolean = false;//是不是内嵌
var knockout:Boolean = false;
var quality:Number = BitmapFilterQuality.HIGH;
var filter:DropShadowFilter=new DropShadowFilter(distance,
angle,color,alpha,blurX,blurY,
strength,quality,inner,knockout);
sprite.filters=[filter];
我的网站设计 web design home page
http://www.webdesign-cn.com
http://www.webdesign-china.cn