Java Code Examples for javafx.scene.canvas.GraphicsContext#fill()

The following examples show how to use javafx.scene.canvas.GraphicsContext#fill() . 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: Path.java    From charts with Apache License 2.0 6 votes vote down vote up
public void draw(final GraphicsContext CTX, final boolean FILL, final boolean STROKE) {
    PathIterator pi = getPathIterator(new Affine());

    CTX.setFillRule(WindingRule.WIND_EVEN_ODD == pi.getWindingRule() ? FillRule.EVEN_ODD : FillRule.NON_ZERO);
    CTX.beginPath();

    double[] seg = new double[6];
    int      segType;

    while(!pi.isDone()) {
        segType = pi.currentSegment(seg);
        switch (segType) {
            case PathIterator.MOVE_TO  : CTX.moveTo(seg[0], seg[1]); break;
            case PathIterator.LINE_TO  : CTX.lineTo(seg[0], seg[1]); break;
            case PathIterator.QUAD_TO  : CTX.quadraticCurveTo(seg[0], seg[1], seg[2], seg[3]);break;
            case PathIterator.BEZIER_TO: CTX.bezierCurveTo(seg[0], seg[1], seg[2], seg[3], seg[4], seg[5]);break;
            case PathIterator.CLOSE    : CTX.closePath();break;
            default                    : break;
        }
        pi.next();
    }

    if (FILL)   { CTX.setFill(fill); CTX.fill(); }
    if (STROKE) { CTX.setStroke(stroke); CTX.stroke(); }
}
 
Example 2
Source File: ToolGraphics.java    From JetUML with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Strokes and fills a path, by converting the elements to integer coordinates and then
 * aligning them to the center of the pixels, so that it aligns precisely
 * with the JavaFX coordinate system. See the documentation for 
 * javafx.scene.shape.Shape for details.
 * 
 * @param pGraphics The graphics context.
 * @param pPath The path to stroke
 * @param pFill The fill color for the path.
 * @param pShadow True to include a drop shadow.
 */
public static void strokeAndFillSharpPath(GraphicsContext pGraphics, Path pPath, Paint pFill, boolean pShadow)
{
	double width = pGraphics.getLineWidth();
	Paint fill = pGraphics.getFill();
	pGraphics.setLineWidth(LINE_WIDTH);
	pGraphics.setFill(pFill);
	applyPath(pGraphics, pPath);
	
	if( pShadow )
	{
		pGraphics.setEffect(DROP_SHADOW);
	}
	pGraphics.fill();
	pGraphics.stroke();
	pGraphics.setLineWidth(width);
	pGraphics.setFill(fill);
	pGraphics.setEffect(null);
}
 
Example 3
Source File: NotGatePeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paintGate(GraphicsContext graphics, CircuitState circuitState) {
	int x = getScreenX();
	int y = getScreenY();
	int width = 3 * GuiUtils.BLOCK_SIZE;
	int height = 2 * GuiUtils.BLOCK_SIZE;
	
	graphics.beginPath();
	graphics.moveTo(x, y);
	graphics.lineTo(x, y + height);
	graphics.lineTo(x + width * 0.7, y + height * 0.5);
	graphics.closePath();
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	graphics.fill();
	graphics.stroke();
	
	graphics.fillOval(x + width * 0.7, y + height * 0.5 - width * 0.125, width * 0.25, width * 0.25);
	graphics.strokeOval(x + width * 0.7, y + height * 0.5 - width * 0.125, width * 0.25, width * 0.25);
}
 
Example 4
Source File: NorGatePeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paintGate(GraphicsContext graphics, CircuitState circuitState) {
	int x = getScreenX();
	int y = getScreenY();
	int width = 4 * GuiUtils.BLOCK_SIZE;
	int height = 4 * GuiUtils.BLOCK_SIZE;
	
	graphics.beginPath();
	graphics.moveTo(x, y + height);
	graphics.arc(x, y + height * 0.5, width * 0.25, height * 0.5, 270, 180);
	graphics.arcTo(x + width * 0.66, y, x + width, y + height * 1.3, width * 0.7);
	graphics.arcTo(x + width * 0.66, y + height, x, y + height, width * 0.7);
	graphics.closePath();
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	graphics.fill();
	graphics.stroke();
	
	graphics.fillOval(x + width * 0.8, y + height * 0.5 - width * 0.1, width * 0.2, width * 0.2);
	graphics.strokeOval(x + width * 0.8, y + height * 0.5 - width * 0.1, width * 0.2, width * 0.2);
}
 
