Berbagai Contoh Efek pada Shape


Ini Adalah berbagai contoh efek pada JavaFX, di coba pada JavaFX 1.3

/*
* Berbagai contoh efek untuk shape
*
*/
package bab8_antarmuka;

import javafx.scene.effect.Blend;
import javafx.scene.effect.BlendMode;
import javafx.scene.effect.ColorAdjust;
import javafx.scene.effect.Flood;
import javafx.scene.paint.Color;
import javafx.scene.effect.Glow;
import javafx.scene.effect.Lighting;
import javafx.scene.effect.PerspectiveTransform;
import javafx.scene.effect.SepiaTone;
import javafx.scene.effect.Bloom;
import javafx.scene.effect.DropShadow;
import javafx.scene.effect.GaussianBlur;
import javafx.scene.effect.InnerShadow;
import javafx.scene.effect.MotionBlur;
import javafx.scene.effect.Reflection;
import javafx.scene.effect.Shadow;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.shape.Rectangle;
import javafx.scene.layout.HBox;
import javafx.geometry.Insets;
import javafx.scene.control.ScrollView;
import javafx.scene.layout.LayoutInfo;
import javafx.scene.Node;

/**
* @author bhangun
*/
var blend = Blend {
mode: BlendMode.ADD
opacity: 0.5
}
var colorAdjust = ColorAdjust {
brightness: 0.0
contrast: 1.0
hue: 0.5
saturation: 0.6
}
var flood = Flood {
paint: Color.GREEN
width: 20
height: 60
x: 5
y: 23
}
var glow = Glow {
level: 1
}
var lighting = Lighting {
diffuseConstant: 1.0
specularConstant: 1.0
specularExponent: 20
surfaceScale: 1.5
}
var perspectiveTransform = PerspectiveTransform {
llx: 13.4, lly: 50.0
lrx: 56.6, lry: 50.0
ulx: 13.4, uly: -10.0
urx: 56.6, ury: 10.0
}
var sepiaTone = SepiaTone {
level: 0.9
}
var bloom = Bloom {
threshold: 0.9
}
var dropShadow = DropShadow {
offsetX: 10
offsetY: 10
color: Color.BLACK
radius: 10
}
var gaussianBlur = GaussianBlur {
radius: 20
}
var innerShadow = InnerShadow {
choke: 0.5
offsetX: 10
offsetY: 10
radius: 10
color: Color.WHEAT
}
var motionBlur = MotionBlur {
angle: 45
radius: 10
}
var reflection = Reflection {
fraction: 0.75
topOffset: 0.0
topOpacity: 0.5
bottomOpacity: 0.0
}
var shadow = Shadow {
color: Color.BLACK
radius: 15
}

function effects(i: Integer): Node {
var seq = [
blend,
colorAdjust,
flood,
glow,
lighting,
perspectiveTransform,
sepiaTone,
bloom,
dropShadow,
gaussianBlur,
innerShadow,
motionBlur,
reflection,
shadow];
Rectangle {
width: 40, height: 40
fill: Color.BLUE
effect: seq[i]
}
}

Stage {
title: “Effect”
onClose: function () {
}
scene: Scene {
width: 500
height: 150
content: [
ScrollView {
layoutInfo: LayoutInfo {
width: 500
height: 150
}
node: HBox {
padding: Insets {top: 20 right: 20 bottom: 10 left: 10 }
spacing: 30
content: for (i in[0..13])
effects(i)
}
}
]
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: