private void initBackground() { Rectangle bg0 = new Rectangle(getWidth(), getHeight(), new LinearGradient(getWidth() / 2, 0, getWidth() / 2, getHeight(), false, CycleMethod.NO_CYCLE, new Stop(0.2, Color.AQUA), new Stop(0.8, Color.BLACK))); Rectangle bg1 = new Rectangle(getWidth(), getHeight(), Color.color(0, 0, 0, 0.2)); bg1.setBlendMode(BlendMode.DARKEN); EntityView bg = new EntityView(RenderLayer.BACKGROUND); bg.addNode(bg0); bg.addNode(bg1); // we add IrremovableComponent because regardless of the level // the background and screen bounds stay in the game world Entities.builder() .viewFromNode(bg) .with(new IrremovableComponent()) .buildAndAttach(getGameWorld()); Entity screenBounds = Entities.makeScreenBounds(40); screenBounds.addComponent(new IrremovableComponent()); getGameWorld().addEntity(screenBounds); }
private void initBubbles() { ParticleEmitter emitter = new ParticleEmitter(); emitter.setSourceImage(getAssetLoader().loadTexture("bubble.png").getImage()); emitter.setBlendMode(BlendMode.SRC_OVER); emitter.setEmissionRate(0.25); emitter.setExpireFunction((i, x, y) -> Duration.seconds(3)); emitter.setVelocityFunction((i, x, y) -> new Point2D(0, -FXGLMath.random(2f, 4f) * 60)); emitter.setSpawnPointFunction((i, x, y) -> new Point2D(FXGLMath.random(0, (float)getWidth()), y - 20 + FXGLMath.random(50))); emitter.setScaleFunction((i, x, y) -> new Point2D(FXGLMath.random(-0.05f, 0), FXGLMath.random(-0.05f, 0))); emitter.setInterpolator(Interpolators.EXPONENTIAL.EASE_IN()); Entity bubbles = new Entity(); bubbles.translateY(getHeight()); bubbles.addControl(new ParticleControl(emitter)); getGameWorld().addEntity(bubbles); }
/** * @return new emitter with explosion configuration */ public static ParticleEmitter newExplosionEmitter(int explosionRadius) { ParticleEmitter emitter = new ParticleEmitter(); emitter.setNumParticles(100); emitter.setEmissionRate(0.0166); emitter.setMaxEmissions(1); emitter.setSize(5, 20); emitter.setSpawnPointFunction((i, x, y) -> new Point2D(x, y)); emitter.setVelocityFunction((i, x, y) -> new Point2D(Math.cos(i), Math.sin(i)).multiply(explosionRadius)); emitter.setScaleFunction((i, x, y) -> new Point2D(rand() * -0.1, rand() * -0.1)); emitter.setExpireFunction((i, x, y) -> Duration.seconds(0.5)); emitter.setColor(Color.rgb((int) rand(200, 255), 30, 20)); emitter.setBlendMode(BlendMode.ADD); emitter.setInterpolator(Interpolators.EXPONENTIAL.EASE_OUT()); return emitter; }
@Override public void reset() { image = null; startPosition.setZero(); position.setZero(); velocity.setZero(); acceleration.setZero(); radius.setZero(); scale.setZero(); startColor = Color.TRANSPARENT; endColor = Color.TRANSPARENT; blendMode = BlendMode.SRC_OVER; initialLife = 0; life = 0; interpolator = Interpolator.LINEAR; control = null; }
private void createTargetButton() { target = (StackPane) lookup("#targetAnchor"); Image image = IconFactory.getTargetIcon(); ImageView targetIcon = new ImageView(image); targetIcon.setClip(new ImageView(image)); ColorAdjust monochrome = new ColorAdjust(); monochrome.setSaturation(-1.0); Blend red = new Blend(BlendMode.MULTIPLY, monochrome, new ColorInput(0, 0, targetIcon.getImage().getWidth(), targetIcon.getImage().getHeight(), Color.RED)); Blend green = new Blend(BlendMode.MULTIPLY, monochrome, new ColorInput(0, 0, targetIcon.getImage().getWidth(), targetIcon.getImage().getHeight(), new Color(0, 1, 0, 0.5))); targetButton = targetIcon; targetIcon.effectProperty().bind(Bindings.when(targetButton.hoverProperty()).then((Effect) green).otherwise((Effect) red)); targetButton.setId("target_button"); hideTargetMarker(); target.getChildren().add(targetButton); }
private static Image generateBrokenHeartImage() { FontAwesomeIconView newHeart = new FontAwesomeIconView(FontAwesomeIcon.HEART); newHeart.setGlyphSize(graphicFontSize); FontAwesomeIconView newBolt = new FontAwesomeIconView(FontAwesomeIcon.BOLT); newBolt.setGlyphSize(graphicFontSize); newBolt.setScaleX(0.65); newBolt.setScaleY(0.65); newBolt.setTranslateX(-1.0); newHeart.setFill(brokenColor); newBolt.setFill(Color.WHITE); StackPane generated = new StackPane( newHeart, newBolt ); StackPane.setAlignment(newBolt, Pos.CENTER); StackPane.setAlignment(newHeart, Pos.CENTER); generated.setBlendMode(BlendMode.MULTIPLY); generated.setEffect( new DropShadow(BlurType.GAUSSIAN, heartDefaultColor, 7.0, 0.25, 0.0, 0.0)); return CellUtils.makeSnapshotWithTransparency(generated); }
/** * Returns a JavaFX BlendMode that is the closest match for the Java2D * alpha composite rule. * * @param rule the rule. * * @return The blend mode. */ private BlendMode blendMode(int rule) { switch (rule) { case AlphaComposite.SRC_ATOP: return BlendMode.SRC_ATOP; case AlphaComposite.CLEAR: case AlphaComposite.DST: case AlphaComposite.DST_ATOP: case AlphaComposite.DST_IN: case AlphaComposite.DST_OUT: case AlphaComposite.DST_OVER: case AlphaComposite.SRC: case AlphaComposite.SRC_IN: case AlphaComposite.SRC_OUT: case AlphaComposite.SRC_OVER: case AlphaComposite.XOR: return BlendMode.SRC_OVER; default: return BlendMode.SRC_OVER; } }
/** * takes the oil pump image and adds a plus to it */ public NewAgentPortrait(Image originalImage) { super(); ImageView firm = new ImageView(originalImage); size = firm.fitWidthProperty(); size.setValue(100);//just so that it has a value firm.setPreserveRatio(true); firm.setSmooth(true); firm.setCache(true); ImageView addPlus = new ImageView(PLUS_IMAGE); addPlus.setEffect(new Glow(2)); addPlus.fitWidthProperty().bind(firm.fitWidthProperty().divide(2)); addPlus.setPreserveRatio(true); addPlus.setSmooth(true); addPlus.setCache(true); addPlus.setBlendMode(BlendMode.SRC_OVER); this.getChildren().addAll(firm,addPlus); }
private List<Text> getTextNodes(final String title, final double startAngle) { final List<Text> texts = new ArrayList<Text>(); final char[] titleCharArray = title.toCharArray(); for (int i = titleCharArray.length - 1; i >= 0; i--) { final Text charText = new Text( Character.toString(titleCharArray[i])); charText.setFontSmoothingType(FontSmoothingType.LCD); charText.setSmooth(true); charText.setMouseTransparent(true); charText.setFill(textColor); charText.setBlendMode(BlendMode.COLOR_BURN); charText.setFont(textFont); texts.add(charText); } return texts; }
@Spawns("Explosion") public Entity spawnExplosion(SpawnData data) { play("explosion-0" + (int) (Math.random() * 8 + 1) + ".wav"); // explosion particle effect ParticleEmitter emitter = ParticleEmitters.newExplosionEmitter(100); emitter.setSize(10, 12); emitter.setNumParticles(24); emitter.setExpireFunction((i, x, y) -> Duration.seconds(2)); emitter.setVelocityFunction((i, x, y) -> Vec2.fromAngle(360 / 24 *i).toPoint2D().multiply(FXGLMath.random(45, 50))); emitter.setBlendMode(BlendMode.SRC_OVER); emitter.setStartColor(Color.YELLOW); emitter.setEndColor(Color.RED); com.almasb.fxgl.effect.ParticleControl control = new ParticleControl(emitter); Entity explosion = Entities.builder() .at(data.getX() - 5, data.getY() - 10) .with(control) .buildAndAttach(); control.setOnFinished(explosion::removeFromWorld); return Entities.builder() .at(data.getX() - 40, data.getY() - 40) .viewFromNode(texture("explosion.png", 80 * 48, 80).toAnimatedTexture(48, Duration.seconds(2))) .with(new ExpireCleanControl(Duration.seconds(1.8))) .build(); }
private void initBall() { ball = factory.newBall(getWidth() / 2 - 5, getHeight() / 2 - 5); ParticleEmitter emitter = ParticleEmitters.newFireEmitter(); emitter.setStartColor(Color.LIGHTYELLOW); emitter.setEndColor(Color.RED); emitter.setBlendMode(BlendMode.SRC_OVER); emitter.setSize(5, 10); emitter.setEmissionRate(1); ball.addControl(new ParticleControl(emitter)); getGameWorld().addEntity(ball); }
@Override protected void onCollisionBegin(Entity bullet, Entity enemy) { Object owner = bullet.getComponent(OwnerComponent.class).getValue(); // some enemy shot the bullet, skip collision handling if (owner == SpaceInvadersType.ENEMY) { return; } GameWorld world = bullet.getWorld(); Point2D hitPosition = bullet.getComponent(PositionComponent.class).getValue(); bullet.removeFromWorld(); HealthComponent hp = enemy.getComponent(HealthComponent.class); hp.setValue(hp.getValue() - 1); if (hp.getValue() <= 0) { if (enemy.hasControl(EnemyControl.class)) { enemy.getControl(EnemyControl.class).die(); } else { enemy.getControl(BossControl.class).die(); } } else { world.spawn("LaserHit", hitPosition); // make enemy look red enemy.getComponent(ViewComponent.class).getView().setBlendMode(BlendMode.RED); // return enemy look to normal FXGL.getMasterTimer() .runOnceAfter(() -> { if (enemy.isActive()) enemy.getComponent(ViewComponent.class).getView().setBlendMode(null); }, Duration.seconds(0.33)); } }
public void shadowandinner(Blend blend){ DropShadow shadow = new DropShadow(); shadow.setOffsetY(7.0f); shadow.setColor(Color.DARKGRAY); InnerShadow innerShadow = new InnerShadow(); innerShadow.setOffsetX(1.0f); innerShadow.setOffsetY(1.0f); innerShadow.setColor(Color.LIGHTGRAY); blend.setMode(BlendMode.MULTIPLY); blend.setBottomInput(shadow); blend.setTopInput(innerShadow); }
@Override protected void initInput() { getInput().addAction(new UserAction("Change Color") { @Override protected void onActionBegin() { Color randomColor = Color.color(FXGLMath.random(), FXGLMath.random(), FXGLMath.random()); emitter.setBlendMode(BlendMode.SRC_OVER); e.setStartColor(randomColor); e.setEndColor(Color.color(FXGLMath.random(), FXGLMath.random(), FXGLMath.random())); } }, MouseButton.PRIMARY); }
public void onUpdate(double tpf) { getViewport().onUpdate(tpf); boolean dirty = drawables.isNotEmpty() || particles.isNotEmpty(); if (dirty || wasDirty) { particlesGC.setGlobalAlpha(1); particlesGC.setGlobalBlendMode(BlendMode.SRC_OVER); // TODO: this is very costly, do we know exact dimensions to clear // OR can we do this off the render thread inbetween frames? particlesGC.clearRect(0, 0, getWidth(), getHeight()); wasDirty = false; } for (Entity e : drawables) { DrawableComponent drawable = e.getComponent(DrawableComponent.class); if (drawable != null) { drawable.draw(particlesGC); } } for (ParticleControl particle : particles) { particle.renderParticles(particlesGC, getViewport().getOrigin()); } wasDirty = dirty; }
/** * @return new emitter with fire configuration */ public static ParticleEmitter newFireEmitter() { ParticleEmitter emitter = new ParticleEmitter(); emitter.setNumParticles(15); emitter.setEmissionRate(0.5); emitter.setColor(Color.rgb(230, 75, 40)); emitter.setSize(9, 12); emitter.setVelocityFunction((i, x, y) -> new Point2D(rand(-0.5, 0.5) * 0.25 * 60, rand() * -1 * 60)); emitter.setSpawnPointFunction((i, x, y) -> new Point2D(x, y).add(new Point2D(i * (rand() - 0.5), (rand() - 1)))); emitter.setScaleFunction((i, x, y) -> new Point2D(rand(-0.01, 0.01) * 10, rand() * -0.1)); emitter.setExpireFunction((i, x, y) -> Duration.seconds(1)); emitter.setBlendMode(BlendMode.ADD); return emitter; }
public final void init(Image image, Point2D position, Point2D vel, Point2D acceleration, double radius, Point2D scale, Duration expireTime, Paint startColor, Paint endColor, BlendMode blendMode, Interpolator interpolator) { this.image = image; this.startPosition.set(position); this.position.set(position); this.radius.set((float) radius, (float) radius); this.scale.set(scale); this.velocity.set(vel); this.acceleration.set(acceleration); this.startColor = startColor; this.endColor = endColor; this.blendMode = blendMode; this.initialLife = expireTime.toSeconds(); this.life = initialLife; this.interpolator = interpolator; }
private static void applyFontColor(ImageView image, Color color) { ColorAdjust monochrome = new ColorAdjust(); monochrome.setSaturation(-1.0); Effect colorInput = new ColorInput(0, 0, image.getImage().getWidth(), image.getImage().getHeight(), color); Blend blend = new Blend(BlendMode.MULTIPLY, new ImageInput(image.getImage()), colorInput); image.setClip(new ImageView(image.getImage())); image.setEffect(blend); image.setCache(true); }
/** * {@inheritDoc} */ @Override protected Collection<Decoration> createRequiredDecorations(Control target) { ImageView imageView = new ImageView(REQUIRED_IMAGE); // The following code will transform REQUIRED_IMAGE from red to blue. ColorAdjust adjust = new ColorAdjust(); adjust.setSaturation(-1); Blend bluemaker = new Blend(BlendMode.SRC_ATOP, adjust, new ColorInput(0, 0, imageView.getImage().getWidth(), imageView.getImage().getHeight(), Color.DEEPSKYBLUE)); imageView.setEffect(bluemaker); return Arrays.asList(new GraphicDecoration(imageView, Pos.TOP_LEFT, REQUIRED_IMAGE.getWidth() / 2, REQUIRED_IMAGE.getHeight() / 2)); }
/** * Given a monochrome image, apply a color to it * * @param imageView A view to the target monochrome image * @param color Target new image color */ public static void colorize(final ImageView imageView, final Paint color) { final ColorAdjust monochrome = new ColorAdjust(); monochrome.setSaturation(-1.0); monochrome.setBrightness(0.75); final Blend selectionColorBlend = new Blend(BlendMode.SRC_ATOP, monochrome, new ColorInput(0, 0, imageView.getFitWidth(), imageView.getFitHeight(), color)); imageView.setEffect(selectionColorBlend); }
private void mode_ADD(Group root,Rectangle r,Circle c){ Group child = new Group(); Text txt = new Text("ADD"); txt.setFill(Color.BLACK); child.getChildren().add(txt); child.getChildren().add(r); child.getChildren().add(c); child.setBlendMode(BlendMode.ADD); root.getChildren().add(child); }
private void mode_BLUE(Group root,Rectangle r,Circle c){ Group child = new Group(); Text txt = new Text("BLUE"); txt.setFill(Color.BLACK); child.getChildren().add(txt); child.getChildren().add(r); child.getChildren().add(c); child.setBlendMode(BlendMode.MULTIPLY); root.getChildren().add(child); }
/** * Retrieve an overlay image. * * @param overlayType * The overlay type. * @param side * The side of the eye. * @param color * The overlay color. * * @return The overlay image. */ private static Image getOverlayImage(final int overlayType, final RightLeft side, final Color color) { URL imageUrl = ClassLoader.getSystemResource("overlay/" + getOverlayFileName(overlayType, side)); Image image = new Image(imageUrl.toExternalForm()); Canvas canvas = new Canvas(OVERLAY_SIZE, OVERLAY_SIZE); Color colorNoAlpha = new Color(color.getRed(), color.getGreen(), color.getBlue(), 1); Blend effect = new Blend( BlendMode.SRC_ATOP, null, new ColorInput( 0, 0, OVERLAY_SIZE, OVERLAY_SIZE, colorNoAlpha)); // Type 2 is not changed in color. if (overlayType != 2) { canvas.getGraphicsContext2D().setEffect(effect); } canvas.getGraphicsContext2D().setGlobalAlpha(color.getOpacity()); canvas.getGraphicsContext2D().drawImage(image, 0, 0, OVERLAY_SIZE, OVERLAY_SIZE); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); return canvas.snapshot(parameters, null); }
public GeographicalFirmPortrait(final GeographicalFirm agent, Color firmColor, GoodType goodSold, MacroII model) { super(agent,agent.xLocationProperty(),agent.yLocationProperty()); color.setValue(firmColor); this.firm = agent; //add a glow effect Glow glow = new Glow(3); Blend blend = new Blend(BlendMode.SRC_OVER, glow,icon.effectProperty().getValue()); icon.setEffect(blend); //schedule yourself to update your text StackPane.setAlignment(priceText, Pos.CENTER); priceText.setFont(Font.font("Verdana", FontWeight.BOLD,10)); model.scheduleSoon(ActionOrder.GUI_PHASE,new Steppable() { @Override public void step(SimState state) { if(!active) return; long price = agent.getSalesDepartment(goodSold).getLastAskedPrice(); Platform.runLater(() -> priceText.setText(String.valueOf(price))); //reschedule model.scheduleTomorrow(ActionOrder.GUI_PHASE,this); } }); //register as deactivable with the model model.registerDeactivable(this); }
public SanFranciscoFireworks() { // create a color palette of 180 colors colors = new Paint[181]; colors[0] = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE, new Stop(0, Color.WHITE), new Stop(0.2, Color.hsb(59, 0.38, 1)), new Stop(0.6, Color.hsb(59, 0.38, 1,0.1)), new Stop(1, Color.hsb(59, 0.38, 1,0)) ); for (int h=0;h<360;h+=2) { colors[1+(h/2)] = new RadialGradient(0, 0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE, new Stop(0, Color.WHITE), new Stop(0.2, Color.hsb(h, 1, 1)), new Stop(0.6, Color.hsb(h, 1, 1,0.1)), new Stop(1, Color.hsb(h, 1, 1,0)) ); } // create canvas canvas = new Canvas(1024, 500); canvas.setBlendMode(BlendMode.ADD); canvas.setEffect(new Reflection(0,0.4,0.15,0)); background = new ImageView(getClass().getResource("sf.jpg").toExternalForm()); getChildren().addAll(background,canvas); // create animation timer that will be called every frame // final AnimationTimer timer = new AnimationTimer() { timer = new AnimationTimer() { @Override public void handle(long now) { GraphicsContext gc = canvas.getGraphicsContext2D(); // clear area with transparent black gc.setFill(Color.rgb(0, 0, 0, 0.2)); gc.fillRect(0, 0, 1024, 708); // draw fireworks drawFireworks(gc); // countdown to launching the next firework if (countDownTillNextFirework == 0) { countDownTillNextFirework = 10 + (int)(Math.random()*30); fireParticle(); } countDownTillNextFirework --; } }; }
public PropertyTimeline<String> blendModeProperty() { return blendMode.setIfEmptyThenGet(enumToString(BlendMode.class, node.blendModeProperty())); }
@Override public Node mkRoot() { Image image = new Image(LenaSample.LENA); GesturePane gesturePane = new GesturePane(new ImageView(image)); gesturePane.setMaxSize(image.getWidth(), image.getHeight()); ImageView background = new ImageView(LenaSample.LENA); background.setFitWidth(image.getWidth()); background.setFitHeight(image.getHeight()); Rectangle shade = new Rectangle(image.getWidth(), image.getHeight(), Color.grayRgb(0, 0.5)); Rectangle viewRect = new Rectangle(); viewRect.setStroke(Color.WHITE); viewRect.setStrokeWidth(2); viewRect.setFill(Color.WHITE); // shade * rect Group group = new Group(shade, viewRect); group.setBlendMode(BlendMode.MULTIPLY); Pane viewportSim = new Pane(background, group); viewportSim.maxWidthProperty().bind(background.fitWidthProperty()); viewportSim.maxHeightProperty().bind(background.fitHeightProperty()); gesturePane.targetViewportProperty().addListener((o, p, n) -> { viewRect.setTranslateX(n.getMinX()); viewRect.setTranslateY(n.getMinY()); viewRect.setWidth(n.getWidth()); viewRect.setHeight(n.getHeight()); }); HBox box = new HBox(gesturePane, viewportSim); box.setAlignment(Pos.CENTER); VBox.setVgrow(box, Priority.ALWAYS); Label description = new Label("Zoom and scroll on the left image(wrapped in a GesturePane)" + "; the right image will reflect the actual viewport " + "of the current transformation"); description.setWrapText(true); description.setPadding(new Insets(16)); return new VBox(description, box); }
public RectangleModel() { rectangle.setStrokeType(StrokeType.INSIDE); rectangle.setBlendMode(BlendMode.MULTIPLY); }
/** * @param control * @param behavior */ protected MacroBaseSkin(MacroControl control, BehaviorBase<MacroControl> behavior) { super(control, behavior); rootLayout = new BorderPane(); tbResult = new TableView<>(); tbResult.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); tbResult.getSelectionModel().setCellSelectionEnabled(true); // tbResult.addEventFilter(KeyEvent.KEY_RELEASED, // this::tbResultOnKeyReleased); textArea = new TextArea(); SplitPane splitPane = new SplitPane(textArea, tbResult); splitPane.setOrientation(Orientation.VERTICAL); rootLayout.setCenter(splitPane); Button btnStart = createStartButton(); Button btnStop = createStopButton(); btnStop.setDisable(true); btnStart.addEventHandler(ActionEvent.ACTION, this::btnStartOnAction); btnStop.addEventHandler(ActionEvent.ACTION, this::btnStopOnAction); Label label = new Label(" Delay Sec : "); NumberTextField numberTextField = new NumberTextField(String.valueOf(sleepSecond.get())); numberTextField.textProperty().addListener((oba, o, n) -> { int parseInt = 5; try { parseInt = Integer.parseInt(n); } catch (NumberFormatException e) { } if (0 <= parseInt && parseInt < 1001) { sleepSecond.getAndSet(parseInt); } else { DialogUtil.showMessageDialog("입력 제한 [1 ~ 1000]"); numberTextField.setText(o); return; } }); HBox buttonBox = new HBox(5, label, numberTextField, btnStart, btnStop); buttonBox.setId("btn-box"); buttonBox.setPadding(new Insets(5)); buttonBox.setAlignment(Pos.CENTER_RIGHT); rootLayout.setBottom(buttonBox); getChildren().add(this.rootLayout); isStarted.addListener((oba, o, n) -> { if (n) { btnStart.setDisable(true); btnStop.setDisable(false); textArea.setEditable(false); textArea.setBlendMode(BlendMode.DARKEN); } else { btnStart.setDisable(false); btnStop.setDisable(true); textArea.setEditable(true); textArea.setBlendMode(null); } }); isStarted.set(false); }
@Override public void initialize(URL url, ResourceBundle rb) { this.rb = rb; table.setRowFactory(new MonitoredEventRowFactory<MonitoredEvent>()); id.setCellValueFactory(p -> new ReadOnlyStringWrapper( String.format("%s (%s)", p.getValue().getSubscription().getSubscriptionId(), p.getValue().getMonitoredItem().getMonitoredItemId()))); mode.setCellValueFactory(p -> new ReadOnlyStringWrapper(p.getValue().getMonitoredItem().getMonitoringMode().toString())); variable.setCellValueFactory(p -> p.getValue().nameProperty()); value.setCellValueFactory(p -> p.getValue().valueProperty()); samplingrate.setCellValueFactory(p -> new ReadOnlyObjectWrapper<Double>(p.getValue().getSubscription().getRevisedPublishingInterval())); quality.setCellValueFactory(p -> new ReadOnlyStringWrapper(OpcUaConverter.toString(p.getValue().getMonitoredItem().getStatusCode()))); timestamp.setCellValueFactory(p -> p.getValue().timestampProperty()); lasterror.setCellValueFactory(p -> p.getValue().lasterrorProperty()); table.setItems(monitoredItems); table.setOnDragOver(event -> { event.acceptTransferModes(TransferMode.COPY); event.consume(); }); table.setOnDragEntered(event -> { if (event.getDragboard().hasString()) { table.setBlendMode(BlendMode.DARKEN); } }); table.setOnDragExited(event -> { if (event.getDragboard().hasString()) { table.setBlendMode(null); } }); table.setOnDragDropped(event -> { if (event.getDragboard().hasString()) { table.setBlendMode(null); event.acceptTransferModes(TransferMode.COPY); state.subscribeTreeItemList().add(state.selectedTreeItemProperty().get()); event.setDropCompleted(true); } }); table.setOnMousePressed(event -> { if (event.isPrimaryButtonDown() && event.getClickCount() == 2) { MonitoredEvent item = table.getSelectionModel().getSelectedItem(); if (item != null) { state.showAttributeItemProperty().set(item.getReferenceDescription()); } } }); state.subscribeTreeItemList().addListener((ListChangeListener.Change<? extends ReferenceDescription> c) -> { while (c.next()) { if (c.wasAdded()) { c.getAddedSubList().stream().forEach(this::subscribe); } } }); bindContextMenu(); state.connectedProperty().addListener((l, a, b) -> { if (b && !monitoredItems.isEmpty()) { List<ReferenceDescription> items = monitoredItems.stream().map(MonitoredEvent::getReferenceDescription).collect(Collectors.toList()); monitoredItems.clear(); subscribe(items); } }); }
slotBlendRectangleCircle(BlendMode _operation) { operation = _operation; }
@Override protected void initGame() { getGameScene().setBackgroundColor(Color.BLACK); e = ParticleEmitters.newSmokeEmitter(); e.setBlendMode(BlendMode.SRC_OVER); e.setSize(15, 30); e.setNumParticles(10); e.setEmissionRate(0.25); e.setStartColor(Color.color(0.6, 0.55, 0.5, 0.47)); e.setEndColor(Color.BLACK); e.setExpireFunction((i, x, y) -> Duration.seconds(16)); e.setVelocityFunction((i, x, y) -> new Point2D(FXGLMath.random() - 0.5, 0)); e.setAccelerationFunction(() -> new Point2D((FXGLMath.noise1D(7776 + getTick()) - 0.5) * 0.02, 0)); //e.setSpawnPointFunction((i, x, y) -> new Point2D(x + FXGLMath.noise1D(333 + getTick()) * 150 - 75, y + FXGLMath.noise1D(getTick()) * 150 - 75)); // Entities.builder() // .at(getWidth() / 2, getHeight() - 100) // .with(new ParticleControl(e), new RandomMoveControl(2)) // .buildAndAttach(getGameWorld()); emitter = ParticleEmitters.newFireEmitter(); emitter.setSize(5, 15); emitter.setVelocityFunction((i, x, y) -> new Point2D(FXGLMath.random() - 0.5, -FXGLMath.random() * 3)); emitter.setAccelerationFunction(() -> new Point2D(0, 0.05)); emitter.setExpireFunction((i, x, y) -> Duration.seconds(3)); emitter.setScaleFunction((i, x, y) -> new Point2D(FXGLMath.random(0, 0.01f), FXGLMath.random(-0.05f, 0.05f))); emitter.setStartColor(Color.YELLOW); emitter.setEndColor(Color.RED); //emitter.setBlendMode(BlendMode.SRC_OVER); //emitter.setSourceImage(getAssetLoader().loadTexture("particleTexture2.png").toColor(Color.rgb(230, 75, 40)).getImage()); entity = Entities.builder() .at(getWidth() / 2, getHeight() / 2) .with(new ParticleControl(emitter)) .buildAndAttach(getGameWorld()); Entities.builder() .at(250, 250) .viewFromNode(new Rectangle(40, 40, Color.BLUE)) .with(new CircularMovementControl(10, 25)) .buildAndAttach(getGameWorld()); }
public final BlendMode getBlendMode() { return blendMode.get(); }