JavaFX学习之Effect
Effect 抽象类,所有特殊效果的父类。
Blending 混合效果影响 对node设置blending有二种
node.setBlendMode(BlendMode arg0); //这只是简单的设置用哪种混合效果模式
Blend blend = new Blend(); //这里可以设置更多的混合效果
blend.setMode(BlendMode.COLOR_BURN);
node.setEffect(Effect value)
Blend的属性 bottomInput,topInput 复合效果处理,设置接下来的效果。 也就说可以对一个node设置多个effect。 Blend没有setInput(Effect effect)方法,因为它涉及二块区域,重叠的部分有上下之分,所以就分为了setBottomInput(Effect value)和setTopInput(Effect value) mode 采用哪种混合模式,可以看枚举类BlendMode opacity 透明度
Bloom 明亮效果,是效果更加明亮
Bloom bloom = new Bloom();
bloom.setThreshold(1.0); //通过此值,改变明亮效果,值从0到1。默认为0.3
node.setEffect(bloom);
属性 threshold 改变明亮效果 input 复合效果处理,设置接下来的效果
Blur 模糊效果
BoxBlur bb = new BoxBlur();
bb.setWidth(5);
bb.setHeight(5);
bb.setIterations(3);
node.setEffect(bb);
属性: height,width BoxBlur模糊效果是往上下左右扩展,所以这里就需要设置,效果展示的宽度和高度。 input 复合效果处理,设置接下来的效果 iterations 值越大效果越模糊,没明白意思 Min: 0 Max: 3 Default: 1 Identity: 0
MotionBlur mb = new MotionBlur();
mb.setRadius(15.0f);
mb.setAngle(45.0f);
node.setEffect(mb);
属性: angle radius Min: 0.0 Max: 63.0 Default: 10.0 Identity: 0.0 input
**DropShadow **阴影效果
DropShadow ds = new DropShadow();
ds.setOffsetY(3.0);
ds.setOffsetX(3.0);
ds.setColor(Color.GRAY);
node.setEffect(ds);
属性: offsetX,offsetY 设置阴影的偏移位置 blurType 设置阴影的模糊类型 color 设置阴影的颜色 spread 阴影传播 Min: 0.0 Max: 1.0 Default: 0.0 Identity: 0.0 height,width 阴影模糊核心的宽高 input
**InnerShadow ** 内部阴影效果
InnerShadow is = new InnerShadow();
is.setOffsetX(2.0f);
is.setOffsetY(2.0f);
node.setEffect(is);
属性: choke 外部阴影是用的spread input
Reflection 反射效果
Reflection r = new Reflection();
r.setFraction(0.9);
node.setEffect(r);
属性: bottomOpacity,topOpacity 反射部分被分成了二半上和下,所以这里有设置下和上的透明度,可以看到默认的反射部分,下部分的透明度和上的不同,那时因为默认值不同,下部分的是0,上部分的是0.5. fraction 反射显示的比率 topOffset 反射部分距离本体的距离 input
Lighting 灯光效果
Distant light = new Distant();
light.setAzimuth(-135.0f);
Lighting l = new Lighting();
l.setLight(light);
l.setSurfaceScale(5.0f);
node.setEffect(l);
属性: bumpInput , contentInput diffuseConstant light light有Light.Distant, Light.Point specularConstant specularExponent surfaceScale 表面的比率因子,效果是更亮,感觉是密度大了, 不明白其意思
PerspectiveTransform 远景效果
PerspectiveTransform pt = new PerspectiveTransform();
pt.setUlx(10.0f);
pt.setUly(10.0f);
pt.setUrx(210.0f);
pt.setUry(40.0f);
pt.setLrx(210.0f);
pt.setLry(60.0f);
pt.setLlx(10.0f);
pt.setLly(90.0f);
node.setEffect(pt);
属性: Ulx,Uly,Urx,Ury,Lrx,Lry,Llx,Lly //设置4个点位置,上左,上右,下右,下左 input
ColorAdjust 颜色效果调节
colorAdjust = new ColorAdjust();
colorAdjust.setContrast(0.1);
colorAdjust.setHue(-0.05);
colorAdjust.setBrightness(0.1);
colorAdjust.setSaturation(0.2);
node.setEffect(colorAdjust);
属性: Contrast 对比 Hue 色彩 Brightness 明亮度 Saturation 饱和度 input
DisplacementMap 根据指定距离移动每一像素
Glow 发热效果,一般都是设置图片的效果
imageView.setEffect(new Glow(0.8)); //发热效果
属性: Level 通过设置改属性调节效果 Min: 0.0 Max: 1.0 Default: 0.3 Identity: 0.0 input
SepiaTone 棕褐色调,一般都是设置图片的效果
SepiaTone sepiaTone = new SepiaTone(); //棕褐色调,加在图片上后,感觉很古老
sepiaTone.setLevel(0.7);
imageView.setEffect(sepiaTone);
属性: Level 通过设置改属性调节效果 Min: 0.0 Max: 1.0 Default: 0.3 Identity: 0.0 input
ColorInput 一个矩形加颜色渲染。 不明白这个的用处
ColorInput colorInput = new ColorInput();
colorInput.setPaint(Color.STEELBLUE);
colorInput.setX(10);
colorInput.setY(10);
colorInput.setWidth(100);
colorInput.setHeight(180);
属性: x,y坐标 width,height 宽高 paint 渲染的颜色
ImageInput 一个图片加颜色渲染 属性 x,y位置 source 源图片
在一个node中,同时加几个效果
setInput(Effect effect); //大部分effect都有setInput方法,设置接下来的效果影响
求评论,求解答,都是自己理解,可能错了,有些也不知道。