The InnerShadow works inside the shape, as compared to the the DropShadow.
Also note that offsets are opposite so a similar place is changed.
package ex46;
import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.effect.DropShadow;
import javafx.scene.effect.InnerShadow;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.stage.Stage;
public class Ex46 extends Application {
@Override
public void start(Stage stage) {
VBox root = new VBox(50);
root.setAlignment(Pos.CENTER);
Label lab1 = new Label("INNER");
lab1.setFont(Font.font("Georgia", 32));
lab1.setUnderline(true);
InnerShadow innerShadow = new InnerShadow();
innerShadow.setOffsetX(10);
innerShadow.setOffsetY(10);
innerShadow.setRadius(5);
innerShadow.setColor(Color.GREEN);
Circle circle1 = new Circle(50);
circle1.setFill(Color.BLUE);
circle1.setEffect(innerShadow);
HBox hbox1 = new HBox(50, lab1, circle1);
hbox1.setAlignment(Pos.CENTER);
Label lab2 = new Label("DROP ");
lab2.setFont(Font.font("Georgia", FontPosture.ITALIC, 32));
DropShadow dropShadow = new DropShadow();
dropShadow.setOffsetX(-10);
dropShadow.setOffsetY(-10);
dropShadow.setRadius(5);
dropShadow.setColor(Color.GREEN);
Circle circle2 = new Circle(50);
circle2.setFill(Color.BLUE);
circle2.setEffect(dropShadow);
HBox hbox2 = new HBox(50, lab2, circle2);
hbox2.setAlignment(Pos.CENTER);
root.getChildren().addAll(hbox1, hbox2);
Scene scene = new Scene(root, 400, 400, Color.LIGHTYELLOW);
stage.setTitle("Example 46. InnerShadow");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
This is the output:
No comments:
Post a Comment