use of javafx.scene.paint.Color in project fxexperience2 by EricCanull.
the class ColorPickerControl method onPickerRegionPressed.
@FXML
void onPickerRegionPressed(MouseEvent e) {
double mx = e.getX();
double my = e.getY();
// Update UI
final Color color = updateUI_OnPickerChange(mx, my);
// Update model
setPaintProperty(color);
}
use of javafx.scene.paint.Color in project fxexperience2 by EricCanull.
the class ColorPickerControl method onHSBChange.
private void onHSBChange(ActionEvent event) {
// Update UI
final Color color = updateUI_OnHSBChange();
final Object source = event.getSource();
assert source instanceof TextField;
((TextField) source).selectAll();
// Update model
setPaintProperty(color);
}
use of javafx.scene.paint.Color in project fxexperience2 by EricCanull.
the class WebColorFieldSkin method updateText.
@Override
protected void updateText() {
Color color = ((WebColorField) control).getValue();
if (color == null)
color = Color.BLACK;
getTextField().setText(getWebColor(color));
}
use of javafx.scene.paint.Color in project fxexperience2 by EricCanull.
the class DerivationController method updateReverse.
private void updateReverse() {
Color desiredColor = desiredColorPicker.getColor();
final Color base = baseColorPicker.getColor();
// System.out.println("base = " + base);
double desiredBrightness = desiredColor.getBrightness();
// System.out.println("desiredBrightness = " + desiredBrightness);
// double desiredSaturation = desiredColor.getSaturation();
// System.out.println("desiredSaturation = " + desiredSaturation);
double derivation = 0, max = 1, min = -1;
Color derivedColor = Color.WHITE;
for (int i = 0; i < 100; i++) {
// System.out.println("---------- "+i+" ----------------");
// System.out.println("derivation = " + derivation);
// System.out.println("max = " + max);
// System.out.println("min = " + min);
derivedColor = ColorEncoder.deriveColor(base, derivation);
double derivedBrightness = derivedColor.getBrightness();
// System.out.println("derivedBrightness = " + derivedBrightness);
// double derivedSaturation = derivedColor.getSaturation();
// System.out.println("derivedSaturation = " + derivedSaturation);
// double saturationDifference = Math.abs(derivedSaturation-desiredSaturation);
// System.out.println("saturationDifference = " + saturationDifference);
double difference = Math.abs(derivedBrightness - desiredBrightness);
// System.out.println("brightness difference = " + difference);
if (difference < 0.0001) {
// GOOD ENOUGH
break;
} else if (min == 1 || max == -1) {
// TO DIFFERENT
break;
} else if (derivedBrightness > desiredBrightness) {
// TO BRIGHT
// System.out.println("NEED DARKER");
max = derivation;
derivation = derivation + ((min - derivation) / 2);
} else {
// TO DARK
// System.out.println("NEED BRIGHTER");
min = derivation;
derivation = derivation + ((max - derivation) / 2);
}
}
// System.out.println("\nFINAL \nderivation = " + derivation+"\n\n");
reverseDerivationLabel.setText(String.format("%3.3f%%", derivation));
reverseResultLabel.setText(getColorString(derivedColor));
reverseResultColor.setStyle("-fx-border-color: black; " + "-fx-background-color: " + getWebColor(derivedColor) + ";");
alert.setVisible(!getWebColor(desiredColor).equals(getWebColor(derivedColor)));
}
use of javafx.scene.paint.Color in project FXyzLib by Birdasaur.
the class BillBoardBehaviorTest method createSubscene.
private void createSubscene() {
subScene = new SubScene(root, 800, 600, true, SceneAntialiasing.BALANCED);
camera = new PerspectiveCamera(true);
cameraTransform.setTranslate(0, 0, 0);
cameraTransform.getChildren().addAll(camera);
camera.setNearClip(0.1);
camera.setFarClip(100000.0);
camera.setFieldOfView(35);
camera.setTranslateZ(-cameraDistance);
cameraTransform.ry.setAngle(-45.0);
cameraTransform.rx.setAngle(-10.0);
//add a Point Light for better viewing of the grid coordinate system
PointLight light = new PointLight(Color.WHITE);
cameraTransform.getChildren().add(light);
light.setTranslateX(camera.getTranslateX());
light.setTranslateY(camera.getTranslateY());
light.setTranslateZ(camera.getTranslateZ());
root.getChildren().add(cameraTransform);
subScene.setCamera(camera);
initFirstPersonControls(subScene);
skyBox = new Skybox(new Image("http://www.zfight.com/misc/images/textures/envmaps/violentdays_large.jpg"), 100000, camera);
//Make a bunch of semi random Torusesessses(toroids?) and stuff : from torustest
Group torusGroup = new Group();
for (int i = 0; i < 10; i++) {
Random r = new Random();
//A lot of magic numbers in here that just artificially constrain the math
float randomRadius = (float) ((r.nextFloat() * 300) + 50);
float randomTubeRadius = (float) ((r.nextFloat() * 100) + 1);
int randomTubeDivisions = (int) ((r.nextFloat() * 64) + 1);
int randomRadiusDivisions = (int) ((r.nextFloat() * 64) + 1);
Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
boolean ambientRandom = r.nextBoolean();
boolean fillRandom = r.nextBoolean();
if (i == 0) {
torusGroup.getChildren().add(bill);
}
TorusMesh torus = new TorusMesh(randomTubeDivisions, randomRadiusDivisions, randomRadius, randomTubeRadius);
double translationX = Math.random() * 1024 * 1.95;
if (Math.random() >= 0.5) {
translationX *= -1;
}
double translationY = Math.random() * 1024 * 1.95;
if (Math.random() >= 0.5) {
translationY *= -1;
}
double translationZ = Math.random() * 1024 * 1.95;
if (Math.random() >= 0.5) {
translationZ *= -1;
}
Translate translate = new Translate(translationX, translationY, translationZ);
Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);
torus.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
//torus.getTransforms().add(translate);
torusGroup.getChildren().add(torus);
}
root.getChildren().addAll(skyBox, torusGroup);
rootPane.getChildren().add(subScene);
//Enable subScene resizing
subScene.widthProperty().bind(rootPane.widthProperty());
subScene.heightProperty().bind(rootPane.heightProperty());
subScene.setFocusTraversable(true);
}
Aggregations