@Override public void draw(BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { BufferedImage input = new BufferedImage( scale * glyph.getWidth(), scale * glyph.getHeight(), BufferedImage.TYPE_BYTE_BINARY); drawGlyph(input, glyph); DistanceFieldGenerator generator = new DistanceFieldGenerator(); generator.setColor(color); generator.setDownscale(scale); // We multiply spread by the scale, so that changing scale will only affect accuracy // and not spread in the output image. generator.setSpread(scale * spread); BufferedImage distanceField = generator.generateDistanceField(input); g.drawImage(distanceField, new AffineTransform(), null); }
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { g = (Graphics2D)g.create(); g.translate(xDistance, yDistance); g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), Math.round(opacity * 255))); g.fill(glyph.getShape()); // Also shadow the outline, if one exists. for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();) { Effect effect = (Effect)iter.next(); if (effect instanceof OutlineEffect) { Composite composite = g.getComposite(); g.setComposite(AlphaComposite.Src); // Prevent shadow and outline shadow alpha from combining. g.setStroke(((OutlineEffect)effect).getStroke()); g.draw(glyph.getShape()); g.setComposite(composite); break; } } g.dispose(); if (blurKernelSize > 1 && blurKernelSize < NUM_KERNELS && blurPasses > 0) blur(image); }
/** * Draws the glyph to the given image, upscaled by a factor of {@link #scale}. * * @param image the image to draw to * @param glyph the glyph to draw */ private void drawGlyph(BufferedImage image, Glyph glyph) { Graphics2D inputG = (Graphics2D) image.getGraphics(); inputG.setTransform(AffineTransform.getScaleInstance(scale, scale)); // We don't really want anti-aliasing (we'll discard it anyway), // but accurate positioning might improve the result slightly inputG.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); inputG.setColor(Color.WHITE); inputG.fill(glyph.getShape()); }
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { g = (Graphics2D)g.create(); if (stroke != null) g.setStroke(stroke); else g.setStroke(getStroke()); g.setColor(color); g.draw(glyph.getShape()); g.dispose(); }
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { int ascent = unicodeFont.getAscent(); float height = (ascent) * scale; float top = -glyph.getYOffset() + unicodeFont.getDescent() + offset + ascent / 2 - height / 2; g.setPaint(new GradientPaint(0, top, topColor, 0, top + height, bottomColor, cyclic)); g.fill(glyph.getShape()); }
/** Called to draw the effect. */ public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph);
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { BufferedImage scratchImage = EffectUtil.getScratchImage(); filter.filter(image, scratchImage); image.getGraphics().drawImage(scratchImage, 0, 0, null); }
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) { g.setColor(color); g.fill(glyph.getShape()); }