Example 5
Source File: XorGatePeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paintGate(GraphicsContext graphics, CircuitState circuitState) {
	int x = getScreenX();
	int y = getScreenY();
	int width = 4 * GuiUtils.BLOCK_SIZE;
	int height = 4 * GuiUtils.BLOCK_SIZE;
	
	graphics.beginPath();
	graphics.moveTo(x + width * 0.1, y + height);
	graphics.arc(x + width * 0.1, y + height * 0.5, width * 0.25, height * 0.5, 270, 180);
	graphics.arcTo(x + width * 0.66, y, x + width * 1.25, y + height, width);
	graphics.arcTo(x + width * 0.66, y + height, x + width * 0.1, y + height, width);
	graphics.closePath();
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	graphics.fill();
	graphics.stroke();
	
	graphics.strokeArc(x - width * 0.3, y, width * 0.5, height, 270, 180, ArcType.OPEN);
}
 
Example 6
Source File: OrGatePeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paintGate(GraphicsContext graphics, CircuitState circuitState) {
	int x = getScreenX();
	int y = getScreenY();
	int width = 4 * GuiUtils.BLOCK_SIZE;
	int height = 4 * GuiUtils.BLOCK_SIZE;
	
	graphics.beginPath();
	graphics.moveTo(x, y + height);
	graphics.arc(x, y + height * 0.5, width * 0.25, height * 0.5, 270, 180);
	graphics.arcTo(x + width * 0.66, y, x + width * 1.25, y + height, width);
	graphics.arcTo(x + width * 0.66, y + height, x, y + height, width);
	graphics.closePath();
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	graphics.fill();
	graphics.stroke();
}
 
Example 7
Source File: NandGatePeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paintGate(GraphicsContext graphics, CircuitState circuitState) {
	int x = getScreenX();
	int y = getScreenY();
	int width = 4 * GuiUtils.BLOCK_SIZE;
	int height = 4 * GuiUtils.BLOCK_SIZE;
	
	graphics.beginPath();
	graphics.moveTo(x, y);
	graphics.lineTo(x, y + height);
	graphics.arc(x + width * 0.3, y + height * 0.5, width * 0.5, height * 0.5, 270, 180);
	graphics.closePath();
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	graphics.fill();
	graphics.stroke();
	
	graphics.fillOval(x + width * 0.8, y + height * 0.5 - width * 0.1, width * 0.2, width * 0.2);
	graphics.strokeOval(x + width * 0.8, y + height * 0.5 - width * 0.1, width * 0.2, width * 0.2);
}
 
Example 8
Source File: AndGatePeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paintGate(GraphicsContext graphics, CircuitState circuitState) {
	int x = getScreenX();
	int y = getScreenY();
	int width = 4 * GuiUtils.BLOCK_SIZE;
	int height = 4 * GuiUtils.BLOCK_SIZE;
	
	graphics.beginPath();
	graphics.moveTo(x, y);
	graphics.lineTo(x, y + height);
	graphics.arc(x + width * 0.5, y + height * 0.5, width * 0.5, height * 0.5, 270, 180);
	graphics.closePath();
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	graphics.fill();
	graphics.stroke();
}
 
