public Tile getTile(int x, int y, int zoom) { byte[] image = readTileImage(x, y, zoom); return image == null ? null : new Tile(TILE_WIDTH, TILE_HEIGHT, image);
zoomGroup.getChildren().add(content); setContent(contentGroup); scaleTransform = new Scale(scaleValue, scaleValue, 0, 0); zoomGroup.getTransforms().add(scaleTransform);
protected void addInfo (CanvasImage image, float cx, float y) { TextLayout ilayout = graphics().layoutText(image.width() + "x" + image.height(), infoFormat); CanvasImage iimage = graphics().createImage(ilayout.width(), ilayout.height()); iimage.canvas().setFillColor(0xFF000000).fillText(ilayout, 0, 0); graphics().rootLayer().addAt(graphics().createImageLayer(iimage), cx - iimage.width()/2, y); }
public static Image makeButtonImage(String label) { TextLayout layout = graphics().layoutText(label, BUTTON_FMT); CanvasImage image = graphics().createImage(layout.width()+10, layout.height()+10); image.canvas().setFillColor(0xFFCCCCCC); image.canvas().fillRect(0, 0, image.width(), image.height()); image.canvas().setFillColor(0xFF000000); image.canvas().fillText(layout, 5, 5); image.canvas().setStrokeColor(0xFF000000); image.canvas().strokeRect(0, 0, image.width()-1, image.height()-1); return image; }
protected static CanvasImage formatText (TextFormat format, String text, boolean border) { TextLayout layout = graphics().layoutText(text, format); float margin = border ? 10 : 0; float width = layout.width()+2*margin, height = layout.height()+2*margin; CanvasImage image = graphics().createImage(width, height); image.canvas().setStrokeColor(0xFF000000); image.canvas().setFillColor(0xFF000000); image.canvas().fillText(layout, margin, margin); if (border) image.canvas().strokeRect(0, 0, width-1, height-1); return image; }
protected Image makeLabel(String label) { TextLayout layout = graphics().layoutText(label, new TextFormat()); CanvasImage image = graphics().createImage(layout.width(), layout.height()); image.canvas().setFillColor(0xFF000000); image.canvas().fillText(layout, 0, 0); return image; }
@Override public void init() { // remove the background layer added by default graphics().rootLayer().removeAll(); // add a grey square SurfaceImage surf = graphics().createSurface(width, height); surf.surface().setFillColor(Color.rgb(200, 200, 200)); surf.surface().fillRect(0, 0, width, height); square = graphics().createImageLayer(surf); graphics().rootLayer().add(square); }
@Override public void init() { // remove the background layer added by default graphics().rootLayer().clear(); // add a grey square square = graphics().createSurfaceLayer(width, height); square.surface().setFillColor(Color.rgb(200, 200, 200)); square.surface().fillRect(0, 0, square.surface().width(), square.surface().height()); graphics().rootLayer().add(square); }
public void draw(Canvas canvas) { // draw a rounded rect directly canvas.setFillGradient(graphics().createLinearGradient( 0, 0, 100, 100, new int[] { 0xFF0000FF, 0xFF00FF00 }, new float[] { 0, 1 })); TextLayout capF = graphics().layoutText("F", new TextFormat().withFont(F_FONT.derive(96))); canvas.fillText(capF, 15, 5); } });
/** * Returns a (created on demand, then cached) image used when filling solid color quads or * triangles. */ Image fillImage() { if (fillImage == null) { CanvasImage image = platform.graphics().createImage(1, 1); image.canvas().setFillColor(0xFFFFFFFF).fillRect(0, 0, image.width(), image.height()); fillImage = image; } return fillImage; }
@Override public void drawSegment(Vec2 p1, Vec2 p2, Color3f color) { if (canvas == null) { log().error(CANVASERROR); return; } setStrokeColor(color); setFillColor(color); getWorldToScreenToOut(p1, tempVec1); getWorldToScreenToOut(p2, tempVec2); canvas.drawLine(tempVec1.x, tempVec1.y, tempVec2.x, tempVec2.y); }
@Override public void drawPoint(Vec2 argPoint, float argRadiusOnScreen, Color3f color) { if (canvas == null) { log().error(CANVASERROR); return; } setFillColor(color); setStrokeColor(color); getWorldToScreenToOut(argPoint, tempVec1); canvas.fillCircle(tempVec1.x, tempVec1.y, argRadiusOnScreen); }
@Override public void cancelLayerDrags() { if (active.layer != null) { Event.Impl event = new Event.Impl(new Events.Flags.Impl(), PlayN.currentTime(), 0, 0, false); event.captureState = active; dispatcher.dispatch(Listener.class, event, CANCEL, null); active.clear(); } }
@Override public void begin (float fbufWidth, float fbufHeight, boolean flip) { super.begin(fbufWidth, fbufHeight, flip); program.activate(); gl.glUniform2f(uHScreenSize, fbufWidth/2f, fbufHeight/2f); gl.glUniform1f(uFlip, flip ? -1 : 1); // certain graphics cards (I'm looking at you, Intel) exhibit broken behavior if we bind our // attributes once during activation, so for those cards we bind every time in flush() if (!delayedBinding) bindAttribsBufs(); gl.checkError("TriangleBatch begin"); }
public Texture wrapText(String text, float width, TextBlock.Align align) { TextLayout[] layouts = game.graphics.layoutText(text, TEXT_FMT, new TextWrap(width)); Canvas canvas = new TextBlock(layouts).toCanvas(game.graphics, align, 0xFF000000); return canvas.toTexture(); }
public Tile getTile(int x, int y, int zoom) { byte[] image = readTileImage(x, y, zoom); return image == null ? null : new Tile(TILE_WIDTH, TILE_HEIGHT, image);
onDraw(canvas, projection); data = bitmapToByteArray(image); Tile tile = new Tile(TILE_SIZE, TILE_SIZE, data); return tile;