JavaFX中effect包中Blend类简单使用

JavaFX中effect包中Blend类简单使用   

 

在JavaFX的类库中提供了许多特殊效果。在RIA应用它,可以具有更好的视觉。今天,我看看Blend类的使用。混合效果示例效果如图:

 

  1. /*
  2.  * Main.fx
  3.  *
  4.  * Created on Dec 29, 2008, 9:50:06 PM
  5.  */
  6. package effects;
  7. import javafx.scene.*;
  8. import javafx.scene.effect.Blend;
  9. import javafx.scene.effect.BlendMode;
  10. import javafx.scene.effect.Flood;
  11. import javafx.scene.paint.Color;
  12. import javafx.scene.paint.CycleMethod;
  13. import javafx.scene.paint.LinearGradient;
  14. import javafx.scene.paint.Stop;
  15. import javafx.scene.shape.Rectangle;
  16. import javafx.scene.text.Font;
  17. import javafx.scene.text.FontPosture;
  18. import javafx.scene.text.FontWeight;
  19. import javafx.scene.text.Text;
  20. import javafx.stage.Stage;
  21. /**
  22.  * @author Administrator
  23.  */
  24. var x:Integer=0;
  25. Stage {
  26.     title: "Application title"
  27.     width: 350
  28.     height: 150
  29.     scene: Scene {
  30.         content:[
  31.             Group{
  32.                 content:[
  33.                     for(x in [0..4])  {
  34.                     
  35.                         Rectangle {
  36.                             y: indexof x * 20
  37.                             width: 100
  38.                             height: 10
  39.                             fill: LinearGradient {
  40.                                 startX: 0.0
  41.                                 startY: 0.0
  42.                                 endX: 0.25
  43.                                 endY: 0.25
  44.                                 cycleMethod: CycleMethod.REFLECT
  45.                                 stops: [
  46.                                     Stop {
  47.                                         offset: 0.0
  48.                                     color: Color.RED },
  49.                                     Stop {
  50.                                         offset: 1.0
  51.                                     color: Color.YELLOW }
  52.                                 ]
  53.                             }
  54.                         }
  55.                     }
  56.                     Text {
  57.                         effect: Blend {
  58.                             mode: BlendMode.SRC_OUT
  59.                             topInput: Flood {
  60.                                 paint: Color.BLUE
  61.                                 x: 10
  62.                                 y: 10
  63.                                 width: 160
  64.                                 height: 80
  65.                             }
  66.                         }
  67.                         translateX:100;
  68.                         x: 25
  69.                         y: 65
  70.                         content: "SrcOut"
  71.                         fill: Color.BLUE
  72.                         font: Font.font(null, FontWeight.BOLD, FontPosture.ITALIC, 36);
  73.                     }
  74.                 ]
  75.             }
  76.         ]
  77.     }
  78. }

在Retangle使用了LinerGradient效果,并且有五个长方形。而“SrcOut”使用Blend效果。

其中Blend类的主要属性有:

topInput:顶端输入;

bottomInput:末端输入;

mode:模式;

opacity:不透明度;

主要是把两种输入的颜色按一定的模式混合在一起。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值