Example 9
Source File: XnorGatePeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paintGate(GraphicsContext graphics, CircuitState circuitState) {
	int x = getScreenX();
	int y = getScreenY();
	int width = 4 * GuiUtils.BLOCK_SIZE;
	int height = 4 * GuiUtils.BLOCK_SIZE;
	
	graphics.beginPath();
	graphics.moveTo(x + width * 0.1, y + height);
	graphics.arc(x + width * 0.1, y + height * 0.5, width * 0.25, height * 0.5, 270, 180);
	graphics.arcTo(x + width * 0.66, y, x + width, y + height * 1.3, width * 0.7);
	graphics.arcTo(x + width * 0.66, y + height, x + width * 0.1, y + height, width * 0.7);
	graphics.closePath();
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	graphics.fill();
	graphics.stroke();
	
	graphics.strokeArc(x - width * 0.3, y, width * 0.5, height, 270, 180, ArcType.OPEN);
	
	graphics.fillOval(x + width * 0.8, y + height * 0.5 - width * 0.1, width * 0.2, width * 0.2);
	graphics.strokeOval(x + width * 0.8, y + height * 0.5 - width * 0.1, width * 0.2, width * 0.2);
}
 
Example 10
Source File: ControlledBufferPeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paint(GraphicsContext graphics, CircuitState circuitState) {
	GuiUtils.drawName(graphics, this, getProperties().getValue(Properties.LABEL_LOCATION));
	GuiUtils.rotateGraphics(this, graphics, getProperties().getValue(Properties.DIRECTION));
	
	graphics.beginPath();
	graphics.moveTo(getScreenX(), getScreenY());
	graphics.lineTo(getScreenX() + getScreenWidth(), getScreenY() + getScreenHeight() * 0.5);
	graphics.lineTo(getScreenX(), getScreenY() + getScreenHeight());
	graphics.closePath();
	
	graphics.setFill(Color.WHITE);
	graphics.fill();
	graphics.setStroke(Color.BLACK);
	graphics.stroke();
}
 
Example 11
Source File: RoundLcdClock.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private void drawAlarmIcon(final GraphicsContext CTX, final Paint COLOR) {
    double iconSize = 0.1 * size;
    CTX.save();
    CTX.translate((size - iconSize) * 0.5, size * 0.25);
    CTX.beginPath();
    CTX.moveTo(0.6875 * iconSize, 0.875 * iconSize);
    CTX.bezierCurveTo(0.625 * iconSize, 0.9375 * iconSize, 0.5625 * iconSize, iconSize, 0.5 * iconSize, iconSize);
    CTX.bezierCurveTo(0.4375 * iconSize, iconSize, 0.375 * iconSize, 0.9375 * iconSize, 0.375 * iconSize, 0.875 * iconSize);
    CTX.bezierCurveTo(0.375 * iconSize, 0.875 * iconSize, 0.6875 * iconSize, 0.875 * iconSize, 0.6875 * iconSize, 0.875 * iconSize);
    CTX.closePath();
    CTX.moveTo(iconSize, 0.8125 * iconSize);
    CTX.bezierCurveTo(0.6875 * iconSize, 0.5625 * iconSize, 0.9375 * iconSize, 0.0, 0.5 * iconSize, 0.0);
    CTX.bezierCurveTo(0.5 * iconSize, 0.0, 0.5 * iconSize, 0.0, 0.5 * iconSize, 0.0);
    CTX.bezierCurveTo(0.5 * iconSize, 0.0, 0.5 * iconSize, 0.0, 0.5 * iconSize, 0.0);
    CTX.bezierCurveTo(0.125 * iconSize, 0.0, 0.375 * iconSize, 0.5625 * iconSize, 0.0, 0.8125 * iconSize);
    CTX.bezierCurveTo(0.0, 0.8125 * iconSize, 0.0, 0.8125 * iconSize, 0.0, 0.8125 * iconSize);
    CTX.bezierCurveTo(0.0, 0.8125 * iconSize, 0.0, 0.8125 * iconSize, 0.0, 0.8125 * iconSize);
    CTX.bezierCurveTo(0.0, 0.8125 * iconSize, 0.0, 0.8125 * iconSize, 0.0625 * iconSize, 0.8125 * iconSize);
    CTX.bezierCurveTo(0.0625 * iconSize, 0.8125 * iconSize, 0.5 * iconSize, 0.8125 * iconSize, 0.5 * iconSize, 0.8125 * iconSize);
    CTX.bezierCurveTo(0.5 * iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize);
    CTX.bezierCurveTo(iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize);
    CTX.bezierCurveTo(iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize);
    CTX.bezierCurveTo(iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize);
    CTX.closePath();
    CTX.setFill(COLOR);
    CTX.fill();
    CTX.restore();    
}
 
