@Override public Surface restore() { canvas.restore(); return this; }
@Override public Surface drawLine(float x0, float y0, float x1, float y1, float width) { canvas.save(); canvas.setStrokeWidth(width); canvas.drawLine(x0, y0, x1, y1); canvas.restore(); return this; }
@Override public void paint(Canvas canvas, float parentAlpha) { if (!visible()) return; canvas.save(); transform(canvas); paintChildren(canvas, parentAlpha * alpha()); canvas.restore(); }
@Override public void paint(Canvas canvas, float parentAlpha) { if (!visible()) return; canvas.save(); transform(canvas); canvas.setAlpha(parentAlpha * alpha()); render(canvas); canvas.restore(); }
public void draw(Canvas canvas) { float dotRadius = 40; canvas.save(); canvas.setFillGradient(graphics().createRadialGradient( 100 / 3, 100 / 2.5f, dotRadius, new int[] { 0xFFFFFFFF, 0xFFCC66FF }, new float[] { 0f, 1f })); canvas.fillCircle(50, 50, dotRadius); canvas.restore(); canvas.setStrokeColor(0xFF000000); canvas.setStrokeWidth(1.5f); canvas.strokeCircle(50, 50, dotRadius); } });
@Override public void render (Canvas canvas, TextLayout layout, int textColor, boolean underlined, float x, float y) { canvas.save(); canvas.setFillColor(textColor); if (underlined) { IRectangle bounds = layout.bounds; float sx = x + bounds.x(), sy = y + bounds.y() + bounds.height() + 1; canvas.fillRect(sx, sy, bounds.width(), 1); } canvas.fillText(layout, x, y); canvas.restore(); } };
@Override public void render (Canvas canvas, TextLayout text, int textColor, boolean underlined, float x, float y) { canvas.save(); canvas.setStrokeColor(outlineColor); canvas.setStrokeWidth(outlineWidth*2); canvas.setLineCap(outlineCap); canvas.setLineJoin(outlineJoin); canvas.strokeText(text, x+outlineWidth, y+outlineWidth); canvas.setFillColor(textColor); canvas.fillText(text, x+outlineWidth, y+outlineWidth); if (underlined) { IRectangle bounds = text.bounds; float sx = x + bounds.x() + outlineWidth; float sy = y + bounds.y() + bounds.height() + outlineWidth + 1; canvas.fillRect(sx, sy, bounds.width(), 1); } canvas.restore(); }
canvas.restore();
@Override public void render (Canvas canvas, TextLayout text, int textColor, boolean underlined, float x, float y) { float tx = (shadowX < 0) ? -shadowX : 0, ty = (shadowY < 0) ? -shadowY : 0; float sx = (shadowX < 0) ? 0 : shadowX, sy = (shadowY < 0) ? 0 : shadowY; canvas.save(); if (underlined) { IRectangle bounds = text.bounds; canvas.setFillColor(shadowColor).fillRect( sx+bounds.x()+x, sy+bounds.y()+bounds.height()+1, bounds.width()+1, 1); canvas.setFillColor(textColor).fillRect( tx+bounds.x()+x, ty+bounds.y()+bounds.height()+1, bounds.width()+1, 1); } canvas.setFillColor(shadowColor); canvas.fillText(text, x+sx, y+sy); canvas.setFillColor(textColor); canvas.fillText(text, x+tx, y+ty); canvas.restore(); }
@Override public void paint(Canvas canvas, float parentAlpha) { if (!visible() || img == null || !img.isReady()) return; canvas.save(); canvas.setAlpha(parentAlpha * alpha()); transform(canvas); float width = width(), height = height(); boolean repX = img.repeatX(), repY = img.repeatY(); if (repX || repY) { if (pattern == null || repX != patternRepeatX || repY != patternRepeatY) { patternRepeatX = repX; patternRepeatY = repY; pattern = img.toPattern(); } canvas.setFillPattern(pattern); float xScale = repX ? 1 : width / img.width(), yScale = repY ? 1 : height / img.height(); canvas.scale(xScale, yScale); canvas.fillRect(0, 0, width / xScale, height / yScale); } else { canvas.drawImage(img, 0, 0, width, height); } canvas.restore(); } }
@Override public void render (Canvas canvas, TextLayout text, int textColor, boolean underlined, float x, float y) { canvas.save(); if (underlined) { IRectangle bounds = text.bounds; float sx = x + bounds.x() + 1, sy = y + bounds.y() + bounds.height() + 2; canvas.setFillColor(outlineColor).fillRect(sx-1, sy-1, bounds.width()+3, 3); canvas.setFillColor(textColor).fillRect(sx, sy, bounds.width(), 1); } canvas.setFillColor(outlineColor); canvas.fillText(text, x+0, y+0); canvas.fillText(text, x+0, y+1); canvas.fillText(text, x+0, y+2); canvas.fillText(text, x+1, y+0); canvas.fillText(text, x+1, y+2); canvas.fillText(text, x+2, y+0); canvas.fillText(text, x+2, y+1); canvas.fillText(text, x+2, y+2); canvas.setFillColor(textColor); canvas.fillText(text, x+1, y+1); canvas.restore(); }
canvas.save(); canvas.setFillGradient(radial).fillCircle(50, 50, dotRadius); canvas.restore(); canvas.setStrokeColor(0xFF000000).setStrokeWidth(1.5f).strokeCircle(50, 50, dotRadius); });