Beispiel #1
0
  @Override
  protected void doInitialize() {
    CanvasImage blackBG = graphics().createImage(graphics().width(), graphics().height());
    blackBG.canvas().setFillColor(0xff000000);
    blackBG.canvas().fillRect(0, 0, graphics().width(), graphics().height());
    Layer layer = graphics().createImageLayer(blackBG);
    layer.setDepth(0);
    addToStaticLayer(layer);

    loadingImage = graphics().createImage(graphics().width(), graphics().height());
    loadingImage.canvas().setStrokeWidth(2);
    loadingImage.canvas().setStrokeColor(0xffff0000);
    loadingImage.canvas().setFillColor(0xff0000ff);
    layer = graphics().createImageLayer(loadingImage);
    layer.setDepth(1);
    addToStaticLayer(layer);

    Font font = graphics().createFont("Courier", Font.Style.BOLD, 16);
    CanvasImage loadingText = graphics().createImage(graphics().width(), graphics().height());
    loadingText.canvas().setStrokeColor(0xffffffff);
    loadingText.canvas().setFillColor(0xffffffff);
    loadingText
        .canvas()
        .drawText("Loading!..", graphics().width() / 2, graphics().height() / 2 - 50);
    layer = graphics().createImageLayer(loadingText);
    layer.setDepth(2);
    addToStaticLayer(layer);
  }
Beispiel #2
0
 @Override
 public void paint(float alpha) {
   if (isCanvasDirty) {
     loadingImage.canvas().clear();
     float bwidth = graphics().width() - 50;
     loadingImage
         .canvas()
         .fillRect(25 + (bwidth - 40) * (pdone / 100), graphics().height() / 2 - 20, 40, 40);
     loadingImage
         .canvas()
         .strokeRect(25, graphics().height() / 2 - 20, graphics().width() - 50, 40);
   }
 }
Beispiel #3
0
 public static void DrawString(Surface g, TextLayout layout, int x, int y) {
   CanvasImage c =
       Global.m_graphics.createImage(
           (int) Math.ceil(layout.width()), (int) Math.ceil(layout.height()));
   Canvas gc = c.canvas();
   gc.drawText(layout, 0, 0);
   g.drawImage(c, x, y);
 }
Beispiel #4
0
 /**
  * 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;
 }
  public UINoGoComponent(int width) {
    mWidth = width;

    mFrontLayer = CanvasHelper.newEmptyLayer();

    CanvasImage image = graphics().createImage(width, HEIGHT);
    image.canvas().setFillColor(0xff000000).fillRect(0, 0, width, HEIGHT);
    mBackLayer = graphics().createImageLayer(image);
  }
Beispiel #6
0
  private CanvasImage createMenuImage(MenuEntry me) {
    CanvasImage result = graphics().createImage(200, 50);
    Canvas resultCanvas = result.canvas();

    //	  resultCanvas.setFillGradient(graphics().createLinearGradient(0f, 0f, 200f, 50f,
    // {Color.rgb(0, 0, 0), Color.rgb(100, 0, 0)}, {0, 0, 200, 50}))
    resultCanvas.setFillColor(Color.argb(50, 255, 255, 255));
    resultCanvas.fillRect(0, 0, result.width(), result.height());
    resultCanvas.setFillColor(Color.rgb(0, 0, 0));
    resultCanvas.drawText(me.getLabel(), result.width() / 2, result.height() / 2);

    return result;
  }
Beispiel #7
0
  @Override
  public void init() {
    GroupLayer rootLayer = graphics().rootLayer();

    final CanvasImage img = graphics().createImage(100, 50);
    img.canvas()
        .setFillGradient(
            graphics()
                .createLinearGradient(
                    0, 0, 100, 100, new int[] {0xFF0000FF, 0xFF00FF00}, new float[] {0, 1}));
    img.canvas().fillRoundRect(0, 0, 100, 50, 10);

    // create an immediate layer that draws the boundaries of our clipped group layers
    rootLayer.add(
        graphics()
            .createImmediateLayer(
                new ImmediateLayer.Renderer() {
                  public void render(Surface surf) {
                    // draw the border of our various clipped groups
                    surf.setFillColor(0xFF000000);
                    outline(surf, g1);
                    outline(surf, g2);
                    outline(surf, g3);
                    outline(surf, g4);
                  }

                  protected void outline(Surface surf, Layer.HasSize ly) {
                    drawRect(
                        surf,
                        ly.transform().tx() - ly.originX(),
                        ly.transform().ty() - ly.originY(),
                        ly.width(),
                        ly.height());
                  }

                  protected void drawRect(Surface surf, float x, float y, float w, float h) {
                    float left = x - 1, top = y - 1, right = x + w + 2, bot = y + h + 2;
                    surf.drawLine(left, top, right, top, 1);
                    surf.drawLine(right, top, right, bot, 1);
                    surf.drawLine(left, top, left, bot, 1);
                    surf.drawLine(left, bot, right, bot, 1);
                  }
                }));

    // create a group layer with a static clip, and a rotating image inside
    g1 = graphics().createGroupLayer(100, 100);
    // test the origin not being at zero/zero
    g1.setOrigin(50, 0);
    i1 = graphics().createImageLayer(img);
    i1.setOrigin(i1.width() / 2, i1.height() / 2);
    g1.addAt(i1, 50, 50);
    rootLayer.addAt(g1, 75, 25);

    g2 = graphics().createGroupLayer(100, 100);
    g2.setOrigin(50, 50);
    g2.addAt(graphics().createImageLayer(img), (100 - img.width()) / 2, (100 - img.height()) / 2);
    rootLayer.addAt(g2, 200, 75);

    // nest a group layer inside with an animated origin
    inner = graphics().createGroupLayer();
    inner.addAt(
        graphics().createImageLayer(img), (100 - img.width()) / 2, (100 - img.height()) / 2);
    g3 = graphics().createGroupLayer(100, 100);
    g3.add(inner);
    rootLayer.addAt(g3, 275, 25);

    // create a group layer with a static clip, and a rotating surface layer inside
    g4 = graphics().createGroupLayer(100, 100);
    s1 = graphics().createSurfaceLayer(100, 50);
    s1.surface().setFillColor(0xFF99CCFF).fillRect(0, 0, 100, 50);
    s1.setOrigin(s1.width() / 2, s1.height() / 2);
    g4.addAt(s1, 50, 50);
    rootLayer.addAt(g4, 400, 25);
  }