JavaCanvas(Graphics2D graphics, float width, float height) { super(width, height); this.gfx = graphics; // push default state stateStack.push(new JavaCanvasState()); // All clears go to rgba(0,0,0,0). gfx.setBackground(new Color(0, true)); }
void prepareStroke(Graphics2D gfx) { gfx.setStroke(new BasicStroke(strokeWidth, convertLineCap(), convertLineJoin(), miterLimit)); gfx.setColor(convertColor(strokeColor)); clipper.setClip(gfx); gfx.setComposite(convertComposite(composite, alpha)); }
@Override public Canvas fillPath(Path path) { currentState().prepareFill(g2d); g2d.fill(((JavaPath) path).path); isDirty = true; return this; }
void prepareFill(Graphics2D gfx) { if (fillGradient != null) gfx.setPaint(fillGradient.paint); else if (fillPattern != null) gfx.setPaint(fillPattern.paint); else gfx.setPaint(convertColor(fillColor)); clipper.setClip(gfx); gfx.setComposite(convertComposite(composite, alpha)); }
@Override public Canvas drawPoint(float x, float y) { currentState().prepareStroke(gfx); gfx.drawLine((int) x, (int) y, (int) x, (int) y); isDirty = true; return this; }
@Override public Canvas clear() { currentState().prepareClear(gfx); gfx.clearRect(0, 0, MathUtil.iceil(width), MathUtil.iceil(height)); isDirty = true; return this; }
@Override public Canvas drawPoint(float x, float y) { currentState().prepareStroke(gfx); gfx.drawLine((int) x, (int) y, (int) x, (int) y); isDirty = true; return this; }
void prepareFill(Graphics2D gfx) { if (fillGradient != null) gfx.setPaint(fillGradient.paint); else if (fillPattern != null) gfx.setPaint(fillPattern.paint); else gfx.setPaint(convertColor(fillColor)); clipper.setClip(gfx); gfx.setComposite(convertComposite(composite, alpha)); }
@Override public Canvas clear() { currentState().prepareClear(gfx); gfx.clearRect(0, 0, MathUtil.iceil(width), MathUtil.iceil(height)); isDirty = true; return this; }
void prepareStroke(Graphics2D gfx) { gfx.setStroke(new BasicStroke(strokeWidth, convertLineCap(), convertLineJoin(), miterLimit)); gfx.setColor(convertColor(strokeColor)); clipper.setClip(gfx); gfx.setComposite(convertComposite(composite, alpha)); }
@Override public Canvas drawPoint(float x, float y) { currentState().prepareStroke(g2d); g2d.drawLine((int) x, (int) y, (int) x, (int) y); isDirty = true; return this; }
@Override public Canvas fillPath(Path path) { currentState().prepareFill(gfx); gfx.fill(((JavaPath) path).path); isDirty = true; return this; }
void prepareFill(Graphics2D gfx) { if (fillGradient != null) { gfx.setPaint(fillGradient.paint); } else if (fillPattern != null) { TexturePaint paint = fillPattern.paint; if (paint != null) { gfx.setPaint(paint); } } else { gfx.setPaint(convertColor(fillColor)); } clipper.setClip(gfx); gfx.setComposite(convertComposite(composite, alpha)); }
JavaCanvas(Graphics2D graphics, float width, float height) { super(width, height); this.gfx = graphics; // push default state stateStack.push(new JavaCanvasState()); // All clears go to rgba(0,0,0,0). gfx.setBackground(new Color(0, true)); }
@Override public Canvas clear() { currentState().prepareClear(g2d); g2d.clearRect(0, 0, MathUtil.iceil(width), MathUtil.iceil(height)); isDirty = true; return this; }
void prepareStroke(Graphics2D gfx) { gfx.setStroke(new BasicStroke(strokeWidth, convertLineCap(), convertLineJoin(), miterLimit)); gfx.setColor(convertColor(strokeColor)); clipper.setClip(gfx); gfx.setComposite(convertComposite(composite, alpha)); }
@Override public Canvas drawPoint(float x, float y) { currentState().prepareStroke(g2d); g2d.drawLine((int) x, (int) y, (int) x, (int) y); isDirty = true; return this; }
@Override public Canvas drawText(String text, float x, float y) { currentState().prepareFill(gfx); gfx.drawString(text, x, y); isDirty = true; return this; }
void prepareFill(Graphics2D gfx) { if (fillGradient != null) { gfx.setPaint(fillGradient.paint); } else if (fillPattern != null) { TexturePaint paint = fillPattern.paint; if (paint != null) { gfx.setPaint(paint); } } else { gfx.setPaint(convertColor(fillColor)); } clipper.setClip(gfx); gfx.setComposite(convertComposite(composite, alpha)); }
public JavaCanvas (Graphics gfx, JavaImage image) { super(gfx, image); g2d = image.bufferedImage().createGraphics(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); float scale = image.scale().factor; g2d.scale(scale, scale); // push default state stateStack.push(new JavaCanvasState()); // All clears go to rgba(0,0,0,0). g2d.setBackground(new Color(0, true)); }