/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER * * Copyright © 2010, Oracle and/or its affiliates. All rights reserved. * Oracle is a registered trademark of Oracle Corporation and/or its affiliates. * Oracle and Java are registered trademarks of Oracle and/or its affiliates. * Other names may be trademarks of their respective owners. * * This file is available and licensed under the following license: * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, trademark notice, this list of conditions, and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, trademark notice, this list of conditions, and the following disclaimer in the documentation and/or other materials provided with the distribution. * * Neither the name of Oracle nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ import javafx.scene.Group; import javafx.scene.Cursor; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.scene.paint.Color; import javafx.scene.paint.RadialGradient; import javafx.scene.paint.CycleMethod; import javafx.scene.paint.Stop; import javafx.scene.shape.*; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.effect.*; import javafx.scene.effect.light.*; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.stage.Stage; import javafx.scene.Scene; //Shadow var shadow1 = Group{content:[ Circle{centerX: 30 centerY:40 radius:20 fill: Color.RED opacity: 0.8 cursor: Cursor.HAND}, Line {startX: 20 startY: 30 endX: 40 endY: 50 stroke: Color.WHITE strokeWidth: 2}, Line {startX: 20 startY: 50 endX: 40 endY: 30 stroke: Color.WHITE strokeWidth: 2} ] effect: DropShadow{offsetX:5 offsetY:5 color: Color.BLACK} }; var shadow2 = Group{content:[ Circle{centerX: 50 centerY:40 radius:20 fill: Color.RED opacity: 0.8 }, Line {startX: 40 startY: 30 endX: 60 endY: 50 stroke: Color.WHITE strokeWidth: 2}, Line {startX: 40 startY: 50 endX: 60 endY: 30 stroke: Color.WHITE strokeWidth: 2} ] effect: InnerShadow{offsetX:5 offsetY:5 color: Color.BLACK} }; var shadow3 = Group{content:[ Circle{centerX: 40 centerY:40 radius:20 fill: Color.RED opacity: 0.8 effect: DropShadow{offsetX: -5 offsetY: 10 color: Color.BLACK}}, Line {startX: 30 startY: 30 endX: 50 endY: 50 stroke: Color.WHITE strokeWidth: 2}, Line {startX: 30 startY: 50 endX: 50 endY: 30 stroke: Color.WHITE strokeWidth: 2} ] effect: InnerShadow{offsetX: -5 color: Color.BLACK} }; var shadow4 = Group{content:[ Circle{centerX: 30 centerY:40 radius:20 fill: Color.RED opacity: 0.8}, Line {startX: 20 startY: 30 endX: 40 endY: 50 stroke: Color.WHITE strokeWidth: 2}, Line {startX: 20 startY: 50 endX: 40 endY: 30 stroke: Color.WHITE strokeWidth: 2} ] effect: Blend{ topInput: DropShadow {offsetX: 4 offsetY: 4 radius: 6 color: Color.DARKBLUE} bottomInput: DropShadow {offsetX: -4 offsetY: 4 radius: 6 color: Color.DARKMAGENTA} } }; //Lighting var lighting1 = Group{content:[ Circle{centerX: 30 centerY:20 radius:20 fill: Color.RED opacity: 0.9}, Line {startX: 20 startY: 10 endX: 40 endY: 30 stroke: Color.WHITE strokeWidth: 2}, Line {startX: 20 startY: 30 endX: 40 endY: 10 stroke: Color.WHITE strokeWidth: 2} ] effect: Lighting{ light: DistantLight{azimuth: 90}} }; var lighting2 = Group{content:[ Circle{centerX: 30 centerY:20 radius:20 fill: Color.RED opacity: 0.9}, Line {startX: 20 startY: 10 endX: 40 endY: 30 stroke: Color.WHITE strokeWidth: 2}, Line {startX: 20 startY: 30 endX: 40 endY: 10 stroke: Color.WHITE strokeWidth: 2} ] effect: Lighting{ light: DistantLight{azimuth: 270}} }; var lighting3 = Group{content:[ Circle{centerX: 30 centerY:20 radius:20 fill: Color.RED opacity: 0.9}, Line {startX: 20 startY: 10 endX: 40 endY: 30 stroke: Color.WHITE strokeWidth: 2}, Line {startX: 20 startY: 30 endX: 40 endY: 10 stroke: Color.WHITE strokeWidth: 2} ] effect: Lighting{light: PointLight{x: 15 y: 15 z: 5}} }; var lighting4 = Group{content:[ Circle{centerX: 30 centerY:20 radius:20 fill: Color.RED opacity: 0.9}, Line {startX: 20 startY: 10 endX: 40 endY: 30 stroke: Color.WHITE strokeWidth: 2}, Line {startX: 20 startY: 30 endX: 40 endY: 10 stroke: Color.WHITE strokeWidth: 2} ] effect: Lighting{light: SpotLight {x: 0 y: 10 z: 10 pointsAtX: 20 pointsAtY: 20 pointsAtZ: 0 specularExponent: 2}} }; //Blur var blur1 = Rectangle{x:5 y:25 width: 100 height: 50 fill: RadialGradient{ centerX: 55, centerY: 50, radius: 10, proportional: false cycleMethod: CycleMethod.REFLECT stops: [ Stop{offset: 0.3 color: Color.DARKGREEN}, Stop{offset: 1.0 color: Color.WHITE} ] } effect: GaussianBlur{radius: 5 }}; var blur2 = Rectangle{x:5 y: 25 width: 100 height: 50 fill: RadialGradient{ centerX: 55, centerY: 50, radius: 10, proportional: false cycleMethod: CycleMethod.REFLECT stops: [ Stop{offset: 0.3 color: Color.DARKGREEN}, Stop{offset: 1.0 color: Color.WHITE} ] } effect: MotionBlur{ angle: 45 input: InnerShadow {offsetX: 4 offsetY: 4 radius: 6 color: Color.YELLOW} radius: 10 }}; //Reflection var reflection = Text{x: 10 y: 42 content: "Reflection" fill: Color.SEAGREEN font: Font{size:20 name: "Verdana"} effect: Reflection {fraction: 0.9 topOpacity: 0.9 topOffset: 0.1}}; //Glow def imageDuke = Image{url: "{__DIR__}penduke.gif"}; var glow = ImageView{image: imageDuke effect: Glow{level: 1 }}; //Sepia Tone var sepia = ImageView{image: imageDuke effect: SepiaTone {level: 0.8}}; //Color Adjust def strawberry = Image{ url: "{__DIR__}strawberry.jpg"}; var originalPic = ImageView{image: strawberry}; var contrast = ImageView{image: strawberry effect: ColorAdjust{contrast: 2}}; var hue = ImageView{image: strawberry effect: ColorAdjust{hue: 1.0}}; //Perspective transformation var original = ImageView{ image: imageDuke }//ImageView var transformed = ImageView{ image: imageDuke effect: PerspectiveTransform { ulx: 40 uly: 20 urx: 104 ury: 20 lrx: 134 lry: 115 llx: 10 lly: 105 } }//ImageView Stage { title: "Effects" width: 420 height: 700 visible: true scene: Scene{ content: VBox{ translateY: 10 spacing: 25 content:[ HBox{spacing: 40 content:[shadow1, shadow2, shadow3, shadow4]}, HBox{spacing: 50 content: [lighting1, lighting2, lighting3, lighting4]}, HBox{spacing: 15 content:[blur1, blur2, reflection]}, HBox{spacing: 25 content:[glow, sepia]}, HBox{spacing: 40 content:[originalPic, contrast, hue] translateY: 20}, HBox{spacing: 20 content:[original, transformed] translateY: 25} ] }//VBox }//Scene }//Stage