Example 12
Source File: Helper.java    From Medusa with Apache License 2.0 5 votes vote down vote up
public static final void drawTriangle(final GraphicsContext CTX,
                                      final double PIX, final double PIY, final double PO1X, final double PO1Y, final double PO2X, final double PO2Y) {
    CTX.beginPath();
    CTX.moveTo(PIX, PIY);
    CTX.lineTo(PO1X, PO1Y);
    CTX.lineTo(PO2X, PO2Y);
    CTX.closePath();
    CTX.fill();
}
 
Example 13
Source File: Helper.java    From Medusa with Apache License 2.0 5 votes vote down vote up
public static final void drawTrapezoid(final GraphicsContext CTX,
                                       final double PI1X, final double PI1Y, final double PI2X, final double PI2Y,
                                       final double PO1X, final double PO1Y, final double PO2X, final double PO2Y) {
    CTX.beginPath();
    CTX.moveTo(PI2X, PI2Y);
    CTX.lineTo(PI1X, PI1Y);
    CTX.lineTo(PO1X, PO1Y);
    CTX.lineTo(PO2X, PO2Y);
    CTX.closePath();
    CTX.fill();
}
 
Example 14
Source File: RoundLcdClockSkin.java    From Medusa with Apache License 2.0 5 votes vote down vote up
private void drawAlarmIcon(final GraphicsContext CTX, final Paint COLOR) {
    double iconSize = 0.1 * size;
    CTX.save();
    CTX.translate((size - iconSize) * 0.5, size * 0.25);
    CTX.beginPath();
    CTX.moveTo(0.6875 * iconSize, 0.875 * iconSize);
    CTX.bezierCurveTo(0.625 * iconSize, 0.9375 * iconSize, 0.5625 * iconSize, iconSize, 0.5 * iconSize, iconSize);
    CTX.bezierCurveTo(0.4375 * iconSize, iconSize, 0.375 * iconSize, 0.9375 * iconSize, 0.375 * iconSize, 0.875 * iconSize);
    CTX.bezierCurveTo(0.375 * iconSize, 0.875 * iconSize, 0.6875 * iconSize, 0.875 * iconSize, 0.6875 * iconSize, 0.875 * iconSize);
    CTX.closePath();
    CTX.moveTo(iconSize, 0.8125 * iconSize);
    CTX.bezierCurveTo(0.6875 * iconSize, 0.5625 * iconSize, 0.9375 * iconSize, 0.0, 0.5 * iconSize, 0.0);
    CTX.bezierCurveTo(0.5 * iconSize, 0.0, 0.5 * iconSize, 0.0, 0.5 * iconSize, 0.0);
    CTX.bezierCurveTo(0.5 * iconSize, 0.0, 0.5 * iconSize, 0.0, 0.5 * iconSize, 0.0);
    CTX.bezierCurveTo(0.125 * iconSize, 0.0, 0.375 * iconSize, 0.5625 * iconSize, 0.0, 0.8125 * iconSize);
    CTX.bezierCurveTo(0.0, 0.8125 * iconSize, 0.0, 0.8125 * iconSize, 0.0, 0.8125 * iconSize);
    CTX.bezierCurveTo(0.0, 0.8125 * iconSize, 0.0, 0.8125 * iconSize, 0.0, 0.8125 * iconSize);
    CTX.bezierCurveTo(0.0, 0.8125 * iconSize, 0.0, 0.8125 * iconSize, 0.0625 * iconSize, 0.8125 * iconSize);
    CTX.bezierCurveTo(0.0625 * iconSize, 0.8125 * iconSize, 0.5 * iconSize, 0.8125 * iconSize, 0.5 * iconSize, 0.8125 * iconSize);
    CTX.bezierCurveTo(0.5 * iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize);
    CTX.bezierCurveTo(iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize);
    CTX.bezierCurveTo(iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize);
    CTX.bezierCurveTo(iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize, iconSize, 0.8125 * iconSize);
    CTX.closePath();
    CTX.setFill(COLOR);
    CTX.fill();
    CTX.restore();
}
 
