Examples of CanvasImage


Examples of playn.core.CanvasImage

        _borderRadius = borderRadius;
    }

    @Override
    protected Instance instantiate (final IDimension size) {
        CanvasImage image = graphics().createImage(size.width(), size.height());
        if (_borderWidth > 0) {
            image.canvas().setFillColor(_borderColor);
            image.canvas().fillRoundRect(0, 0, size.width(), size.height(), _radius);
            // scale the inner radius based on the ratio of the inner height to the full height;
            // this improves the uniformity of the border substantially
            float iwidth = size.width() - 2*_borderWidth, iheight = size.height() - 2*_borderWidth;
            float iradius = _borderRadius * (iheight / size.height());
            image.canvas().setFillColor(_bgColor);
            image.canvas().fillRoundRect(_borderWidth, _borderWidth, iwidth, iheight, iradius);
        } else {
            image.canvas().setFillColor(_bgColor);
            image.canvas().fillRoundRect(0, 0, size.width(), size.height(), _radius);
        }
        ImageLayer layer = graphics().createImageLayer(image);
        if (alpha != null) layer.setAlpha(alpha);
        return new LayerInstance(size, layer);
    }
View Full Code Here

Examples of playn.core.CanvasImage

        value.update(r.min + pos);
    }

    protected static Icon createDefaultThumbImage () {
        float size = 24;
        CanvasImage image = graphics().createImage(size, size);
        image.canvas().setFillColor(0xFF000000);
        image.canvas().fillCircle(size/2, size/2, size/2-1);
        return Icons.image(image);
    }
View Full Code Here

Examples of playn.core.CanvasImage

    /**
     * Creates a solid square icon of the given size.
     */
    public static Icon solid (int color, float size) {
        CanvasImage image = PlayN.graphics().createImage(1, 1);
        image.canvas().setFillColor(color).fillRect(0, 0, 1, 1);
        return scaled(image(image), size);
    }
View Full Code Here

Examples of playn.core.CanvasImage

    /** Renders this styled text into the supplied canvas at the specified offset. */
    public abstract void render (Canvas canvas, float x, float y);

    /** Creates an image large enough to accommodate this styled text, and renders it therein. */
    public CanvasImage toImage () {
        CanvasImage image = graphics().createImage(width(), height());
        render(image.canvas(), 0, 0);
        return image;
    }
View Full Code Here

Examples of playn.core.CanvasImage

    /**
     * Creates an image large enough to accommodate the supplied text layout, renders the text into
     * it, and returns the image.
     */
    public CanvasImage toImage (TextLayout layout) {
        CanvasImage image = createImage(layout);
        render(image.canvas(), layout, 0, 0);
        return image;
    }
View Full Code Here

Examples of playn.core.CanvasImage

  private static ImageLayer generateLogMessageImageLayer(String message) {
      TextFormat logFormat_ = (logCount % 2 == 0) ? logFormat : logOddFormat;
     
      ImageLayer imageLayer = graphics().createImageLayer();
        TextLayout layout = graphics().layoutText(message, logFormat_);
        CanvasImage logImage = graphics().createImage(graphics().width(), logFontSize + 4);
        logImage.canvas().drawText(layout, 0, 0);
        imageLayer.setImage(logImage);
        return imageLayer;
    }
View Full Code Here

Examples of playn.core.CanvasImage

    this.alpha = alpha;
  }

  public CanvasImage asCanvasImage() {
    int diameter = radius * 2;
    CanvasImage circleImage = graphics().createImage(diameter, diameter);
    Canvas canvas = circleImage.canvas();
    canvas.setFillColor(color);
    canvas.fillCircle((float) radius, (float) radius, (float) radius);
    canvas.setAlpha(alpha);
   
    float strokeWidth = 16.0f;
View Full Code Here

Examples of playn.core.CanvasImage

    return circleImage;
  }

  public ImageLayer asImageLayer() {
      // NOTE: use this for transparent images
    CanvasImage image = asCanvasImage();
    ImageLayer imageLayer = graphics().createImageLayer(image);
    imageLayer.setAlpha(alpha);
    imageLayer.transform().translate(getScreenX(), getScreenY());
    return imageLayer;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.