Java Code Examples for javafx.scene.effect.Blend#setBottomInput()
The following examples show how to use
javafx.scene.effect.Blend#setBottomInput() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeometryNodeSnippet.java From gef with Eclipse Public License 2.0 | 6 votes |
protected static Effect createShadowEffect() { final DropShadow outerShadow = new DropShadow(); outerShadow.setRadius(3); outerShadow.setSpread(0.2); outerShadow.setOffsetX(3); outerShadow.setOffsetY(3); outerShadow.setColor(new Color(0.3, 0.3, 0.3, 1)); final Distant light = new Distant(); light.setAzimuth(-135.0f); final Lighting l = new Lighting(); l.setLight(light); l.setSurfaceScale(3.0f); final Blend effects = new Blend(BlendMode.MULTIPLY); effects.setTopInput(l); effects.setBottomInput(outerShadow); return effects; }
Example 2
Source File: MvcLogoExample.java From gef with Eclipse Public License 2.0 | 6 votes |
private static Effect createShadowEffect() { DropShadow outerShadow = new DropShadow(); outerShadow.setRadius(3); outerShadow.setSpread(0.2); outerShadow.setOffsetX(3); outerShadow.setOffsetY(3); outerShadow.setColor(new Color(0.3, 0.3, 0.3, 1)); Distant light = new Distant(); light.setAzimuth(-135.0f); Lighting l = new Lighting(); l.setLight(light); l.setSurfaceScale(3.0f); Blend effects = new Blend(BlendMode.MULTIPLY); effects.setTopInput(l); effects.setBottomInput(outerShadow); return effects; }
Example 3
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 5 votes |
public static Image addTextFx(Image image, String textString, Font font, Color color, int x, int y, float transparent, int shadow) { try { Group group = new Group(); Text text = new Text(x, y, textString); text.setFill(color); text.setFont(font); if (shadow > 0) { DropShadow dropShadow = new DropShadow(); dropShadow.setOffsetX(shadow); dropShadow.setOffsetY(shadow); text.setEffect(dropShadow); } group.getChildren().add(text); Blend blend = new Blend(BlendMode.SRC_OVER); blend.setBottomInput(new ImageInput(image)); blend.setOpacity(1.0 - transparent); group.setEffect(blend); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); WritableImage newImage = group.snapshot(parameters, null); return newImage; } catch (Exception e) { logger.error(e.toString()); return null; } }
Example 4
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 5 votes |
public static Image addArcFx(Image image, int arc, Color bgColor) { try { if (image == null || arc <= 0) { return null; } Group group = new Group(); double imageWidth = image.getWidth(), imageHeight = image.getHeight(); Scene scene = new Scene(group); ImageView view = new ImageView(image); view.setPreserveRatio(true); view.setFitWidth(imageWidth); view.setFitHeight(imageHeight); Rectangle clip = new Rectangle(imageWidth, imageHeight); clip.setArcWidth(arc); clip.setArcHeight(arc); view.setClip(clip); group.getChildren().add(view); Blend blend = new Blend(BlendMode.SRC_OVER); blend.setBottomInput(new ColorInput(0, 0, imageWidth, imageHeight, bgColor)); group.setEffect(blend); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); WritableImage newImage = group.snapshot(parameters, null); return newImage; } catch (Exception e) { // logger.error(e.toString()); return null; } }
Example 5
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 4 votes |
public static Image indicateSplitFx(Image image, List<Integer> rows, List<Integer> cols, Color lineColor, int lineWidth, boolean showSize) { try { if (rows == null || cols == null) { return image; } Group group = new Group(); int width = (int) image.getWidth(); int height = (int) image.getHeight(); int row; for (int i = 0; i < rows.size(); ++i) { row = rows.get(i); if (row <= 0 || row >= height - 1) { continue; } Line rowLine = new Line(0, row, width, row); rowLine.setStroke(lineColor); rowLine.setStrokeWidth(lineWidth); group.getChildren().add(rowLine); } int col; for (int i = 0; i < cols.size(); ++i) { col = cols.get(i); if (col <= 0 || col >= width - 1) { continue; } Line colLine = new Line(col, 0, col, height); colLine.setStroke(lineColor); colLine.setStrokeWidth(lineWidth); group.getChildren().add(colLine); } if (showSize) { for (int i = 0; i < rows.size() - 1; ++i) { int h = rows.get(i + 1) - rows.get(i) + 1; for (int j = 0; j < cols.size() - 1; ++j) { int w = cols.get(j + 1) - cols.get(j) + 1; Text text = new Text(); text.setX(cols.get(j) + w / 3); text.setY(rows.get(i) + h / 3); text.setFill(lineColor); text.setText(w + "x" + h); text.setFont(new javafx.scene.text.Font(lineWidth * 3.0)); group.getChildren().add(text); } } } Blend blend = new Blend(BlendMode.SRC_OVER); blend.setBottomInput(new ImageInput(image)); group.setEffect(blend); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); WritableImage newImage = group.snapshot(parameters, null); return newImage; } catch (Exception e) { // logger.error(e.toString()); return null; } }
Example 6
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 4 votes |
public static Image combineImagesColumnFx(List<Image> images, Color bgColor, int interval, int Margin) { try { if (images == null || images.isEmpty()) { return null; } Group group = new Group(); int x = Margin, y = Margin, width = 0, height = 0; for (int i = 0; i < images.size(); ++i) { Image image = images.get(i); ImageView view = new ImageView(image); view.setPreserveRatio(true); view.setFitWidth(image.getWidth()); view.setFitHeight(image.getHeight()); view.setX(x); view.setY(y); group.getChildren().add(view); x = Margin; y += image.getHeight() + interval; if (image.getWidth() > width) { width = (int) image.getWidth(); } } width += 2 * Margin; height = y + Margin - interval; Blend blend = new Blend(BlendMode.SRC_OVER); blend.setBottomInput(new ColorInput(0, 0, width, height, bgColor)); group.setEffect(blend); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); WritableImage newImage = group.snapshot(parameters, null); return newImage; } catch (Exception e) { logger.error(e.toString()); return null; } }
Example 7
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 4 votes |
public static Image combineSingleColumnFx(List<Image> images) { if (images == null || images.isEmpty()) { return null; } try { Group group = new Group(); double x = 0, y = 0, imageWidth, imageHeight; double totalWidth = 0, totalHeight = 0; for (Image theImage : images) { ImageView view = new ImageView(theImage); imageWidth = theImage.getWidth(); imageHeight = theImage.getHeight(); view.setPreserveRatio(true); view.setX(x); view.setY(y); view.setFitWidth(imageWidth); view.setFitHeight(imageHeight); group.getChildren().add(view); y += imageHeight; if (imageWidth > totalWidth) { totalWidth = imageWidth; } } totalHeight = y; Blend blend = new Blend(BlendMode.SRC_OVER); blend.setBottomInput(new ColorInput(0, 0, totalWidth, totalHeight, Color.TRANSPARENT)); group.setEffect(blend); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); WritableImage newImage = group.snapshot(parameters, null); return newImage; } catch (Exception e) { logger.error(e.toString()); return null; } }
Example 8
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 4 votes |
public static Image addMarginsFx2(Image image, Color color, int MarginWidth, boolean addTop, boolean addBottom, boolean addLeft, boolean addRight) { try { if (image == null || MarginWidth <= 0) { return image; } Group group = new Group(); double imageWidth = image.getWidth(), imageHeight = image.getHeight(); double totalWidth = image.getWidth(), totalHeight = image.getHeight(); ImageView view = new ImageView(image); view.setPreserveRatio(true); view.setFitWidth(imageWidth); view.setFitHeight(imageHeight); if (addLeft) { view.setX(MarginWidth); totalWidth += MarginWidth; } else { view.setX(0); } if (addTop) { view.setY(MarginWidth); totalHeight += MarginWidth; } else { view.setY(0); } if (addBottom) { totalHeight += MarginWidth; } if (addRight) { totalWidth += MarginWidth; } group.getChildren().add(view); Blend blend = new Blend(BlendMode.SRC_OVER); blend.setBottomInput(new ColorInput(0, 0, totalWidth, totalHeight, color)); group.setEffect(blend); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); WritableImage newImage = group.snapshot(parameters, null); return newImage; } catch (Exception e) { logger.error(e.toString()); return image; } }
Example 9
Source File: MainScene.java From mars-sim with GNU General Public License v3.0 | 4 votes |
public void createBlend() { blend = new Blend(); blend.setMode(BlendMode.MULTIPLY); DropShadow ds = new DropShadow(); ds.setColor(Color.rgb(254, 235, 66, 0.3)); ds.setOffsetX(5); ds.setOffsetY(5); ds.setRadius(5); ds.setSpread(0.2); blend.setBottomInput(ds); DropShadow ds1 = new DropShadow(); ds1.setColor(Color.web("#d68268")); // #d68268 is pinkish orange//f13a00")); ds1.setRadius(20); ds1.setSpread(0.2); Blend blend2 = new Blend(); blend2.setMode(BlendMode.MULTIPLY); InnerShadow is = new InnerShadow(); is.setColor(Color.web("#feeb42")); // #feeb42 is mid-pale yellow is.setRadius(9); is.setChoke(0.8); blend2.setBottomInput(is); InnerShadow is1 = new InnerShadow(); is1.setColor(Color.web("#278206")); // # f13a00 is bright red // 278206 is dark green is1.setRadius(5); is1.setChoke(0.4); blend2.setTopInput(is1); Blend blend1 = new Blend(); blend1.setMode(BlendMode.MULTIPLY); blend1.setBottomInput(ds1); blend1.setTopInput(blend2); blend.setTopInput(blend1); }