Example 15
Source File: DecoderPeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void paint(GraphicsContext graphics, CircuitState circuitState) {
	GuiUtils.drawName(graphics, this, getProperties().getValue(Properties.LABEL_LOCATION));
	Direction direction = getProperties().getValue(Properties.DIRECTION);
	
	int x = getScreenX();
	int y = getScreenY();
	int width = 3 * GuiUtils.BLOCK_SIZE;
	int height = (getComponent().getNumOutputs() + 2) * GuiUtils.BLOCK_SIZE;
	
	int zeroXOffset = 0;
	
	switch(direction) {
		case SOUTH:
			graphics.translate(x, y);
			graphics.rotate(270);
			graphics.translate(-x - width, -y);
		case WEST:
			zeroXOffset = 2;
			graphics.beginPath();
			graphics.moveTo(x, y);
			graphics.lineTo(x + width, y + Math.min(20, height * 0.2));
			graphics.lineTo(x + width, y + height - Math.min(20, height * 0.2));
			graphics.lineTo(x, y + height);
			graphics.closePath();
			break;
		case NORTH:
			graphics.translate(x, y);
			graphics.rotate(270);
			graphics.translate(-x - width, -y);
		case EAST:
			zeroXOffset = width - 10;
			graphics.beginPath();
			graphics.moveTo(x + width, y);
			graphics.lineTo(x, y + Math.min(20, height * 0.2));
			graphics.lineTo(x, y + height - Math.min(20, height * 0.2));
			graphics.lineTo(x + width, y + height);
			graphics.closePath();
			break;
	}
	
	graphics.setFill(Color.WHITE);
	graphics.fill();
	graphics.setStroke(Color.BLACK);
	graphics.stroke();
	
	graphics.setFill(Color.DARKGRAY);
	graphics.fillText("0", x + zeroXOffset, y + 13);
}
 
Example 16
Source File: DemultiplexerPeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void paint(GraphicsContext graphics, CircuitState circuitState) {
	GuiUtils.drawName(graphics, this, getProperties().getValue(Properties.LABEL_LOCATION));
	Direction direction = getProperties().getValue(Properties.DIRECTION);
	
	int x = getScreenX();
	int y = getScreenY();
	int width = 3 * GuiUtils.BLOCK_SIZE;
	int height = (getComponent().getNumOutputs() + 2) * GuiUtils.BLOCK_SIZE;
	
	int zeroXOffset = 0;
	
	switch(direction) {
		case SOUTH:
			graphics.translate(x, y);
			graphics.rotate(270);
			graphics.translate(-x - width, -y);
		case WEST:
			zeroXOffset = 2;
			graphics.beginPath();
			graphics.moveTo(x, y);
			graphics.lineTo(x + width, y + Math.min(20, height * 0.2));
			graphics.lineTo(x + width, y + height - Math.min(20, height * 0.2));
			graphics.lineTo(x, y + height);
			graphics.closePath();
			break;
		case NORTH:
			graphics.translate(x, y);
			graphics.rotate(270);
			graphics.translate(-x - width, -y);
		case EAST:
			zeroXOffset = width - 10;
			graphics.beginPath();
			graphics.moveTo(x + width, y);
			graphics.lineTo(x, y + Math.min(20, height * 0.2));
			graphics.lineTo(x, y + height - Math.min(20, height * 0.2));
			graphics.lineTo(x + width, y + height);
			graphics.closePath();
			break;
	}
	
	graphics.setFill(Color.WHITE);
	graphics.fill();
	graphics.setStroke(Color.BLACK);
	graphics.stroke();
	
	graphics.setFill(Color.DARKGRAY);
	graphics.fillText("0", x + zeroXOffset, y + 13);
}
 
