Пример #1
0
 @Override
 public void draw(Vec2 pos) {
   super.draw(pos);
   Graphics2D.fillRect(pos.add(new Vec2(-20, -20)), new Vec2(40, 6), BLACK);
   Graphics2D.fillRect(pos.add(new Vec2(-20, -20)), new Vec2(40. * health / maxHealth, 6), GREEN);
   Graphics2D.drawRect(pos.add(new Vec2(-20, -20)), new Vec2(40, 6), BLACK);
 }
Пример #2
0
 // DIRECT repaint method
 public void repaint2() {
   Canvas c = null;
   try {
     c = getHolder().lockCanvas();
     if (c != null) {
       // enable anti-aliasing
       c.setDrawFilter(new PaintFlagsDrawFilter(1, Paint.ANTI_ALIAS_FLAG));
       // clean background
       Paint paint = new Paint();
       paint.setColor(drawable.getBackground().getAndroidColor());
       c.drawRect(0, 0, c.getWidth(), c.getHeight(), paint);
       // set dimensions
       drawable.setWidth(getWidth());
       drawable.setHeight(getHeight());
       // do the drawing
       drawable.draw(new Graphics(c));
     }
   } catch (Exception e) {
     // ignore
   } finally {
     if (c != null) {
       getHolder().unlockCanvasAndPost(c);
     }
   }
 }
 public void draw(RenderContext context) {
   context.beginTransformation();
   context.translate(offset.add(new Vector(isVerticallyMirrored ? 1 : 0, 0)));
   context.translate(rotationCenter);
   context.scale(scale.multiply(new Vector(isVerticallyMirrored ? -1 : 1, 1)));
   context.rotate(angle);
   context.translate(rotationCenter.negate());
   drawable.draw(context);
   context.endTransformation();
 }
Пример #4
0
  /**
   * Draw into the provided canvas. Assumes that the canvas has been rotated accordingly and the
   * size has been set. The effect will be drawn the full width of X=0 to X=width, beginning from
   * Y=0 and extending to some factor < 1.f of height.
   *
   * @param canvas Canvas to draw into
   * @return true if drawing should continue beyond this frame to continue the animation
   */
  public boolean draw(GLCanvas canvas) {
    update();

    final int edgeHeight = mEdge.getIntrinsicHeight();
    final int edgeWidth = mEdge.getIntrinsicWidth();
    final int glowHeight = mGlow.getIntrinsicHeight();
    final int glowWidth = mGlow.getIntrinsicWidth();

    mGlow.setAlpha((int) (Math.max(0, Math.min(mGlowAlpha, 1)) * 255));

    int glowBottom =
        (int)
            Math.min(
                glowHeight * mGlowScaleY * glowHeight / glowWidth * 0.6f,
                glowHeight * MAX_GLOW_HEIGHT);
    if (mWidth < mMinWidth) {
      // Center the glow and clip it.
      int glowLeft = (mWidth - mMinWidth) / 2;
      mGlow.setBounds(glowLeft, 0, mWidth - glowLeft, glowBottom);
    } else {
      // Stretch the glow to fit.
      mGlow.setBounds(0, 0, mWidth, glowBottom);
    }

    mGlow.draw(canvas);

    mEdge.setAlpha((int) (Math.max(0, Math.min(mEdgeAlpha, 1)) * 255));

    int edgeBottom = (int) (edgeHeight * mEdgeScaleY);
    if (mWidth < mMinWidth) {
      // Center the edge and clip it.
      int edgeLeft = (mWidth - mMinWidth) / 2;
      mEdge.setBounds(edgeLeft, 0, mWidth - edgeLeft, edgeBottom);
    } else {
      // Stretch the edge to fit.
      mEdge.setBounds(0, 0, mWidth, edgeBottom);
    }
    mEdge.draw(canvas);

    return mState != STATE_IDLE;
  }
Пример #5
0
 private void drawObjects() {
   for (Drawable d : drawableStorage.getAllElements()) d.draw(backBufferContext);
 }
 // 実行
 public void execute() {
   drawable.draw(position.x, position.y);
 }