use of javafx.scene.paint.Color in project FXyzLib by Birdasaur.
the class FPSControllerTest method start.
@Override
public void start(Stage stage) {
Group root = new Group();
//Make a bunch of semi random Torusesessses(toroids?) and stuff : from torustest
Group torusGroup = new Group();
for (int i = 0; i < 30; 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());
Torus torus = new Torus(randomTubeDivisions, randomRadiusDivisions, randomRadius, randomTubeRadius, randomColor);
torus.setEmissiveLightingColor(randomColor);
torus.setEmissiveLightingOn(r.nextBoolean());
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().add(torusGroup);
Scene scene = new Scene(root, 1400, 1000, true, SceneAntialiasing.BALANCED);
scene.setFill(Color.BLACK);
stage.setTitle("SimpleFPSControllerTest");
stage.setScene(scene);
stage.show();
//stage.setMaximized(true);
FPSController controller = new FPSController();
controller.setScene(scene);
controller.setMouseLookEnabled(true);
AdvancedCamera camera = new AdvancedCamera();
camera.setController(controller);
root.getChildren().add(camera);
scene.setCamera(camera);
}
use of javafx.scene.paint.Color in project FXyzLib by Birdasaur.
the class ConeTest method start.
@Override
public void start(Stage stage) {
Group coneGroup = new Group();
for (int i = 0; i < 100; i++) {
Random r = new Random();
//A lot of magic numbers in here that just artificially constrain the math
float randomRadius = (float) ((r.nextFloat() * 100) + 25);
float randomHeight = (float) ((r.nextFloat() * 300) + 75);
int randomDivisions = (int) ((r.nextFloat() * 50) + 5);
Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());
Cone cone = new Cone(randomDivisions, randomRadius, randomHeight, randomColor);
cone.setEmissiveLightingColor(randomColor);
cone.setEmissiveLightingOn(r.nextBoolean());
cone.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);
double translationX = Math.random() * 1024;
if (Math.random() >= 0.5) {
translationX *= -1;
}
double translationY = Math.random() * 1024;
if (Math.random() >= 0.5) {
translationY *= -1;
}
double translationZ = Math.random() * 1024;
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);
cone.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);
coneGroup.getChildren().add(cone);
}
root.getChildren().add(coneGroup);
camera = new AdvancedCamera();
controller = new FPSController();
camera.setNearClip(0.1);
camera.setFarClip(10000.0);
camera.setFieldOfView(42);
camera.setController(controller);
Scene scene = new Scene(new StackPane(root), 1024, 668, true, SceneAntialiasing.BALANCED);
scene.setCamera(camera);
scene.setFill(Color.BLACK);
controller.setScene(scene);
stage.setTitle("Random Cones!");
stage.setScene(scene);
stage.show();
stage.setFullScreen(false);
stage.setFullScreenExitHint("");
}
use of javafx.scene.paint.Color in project FXyzLib by Birdasaur.
the class Histogram method setHeightData.
public void setHeightData(float[][] arrayY, int barSize, int spacing, Color color, boolean ambient, boolean fill) {
histogramDataGroup.getChildren().clear();
PhongMaterial phong = new PhongMaterial();
phong.setSpecularColor(color);
phong.setDiffuseColor(color);
float min = arrayY[0][0], max = arrayY[0][0];
// Find min and max's for color gradient
for (int x = 0; x < arrayY.length; x++) {
for (int z = 0; z < arrayY[0].length; z++) {
if (arrayY[x][z] < min) {
min = arrayY[x][z];
}
if (arrayY[x][z] > max) {
max = arrayY[x][z];
}
}
}
//
float range = max - min;
// Generate Bars
for (int x = 0; x < arrayY.length; x++) {
for (int z = 0; z < arrayY[0].length; z++) {
double ySize = arrayY[x][z];
if (ySize < 0) {
ySize *= -1;
}
Node bar = createDefaultNode(barSize, ySize);
bar.setTranslateX(x * spacing);
bar.setTranslateY(-arrayY[x][z]);
bar.setTranslateZ(z * spacing);
//Apply normalized color scale
double normalizedColor = (arrayY[x][z] - min) / range;
if (//if it is in the lower half of the range
arrayY[x][z] < range / 2) {
phong = new PhongMaterial(new Color(0.25, 0, normalizedColor, 1));
} else //if it is in the upper half of the range
{
phong = new PhongMaterial(new Color(normalizedColor, 0, 0.25, 1));
}
switch(getDefaultNodeType()) {
case CYLINDER:
{
((Cylinder) bar).setMaterial(phong);
((Cylinder) bar).setCullFace(CullFace.BACK);
if (fill) {
((Cylinder) bar).setDrawMode(DrawMode.FILL);
} else {
//show lines only by default
((Cylinder) bar).setDrawMode(DrawMode.LINE);
}
break;
}
case CUBE:
default:
{
((Box) bar).setMaterial(phong);
((Box) bar).setCullFace(CullFace.BACK);
if (fill) {
((Box) bar).setDrawMode(DrawMode.FILL);
} else {
//show lines only by default
((Box) bar).setDrawMode(DrawMode.LINE);
}
}
}
if (ambient) {
AmbientLight light = new AmbientLight(color);
light.getScope().add(bar);
histogramDataGroup.getChildren().add(light);
}
histogramDataGroup.getChildren().add(bar);
}
}
}
use of javafx.scene.paint.Color in project aima-java by aimacode.
the class ConnectFourApp method update.
/** Updates the view after the model state has changed. */
private void update(Observable o, Object arg) {
final int cols = model.getCols();
for (int i = 0; i < disks.length; i++) {
String player = model.getPlayerAt(i / cols, i % cols);
Color color = Color.DARKBLUE;
if (player != null)
color = player.equals("red") ? Color.RED : Color.YELLOW;
else {
for (String p : model.getPlayers()) if (model.isWinPositionFor(i / cols, i % cols, p))
color = Color.BLACK;
}
disks[i].setFill(color);
}
String statusText;
if (!model.isGameOver()) {
String toMove = model.getPlayerForNextMove();
statusText = "Next move: " + toMove;
statusBar.setTextFill(toMove.equals("red") ? Color.RED : Color.YELLOW);
} else {
String winner = model.getWinner();
if (winner != null)
statusText = "Color " + winner + " has won. Congratulations!";
else
statusText = "No winner :-(";
statusBar.setTextFill(Color.WHITE);
}
if (model.searchMetrics != null)
statusText += " " + model.searchMetrics;
statusBar.setText(statusText);
}
use of javafx.scene.paint.Color in project aima-java by aimacode.
the class CspViewCtrl method visualize.
protected void visualize(VAR var) {
Point2D pos = getPosition(var);
String label = var.getName();
VAL value = null;
Color fillColor = null;
if (assignment != null)
value = assignment.getValue(var);
if (value != null) {
label += " = " + value;
fillColor = colorMapping.get(value);
}
Circle circle = new Circle(pos.getX(), pos.getY(), 20);
circle.setStroke(Color.BLACK);
circle.setFill(fillColor != null ? fillColor : Color.WHITE);
Text t1 = new Text(pos.getX() + 25, pos.getY(), label);
t1.setTextOrigin(VPos.CENTER);
Text t2 = new Text(pos.getX(), pos.getY() + 40, csp.getDomain(var).toString());
pane.getChildren().addAll(circle, t1, t2);
}
Aggregations