Example 17
Source File: MultiplexerPeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void paint(GraphicsContext graphics, CircuitState circuitState) {
	GuiUtils.drawName(graphics, this, getProperties().getValue(Properties.LABEL_LOCATION));
	
	Direction direction = getProperties().getValue(Properties.DIRECTION);
	
	int x = getScreenX();
	int y = getScreenY();
	int width = 3 * GuiUtils.BLOCK_SIZE;
	int height = (getComponent().getNumInputs() + 2) * GuiUtils.BLOCK_SIZE;
	
	int zeroXOffset = 0;
	
	switch(direction) {
		case NORTH:
			graphics.translate(x, y);
			graphics.rotate(270);
			graphics.translate(-x - width, -y);
		case EAST:
			zeroXOffset = 2;
			graphics.beginPath();
			graphics.moveTo(x, y);
			graphics.lineTo(x + width, y + Math.min(20, height * 0.2));
			graphics.lineTo(x + width, y + height - Math.min(20, height * 0.2));
			graphics.lineTo(x, y + height);
			graphics.closePath();
			break;
		case SOUTH:
			graphics.translate(x, y);
			graphics.rotate(270);
			graphics.translate(-x - width, -y);
		case WEST:
			zeroXOffset = width - 10;
			graphics.beginPath();
			graphics.moveTo(x + width, y);
			graphics.lineTo(x, y + Math.min(20, height * 0.2));
			graphics.lineTo(x, y + height - Math.min(20, height * 0.2));
			graphics.lineTo(x + width, y + height);
			graphics.closePath();
			break;
	}
	
	graphics.setFill(Color.WHITE);
	graphics.fill();
	graphics.setStroke(Color.BLACK);
	graphics.stroke();
	
	graphics.setFill(Color.DARKGRAY);
	graphics.fillText("0", x + zeroXOffset, y + 13);
}
 
Example 18
Source File: Patterns.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
public static final ImagePattern createCarbonPattern() {
    final double WIDTH = 12;
    final double HEIGHT = 12;
    final Canvas CANVAS = new Canvas(WIDTH, HEIGHT);
    final GraphicsContext CTX = CANVAS.getGraphicsContext2D();

    double offsetY = 0;

    CTX.beginPath();
    CTX.rect(0, 0, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();

    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(35, 35, 35)),
            new Stop(1, Color.rgb(23, 23, 23))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.083333, 0, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(38, 38, 38)),
            new Stop(1, Color.rgb(30, 30, 30))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.5, HEIGHT * 0.5, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(35, 35, 35)),
            new Stop(1, Color.rgb(23, 23, 23))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.583333, HEIGHT * 0.5, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(38, 38, 38)),
            new Stop(1, Color.rgb(30, 30, 30))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.5, 0, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(48, 48, 48)),
            new Stop(1, Color.rgb(40, 40, 40))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.583333, HEIGHT * 0.083333, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.083333;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(53, 53, 53)),
            new Stop(1, Color.rgb(45, 45, 45))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(0, HEIGHT * 0.5, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(48, 48, 48)),
            new Stop(1, Color.rgb(40, 40, 40))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.083333, HEIGHT * 0.583333, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.583333;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(53, 53, 53)),
            new Stop(1, Color.rgb(45, 45, 45))));
    CTX.fill();

    final Image PATTERN_IMAGE = CANVAS.snapshot(new SnapshotParameters(), null);
    final ImagePattern PATTERN = new ImagePattern(PATTERN_IMAGE, 0, 0, WIDTH, HEIGHT, false);

    return PATTERN;
}
 
