use of javafx.scene.paint.Stop in project OTP2_R6_svaap by JNuutinen.
the class Explosion method update.
@Override
public void update(double deltaTime) {
double deltaTimeMultiplier = 0.4;
for (int i = 0; i < linesAmount; i++) {
if (colors[0].getColor().getOpacity() > deltaTime * deltaTimeMultiplier) {
colors[0] = new Stop(0, new Color(colors[0].getColor().getRed(), colors[0].getColor().getGreen(), colors[0].getColor().getBlue(), colors[0].getColor().getOpacity() - deltaTime * deltaTimeMultiplier));
LinearGradient lg = new LinearGradient(0, 0, directionVector[i].getX() * lineLength * 1.05 * scaleMultiplier, directionVector[i].getY() * lineLength * 1.05 * scaleMultiplier, false, CycleMethod.REFLECT, colors);
lines.get(i).setStroke(lg);
}
}
}
use of javafx.scene.paint.Stop in project OTP2_R6_svaap by JNuutinen.
the class Trail method update.
/**
* vähentää joka päivityksessä väri- ja läpinäkyvyysarvon jokaisesta viivasta joka trailissa on.
* Poistaa viivat hännästä joiden läpinäkyvyysarvo tippuu alle vähennettävän arvon.
*
* @param deltaTime Kulunut aika viime päivityksestä.
*/
@Override
public void update(double deltaTime) {
if (getDistanceFromBetweenPoints(newestTrailPoint, target.getPosition()) > 30.0) {
Line newLine = new Line(newestTrailPoint.getX(), newestTrailPoint.getY(), target.getPosition().getX(), target.getPosition().getY());
newLine.setStrokeWidth(1);
lines.add(newLine);
Stop[] stops1 = new Stop[] { new Stop(0, Color.color(1, 1, 1)), new Stop(1, Color.color(1, 1, 1)) };
this.colors.add(stops1);
LinearGradient lg = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, colors.get(colors.size() - 1));
lines.get(lines.size() - 1).setStroke(lg);
newestTrailPoint = new Point2D(target.getPosition().getX(), target.getPosition().getY());
this.getChildren().addAll(lines.get(lines.size() - 1));
}
for (Stop[] stops : colors) {
if (stops[0].getColor().getRed() > deltaTime) {
stops[0] = new Stop(0, Color.color(stops[0].getColor().getRed() - deltaTime, stops[0].getColor().getGreen() - deltaTime, 1, stops[0].getColor().getOpacity() - deltaTime));
stops[1] = new Stop(0, Color.color(stops[1].getColor().getRed() - deltaTime, stops[1].getColor().getGreen() - deltaTime, 1, stops[1].getColor().getOpacity() - deltaTime));
}
}
int colorsIndex = 0;
for (Line line : lines) {
LinearGradient lg = new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, colors.get(colorsIndex));
line.setStroke(lg);
colorsIndex++;
}
}
use of javafx.scene.paint.Stop in project OTP2_R6_svaap by JNuutinen.
the class LaserGun method update.
@Override
public void update(double deltaTime) {
if (triggeredShoot) {
// jos ase on lataamassa laseria
// viime silmukasta kulunut aika lisätään aikalaskuriin
timeCounter += deltaTime;
chargingEffect.setRadius(chargingEffect.getRadius() + deltaTime * 17 / shootingDelay);
chargingEffect.setStrokeWidth(chargingEffect.getStrokeWidth() + deltaTime * 4 / shootingDelay);
// jos latausefektin läpinäkyvyysarvo on suurempi kuin lisättävä näkyvyysarvo, niin lisää näkyvyysarvo
if (1 - stops1[0].getColor().getOpacity() > deltaTime * 1 / shootingDelay) {
stops1[0] = new Stop(0, Color.color(0, 1, 0, stops1[0].getColor().getOpacity() + deltaTime * 1 / shootingDelay));
pointerEffect.setStroke(new LinearGradient(0, 0, 1, 0, true, CycleMethod.NO_CYCLE, stops1));
}
// jos aikaa on kulunut enemmän kuin ampumisviiveessä, niin luo LaserBeam peliin.
if (timeCounter > shootingDelay) {
controller.addUpdateable(new LaserBeam(controller, shooter, SPEED, DAMAGE, Color.WHITE, tag, getProjectileFrontOffset(), getProjectileLeftOffset()));
triggeredShoot = false;
timeCounter = 0;
shooter.getChildren().remove(chargingEffect);
shooter.getChildren().remove(pointerEffect);
}
}
}
use of javafx.scene.paint.Stop in project Board-Instrumentation-Framework by intel.
the class DemoOneEightyGauge method init.
@Override
public void init() {
gauge = OneEightyGaugeBuilder.create().animated(true).title("Temperature").unit("°C").maxValue(40).dynamicBarColor(true).stops(new Stop(0.00, Color.BLUE), new Stop(0.25, Color.CYAN), new Stop(0.50, Color.LIME), new Stop(0.75, Color.YELLOW), new Stop(1.00, Color.RED)).build();
lastTimerCall = System.nanoTime();
timer = new AnimationTimer() {
@Override
public void handle(long now) {
if (now > lastTimerCall + 2_000_000_000l) {
gauge.setValue(RND.nextDouble() * gauge.getMaxValue() + gauge.getMinValue());
lastTimerCall = now;
}
}
};
}
use of javafx.scene.paint.Stop in project Board-Instrumentation-Framework by intel.
the class DemoRadialBargraph method init.
@Override
public void init() {
control = RadialBargraphBuilder.create().title("Enzo").unit("°C").markers(new Marker(40)).threshold(25).sections(new Section(60, 80, Color.rgb(255, 255, 0, 0.5))).thresholdVisible(true).build();
control.setBarGradientEnabled(true);
List<Stop> stops = new ArrayList<>();
stops.add(new Stop(0.0, Color.BLUE));
// stops.add(new Stop(0.31, Color.CYAN));
// stops.add(new Stop(0.5, Color.LIME));
// stops.add(new Stop(0.69, Color.YELLOW));
stops.add(new Stop(1.0, Color.RED));
control.setBarGradient(stops);
lastTimerCall = System.nanoTime() + 2_000_000_000l;
timer = new AnimationTimer() {
@Override
public void handle(long now) {
if (now > lastTimerCall + 5_000_000_000l) {
control.setValue(RND.nextDouble() * 100);
lastTimerCall = now;
}
}
};
}
Aggregations