Playing with Color in JavaFX
Wednesday Dec 17, 2008
JavaFX provide a rich API for playing with colors for an image or object. The best depicted in this sample but I will show you very quickly how to change the color of a car on JSlider. I have taken this nice car from Path Animation Sample and on JSlider, I will reproduce lot of Car color like this :


Actually this is very small but some one who want to develop car race required lot of car colors(it can be done at runtime)
Code here :
package carcolors;
import javafx.scene.effect.ColorAdjust;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.animation.Timeline;
import javafx.animation.KeyFrame;
import javafx.animation.Interpolator;
import javafx.ext.swing.SwingSlider;
var hue = 0;
var s = SwingSlider {
minimum: -100
maximum: 100
value: hue
vertical: false
};
Stage {
title: "Application title"
width: 250
height: 280
scene: Scene {
content: [
s,
ImageView {
x: 100
y: 100
image: Image {
url: "{__DIR__}car.png"
}
effect: ColorAdjust {
hue: bind s.value/100.0
}
},
]
}
}















A very cool way to create new versions of entities...
welcome :)
Ha ha ha ... this was the whole idea :). Stea...
Thanks for the idea!
Hi,
I am delving into JavaFX... I am working wit...
Hi,
I am delving into JavaFX... I am working wit...