Example 19
Source File: Patterns.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
public static final ImagePattern createLightCarbonPattern() {
    final double WIDTH = 12;
    final double HEIGHT = 12;
    final Canvas CANVAS = new Canvas(WIDTH, HEIGHT);
    final GraphicsContext CTX = CANVAS.getGraphicsContext2D();

    double offsetY = 0;

    CTX.beginPath();
    CTX.rect(0, 0, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();

    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(108, 108, 108)),
            new Stop(1, Color.rgb(100, 100, 100))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.083333, 0, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(142, 142, 142)),
            new Stop(1, Color.rgb(130, 130, 130))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.5, HEIGHT * 0.5, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(108, 108, 108)),
            new Stop(1, Color.rgb(100, 100, 100))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.583333, HEIGHT * 0.5, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(142, 142, 142)),
            new Stop(1, Color.rgb(130, 130, 130))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.5, 0, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(152, 152, 152)),
            new Stop(1, Color.rgb(146, 146, 146))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.583333, HEIGHT * 0.083333, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.083333;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(160, 160, 160)),
            new Stop(1, Color.rgb(152, 152, 152))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(0, HEIGHT * 0.5, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(152, 152, 152)),
            new Stop(1, Color.rgb(146, 146, 146))));
    CTX.fill();

    CTX.beginPath();
    CTX.rect(WIDTH * 0.083333, HEIGHT * 0.583333, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.583333;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(160, 160, 160)),
            new Stop(1, Color.rgb(152, 152, 152))));
    CTX.fill();

    final Image PATTERN_IMAGE = CANVAS.snapshot(new SnapshotParameters(), null);
    final ImagePattern PATTERN = new ImagePattern(PATTERN_IMAGE, 0, 0, WIDTH, HEIGHT, false);

    return PATTERN;
}
 
Example 20
Source File: Patterns.java    From FXyzLib with GNU General Public License v3.0 4 votes vote down vote up
public static final ImagePattern createCarbonKevlarPattern() {
    final double WIDTH = 12;
    final double HEIGHT = 12;
    final Canvas CANVAS = new Canvas(WIDTH, HEIGHT);
    final GraphicsContext CTX = CANVAS.getGraphicsContext2D();

    double offsetY = 0;
    /// 1= border=yellow=dark========================================================
    CTX.beginPath();
    CTX.rect(0, 0, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();

    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(105, 105, 0)),
            new Stop(1, Color.rgb(98, 98, 0))));
    CTX.fill();
    //  2=body=yellow==============================
    CTX.beginPath();
    CTX.rect(WIDTH * 0.083333, 0, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(138, 138, 0)),
            new Stop(1, Color.rgb(130, 130, 0))));
    CTX.fill();
    //  3=border=yellow=dark=============================
    CTX.beginPath();
    CTX.rect(WIDTH * 0.5, HEIGHT * 0.5, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(105, 105, 0)),
            new Stop(1, Color.rgb(98, 98, 0))));
    CTX.fill();
    //  4=body=yellow============================================================
    CTX.beginPath();
    CTX.rect(WIDTH * 0.583333, HEIGHT * 0.5, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(138, 138, 0)),
            new Stop(1, Color.rgb(130, 130, 0))));
    CTX.fill();
    //  5= border=gray=dark============================
    CTX.beginPath();
    CTX.rect(WIDTH * 0.5, 0, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(48, 48, 48)),
            new Stop(1, Color.rgb(30, 30, 30))));
    CTX.fill();
    //  6=body=gray=============================
    CTX.beginPath();
    CTX.rect(WIDTH * 0.583333, HEIGHT * 0.083333, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.083333;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(53, 53, 53)),
            new Stop(1, Color.rgb(45, 45, 45))));
    CTX.fill();
    //  7= border=gray=dark=============================
    CTX.beginPath();
    CTX.rect(0, HEIGHT * 0.5, WIDTH * 0.5, HEIGHT * 0.5);
    CTX.closePath();
    offsetY = 0.5;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.5 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(48, 48, 48)),
            new Stop(1, Color.rgb(40, 40, 40))));
    CTX.fill();
    //  8= body=gray=light==============================
    CTX.beginPath();
    CTX.rect(WIDTH * 0.083333, HEIGHT * 0.583333, WIDTH * 0.333333, HEIGHT * 0.416666);
    CTX.closePath();
    offsetY = 0.583333;
    CTX.setFill(new LinearGradient(0, offsetY * HEIGHT,
            0, 0.416666 * HEIGHT + offsetY * HEIGHT,
            false, CycleMethod.NO_CYCLE,
            new Stop(0, Color.rgb(53, 53, 53)),
            new Stop(1, Color.rgb(45, 45, 45))));
    CTX.fill();

    final Image PATTERN_IMAGE = CANVAS.snapshot(new SnapshotParameters(), null);
    final ImagePattern PATTERN = new ImagePattern(PATTERN_IMAGE, 0, 0, WIDTH, HEIGHT, false);

    return PATTERN;
}