JavaFx Effect 之 Dropshadow 介绍使用
JavaFx Effect 之 Dropshadow
DropShadow Oracle 官网解释
A high-level effect that renders a shadow of the given content behind the content with the specified color, radius, and offset.
以指定的颜色、半径和偏移量呈现内容后面给定内容的阴影的高级效果。
dropshadow 在 JavaFX Scene Builder 2.0中的使用
javaFx Sence Builder DropShadow 解释
先看图:
注意:
设置了radius 一般不需要设置了height 和 width 了,
他们是分开的,在图中已经说明了他们的转换公式!
简单例子效果图
参数设置
Dropshadow 代码案例(官方案例)
java Dropshadow 代码片
.
DropShadow dropShadow =new DropShadow();
dropShadow.setRadius(5.0);
dropShadow.setOffsetX(3.0);
dropShadow.setOffsetY(3.0);
dropShadow.setColor(Color.color(0.4, 0.5, 0.5));
dropShadow.setSpread(0.0);
System.out.println("Width : " + dropShadow.getWidth());
System.out.println("Hieght : " + dropShadow.getHeight());
System.out.println("Radius : " + dropShadow.getRadius());
System.out.println("Color : " + dropShadow.getColor().toString());
System.out.println("spread :" + dropShadow.getSpread());
Text text = new Text();
text.setEffect(dropShadow);
text.setCache(true);
text.setX(10.0);
text.setY(70.0);
text.setFill(Color.web("0x3b596d"));
text.setText("JavaFX drop shadow...");
text.setFont(Font.font(null, FontWeight.BOLD, 40));
DropShadow dropShadow2 = new DropShadow();
dropShadow2.setOffsetX(6.0);
dropShadow2.setOffsetY(4.0);
Circle circle = new Circle();
circle.setEffect(dropShadow2);
circle.setCenterX(50.0);
circle.setCenterY(125.0);
circle.setRadius(30.0);
circle.setFill(Color.STEELBLUE);
circle.setCache(true);
Pane pane = new Pane();
pane.getChildren().addAll(text,circle);
代码效果
大家有什么补充的可以提,谢谢大家的观看阅读。