Example #1
0
  public void redraw(Canvas c, int width, int height, float now, float totalTime) {
    // window [-2.0, 1.0, -1.5, 1.5]

    float dperiod = period * 2 * 10;

    float ratio = (now % dperiod) / dperiod;
    float trans;

    dstR.right = width;
    dstR.bottom = height;
    c.drawBitmap(background, srcR, dstR, null);

    if (ratio > 0.5) trans = (1 - ratio) * 50;
    else trans = ratio * 50;
    float radius = width / 2;

    pTag.setColor(Color.argb((int) (trans * 0.7), 255, 255, 255));
    c.drawCircle(width / 4, height / 2, radius, pTag);

    pTag.setColor(Color.argb((int) (trans * 0.4), 255, 255, 255));
    c.drawCircle(width / 4 - 20, height / 2 + 20, radius * 0.7f, pTag);

    pTag.setColor(Color.argb((int) trans, 255, 255, 255));
    c.drawCircle(width / 4, height / 2, radius * 0.4f, pTag);
  }
Example #2
0
  @Override
  public void drawChassis(Canvas canvas) {
    canvas.save();

    canvas.translate(getX(), getY());

    canvas.rotate(MathUtils.toDegrees(getHeading()) + 90);
    canvas.drawLines(outline, paint);
    canvas.drawCircle(0f, 0f, 5f, paint);

    canvas.restore();

    if (!firing) {
      float radius = POWER_CIRCLE_RADIUS * powerLevel / MAX_POWER_LEVEL;
      if (radius > 0) {
        tempPaint.set(paint);

        paint.setStyle(Style.FILL);
        paint.setColor(Color.GRAY);
        canvas.drawCircle(getX(), getY(), radius, paint);

        paint.set(tempPaint);
      }
    }
  }
  @SuppressLint("DrawAllocation")
  @Override
  public void onDraw(Canvas canvas) {
    // load the bitmap
    loadBitmap();

    // init shader
    if (image != null) {
      shader =
          new BitmapShader(
              Bitmap.createScaledBitmap(image, canvas.getWidth(), canvas.getHeight(), false),
              Shader.TileMode.CLAMP,
              Shader.TileMode.CLAMP);
      paint.setShader(shader);
      int circleCenter = viewWidth / 2;

      // circleCenter is the x or y of the view's center
      // radius is the radius in pixels of the cirle to be drawn
      // paint contains the shader that will texture the shape
      canvas.drawCircle(
          circleCenter + borderWidth,
          circleCenter + borderWidth,
          circleCenter + borderWidth,
          paintBorder);
      canvas.drawCircle(
          circleCenter + borderWidth, circleCenter + borderWidth, circleCenter, paint);
    }
  }
Example #4
0
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    final float ratio = calculateRatio();
    float radius;

    // Darkening background
    canvas.drawColor(Color.argb((int) (200 * calculateRatio()), 0, 0, 0));

    if (mRadiusAimed) {

      // Indicate that target radius is aimed.
      mPaint.setAlpha(35);
      radius = (float) Math.sqrt(mRadius / 70) * 70;
      canvas.drawCircle(mPoint[0], mPoint[1], radius, mPaint);
    }

    // Draw unlock circle
    mPaint.setAlpha((int) (255 * Math.pow(ratio, 0.33f)));
    radius = (float) Math.sqrt(mRadius / 50) * 50;
    canvas.drawCircle(mPoint[0], mPoint[1], radius, mPaint);

    // Draw unlock icon at the center of circle
    float scale = 0.5f + 0.5f * ratio;
    canvas.save();
    canvas.translate(
        mPoint[0] - mDrawable.getMinimumWidth() / 2 * scale,
        mPoint[1] - mDrawable.getMinimumHeight() / 2 * scale);
    canvas.scale(scale, scale);
    mDrawable.draw(canvas);
    canvas.restore();
  }
  @Override
  protected void onDraw(Canvas canvas) {
    float left = getPaddingLeft() + mUnreachedWidth / 2;
    float top = getPaddingTop() + mUnreachedWidth / 2;
    float right = canvas.getWidth() - getPaddingRight() - mUnreachedWidth / 2;
    float bottom = canvas.getHeight() - getPaddingBottom() - mUnreachedWidth / 2;
    float centerX = (left + right) / 2;
    float centerY = (top + bottom) / 2;

    float wheelRadius =
        (canvas.getWidth() - getPaddingLeft() - getPaddingRight()) / 2 - mUnreachedWidth / 2;

    if (isHasCache) {
      if (mCacheCanvas == null) {
        buildCache(centerX, centerY, wheelRadius);
      }
      canvas.drawBitmap(mCacheBitmap, 0, 0, null);
    } else {
      canvas.drawCircle(centerX, centerY, wheelRadius, mWheelPaint);
    }

    // 画选中区域
    canvas.drawArc(
        new RectF(left, top, right, bottom), -90, (float) mCurAngle, false, mReachedPaint);

    // 画锚点
    canvas.drawCircle(mWheelCurX, mWheelCurY, mPointerRadius, mPointerPaint);
  }
  @Override
  public void draw(Canvas canvas) {
    mBounds.set(getBounds());

    if (mMode == MODE_RATING) {
      float arcAngle = mCurrentValue * 360f;
      final float arcStart = -90f;
      canvas.drawArc(mBounds, arcStart + arcAngle, 360f - arcAngle, true, mBackgroundArcPaint);
      canvas.drawArc(mBounds, arcStart, arcAngle, true, mArcPaint);
    } else if (mMode == MODE_PROMPT) {
      canvas.drawCircle(
          mBounds.centerX(),
          mBounds.centerY(),
          mBounds.height() * BACKGROUND_CIRCLE_RADIUS_RATIO,
          mBackgroundArcPaint);
    }

    canvas.drawCircle(
        mBounds.centerX(),
        mBounds.centerY(),
        mBounds.height() * FOREGROUND_CIRCLE_RADIUS_RATIO,
        mForegroundCirclePaint);

    if (mText != null) {
      canvas.drawText(
          mText,
          mBounds.centerX() - (mTextWidth / 2f),
          mBounds.centerY() + (mTextHeight / 2f),
          mTextPaint);
    }
  }
  @Override
  protected void drawMyLocation(
      Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when) {
    if (!bugged) {
      try {
        super.drawMyLocation(canvas, mapView, lastFix, myLocation, when);
      } catch (Exception e) {
        // we found a buggy phone, draw the location icons ourselves
        bugged = true;
      }
    }

    if (bugged) {
      if (drawable == null) {

        accuracyPaint = new Paint();
        accuracyPaint.setAntiAlias(true);
        accuracyPaint.setStrokeWidth(2.0f);

        drawable =
            mapView
                .getContext()
                .getResources()
                .getDrawable(R.drawable.ic_maps_indicator_current_position);
        width = drawable.getIntrinsicWidth();
        height = drawable.getIntrinsicHeight();
        center = new Point();
        left = new Point();
      }

      Projection projection = mapView.getProjection();
      double latitude = lastFix.getLatitude();
      double longitude = lastFix.getLongitude();
      float accuracy = lastFix.getAccuracy();

      float[] result = new float[1];

      Location.distanceBetween(latitude, longitude, latitude, longitude + 1, result);
      float longitudeLineDistance = result[0];

      GeoPoint leftGeo =
          new GeoPoint(
              (int) (latitude * 1e6), (int) ((longitude - accuracy / longitudeLineDistance) * 1e6));
      projection.toPixels(leftGeo, left);
      projection.toPixels(myLocation, center);
      int radius = center.x - left.x;

      accuracyPaint.setColor(0xff6666ff);
      accuracyPaint.setStyle(Style.STROKE);
      canvas.drawCircle(center.x, center.y, radius, accuracyPaint);

      accuracyPaint.setColor(0x186666ff);
      accuracyPaint.setStyle(Style.FILL);
      canvas.drawCircle(center.x, center.y, radius, accuracyPaint);

      drawable.setBounds(
          center.x - width / 2, center.y - height / 2, center.x + width / 2, center.y + height / 2);
      drawable.draw(canvas);
    }
  }
  /**
   * Draws the data encapsulated by a {@link TouchDisplayView.TouchHistory} object to a canvas. A
   * large circle indicates the current position held by the {@link TouchDisplayView.TouchHistory}
   * object, while a smaller circle is drawn for each entry in its history. The size of the large
   * circle is scaled depending on its pressure, clamped to a maximum of <code>1.0</code>.
   *
   * @param canvas
   * @param id
   * @param data
   */
  protected void drawCircle(Canvas canvas, int id, TouchHistory data) {
    // select the color based on the id
    int color = COLORS[id % COLORS.length];
    mCirclePaint.setColor(color);

    /*
     * Draw the circle, size scaled to its pressure. Pressure is clamped to
     * 1.0 max to ensure proper drawing. (Reported pressure values can
     * exceed 1.0, depending on the calibration of the touch screen).
     */
    float pressure = Math.min(data.pressure, 1f);
    float radius = pressure * mCircleRadius;

    canvas.drawCircle(data.x, (data.y) - (radius / 2f), radius, mCirclePaint);

    // draw all historical points with a lower alpha value
    mCirclePaint.setAlpha(125);
    for (int j = 0; j < data.history.length && j < data.historyCount; j++) {
      PointF p = data.history[j];
      canvas.drawCircle(p.x, p.y, mCircleHistoricalRadius, mCirclePaint);
    }

    // draw its label next to the main circle
    canvas.drawText(data.label, data.x + radius, data.y - radius, mTextPaint);
  }
  /*
   * (non-Javadoc)
   *
   * @see android.view.View#onDraw(android.graphics.Canvas)
   */
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    int count = 3;
    if (viewFlow != null) {
      count = viewFlow.getViewsCount();
    }

    float circleSeparation = 2 * radius + radius;
    // this is the amount the first circle should be offset to make the entire thing centered
    float centeringOffset = 0;

    int leftPadding = getPaddingLeft();

    // Draw stroked circles
    for (int iLoop = 0; iLoop < count; iLoop++) {
      canvas.drawCircle(
          leftPadding + radius + (iLoop * circleSeparation) + centeringOffset,
          getPaddingTop() + radius,
          radius,
          mPaintInactive);
    }
    float cx = 0;
    if (flowWidth != 0) {
      // Draw the filled circle according to the current scroll
      cx = (currentScroll * (2 * radius + radius)) / flowWidth;
    }
    // The flow width has been upadated yet. Draw the default position
    canvas.drawCircle(
        leftPadding + radius + cx + centeringOffset,
        getPaddingTop() + radius,
        radius,
        mPaintActive);
  }
Example #10
0
  /** Draws this code with its current location and orientation */
  public void draw(Canvas g) {

    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

    int bits = this.code;
    float sweep = 360.0f / SECTORS;
    float a = (-orientation * 180 / PI);
    float r = WIDTH * 0.5f * unit;

    paint.setColor(Color.WHITE);
    g.drawCircle(x, y, r, paint);

    RectF oval = new RectF(x - r, y - r, x + r, y + r);
    for (int i = 0; i < SECTORS; i++) {
      paint.setColor(((bits & 0x1) > 0) ? Color.WHITE : Color.BLACK);
      g.drawArc(oval, i * sweep + a, sweep, true, paint);
      bits >>= 1;
    }

    paint.setColor(Color.WHITE);
    g.drawCircle(x, y, r - unit, paint);

    paint.setColor(Color.BLACK);
    g.drawCircle(x, y, r - unit * 2, paint);

    paint.setColor(Color.WHITE);
    g.drawCircle(x, y, r - unit * 3, paint);
  }
Example #11
0
  private void drawDebug(Canvas canvas) {
    float posX = 10;
    float posY = 20;

    Paint paint = new Paint();
    paint.setStrokeWidth(5);
    paint.setStyle(Style.FILL);

    paint.setColor(Color.BLACK);

    canvas.drawCircle(mOrigin.x, mOrigin.y, getWidth(), paint);

    paint.setStrokeWidth(3);
    paint.setColor(Color.RED);
    canvas.drawCircle(mOrigin.x, mOrigin.y, getWidth(), paint);

    paint.setStrokeWidth(5);
    paint.setColor(Color.BLACK);
    canvas.drawLine(mOrigin.x, mOrigin.y, mMovement.x, mMovement.y, paint);

    paint.setStrokeWidth(3);
    paint.setColor(Color.RED);
    canvas.drawLine(mOrigin.x, mOrigin.y, mMovement.x, mMovement.y, paint);

    posY = debugDrawPoint(canvas, "A", mA, Color.RED, posX, posY);
    posY = debugDrawPoint(canvas, "B", mB, Color.GREEN, posX, posY);
    posY = debugDrawPoint(canvas, "C", mC, Color.BLUE, posX, posY);
    posY = debugDrawPoint(canvas, "D", mD, Color.CYAN, posX, posY);
    posY = debugDrawPoint(canvas, "E", mE, Color.YELLOW, posX, posY);
    posY = debugDrawPoint(canvas, "F", mF, Color.LTGRAY, posX, posY);
    posY = debugDrawPoint(canvas, "Mov", mMovement, Color.DKGRAY, posX, posY);
    posY = debugDrawPoint(canvas, "Origin", mOrigin, Color.MAGENTA, posX, posY);

    /**/
  }
Example #12
0
 private void drawApexes(final Canvas canvas) {
   for (int i = 0; i < numNode; ++i) {
     if (matrix[i][i] == 1)
       canvas.drawCircle(coordNodes.get(i).x, coordNodes.get(i).y, radius, paintLapse);
     else canvas.drawCircle(coordNodes.get(i).x, coordNodes.get(i).y, radius, paintNode);
   }
 }
Example #13
0
  @Override
  protected void onDraw(Canvas canvas) {
    final int width = getWidth();
    final int height = getHeight();

    // make background blue
    canvas.drawColor(Color.BLUE);

    // draw body
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); // smooth out the edges
    paint.setColor(Color.YELLOW);
    paint.setStyle(Paint.Style.FILL);

    float radius = 0.3f * width; // body radius
    canvas.translate(width / 2.0f, height / 2.0f); // set origin to center of view
    canvas.drawCircle(0, 0, radius, paint);

    // draw eyes
    paint.setColor(Color.BLACK);
    radius = 0.025f * width; // eye radius
    canvas.drawCircle(0.2f * width, 0, radius, paint); // draw right eye
    canvas.drawCircle(-0.2f * width, 0, radius, paint); // draw left eye

    // draw wings
    paint.setColor(Color.YELLOW);
    radius = 0.055f * width; // wing radius
    canvas.drawCircle(0.28f * width, 0.08f * height, radius, paint); // draw right wing
    canvas.drawCircle(-0.28f * width, 0.08f * height, radius, paint); // draw left wing

    // draw beak
    paint.setColor(Color.rgb(255, 165, 0));
    RectF oval = new RectF(-0.18f * width, 0.02f * height, 0.18f * width, 0.07f * height);
    canvas.drawOval(oval, paint);
  }
Example #14
0
  @Override
  public void onDraw(Canvas canvas) {
    int viewWidth = getWidth();
    if (viewWidth == 0 || !mIsInitialized) {
      return;
    }

    if (!mDrawValuesReady) {
      mXCenter = getWidth() / 2;
      mYCenter = getHeight() / 2;
      mCircleRadius = (int) (Math.min(mXCenter, mYCenter) * mCircleRadiusMultiplier);

      if (!mIs24HourMode) {
        // We'll need to draw the AM/PM circles, so the main circle will need to have
        // a slightly higher center. To keep the entire view centered vertically, we'll
        // have to push it up by half the radius of the AM/PM circles.
        int amPmCircleRadius = (int) (mCircleRadius * mAmPmCircleRadiusMultiplier);
        mYCenter -= amPmCircleRadius / 2;
      }

      mDrawValuesReady = true;
    }

    // Draw the white circle.
    mPaint.setColor(mWhite);
    canvas.drawCircle(mXCenter, mYCenter, mCircleRadius, mPaint);

    // Draw a small black circle in the center.
    mPaint.setColor(mBlack);
    canvas.drawCircle(mXCenter, mYCenter, 2, mPaint);
  }
 /*
  * Drawing
  */
 @Override
 public void draw(Canvas canvas) {
   final boolean positionChanged = adapterPositionChanged();
   if (rippleOverlay) {
     if (!positionChanged) {
       rippleBackground.draw(canvas);
     }
     super.draw(canvas);
     if (!positionChanged) {
       if (rippleRoundedCorners != 0) {
         Path clipPath = new Path();
         RectF rect = new RectF(0, 0, canvas.getWidth(), canvas.getHeight());
         clipPath.addRoundRect(
             rect, rippleRoundedCorners, rippleRoundedCorners, Path.Direction.CW);
         canvas.clipPath(clipPath);
       }
       canvas.drawCircle(currentCoords.x, currentCoords.y, radius, paint);
     }
   } else {
     if (!positionChanged) {
       rippleBackground.draw(canvas);
       canvas.drawCircle(currentCoords.x, currentCoords.y, radius, paint);
     }
     super.draw(canvas);
   }
 }
Example #16
0
  /** draws the hole in the center of the chart and the transparent circle / hole */
  protected void drawHole(Canvas c) {

    if (mChart.isDrawHoleEnabled()) {

      float transparentCircleRadius = mChart.getTransparentCircleRadius();
      float holeRadius = mChart.getHoleRadius();
      float radius = mChart.getRadius();

      PointF center = mChart.getCenterCircleBox();

      // only draw the circle if it can be seen (not covered by the hole)
      if (transparentCircleRadius > holeRadius) {

        // get original alpha
        int alpha = mTransparentCirclePaint.getAlpha();
        mTransparentCirclePaint.setAlpha(
            (int) ((float) alpha * mAnimator.getPhaseX() * mAnimator.getPhaseY()));

        // draw the transparent-circle
        mBitmapCanvas.drawCircle(
            center.x, center.y, radius / 100 * transparentCircleRadius, mTransparentCirclePaint);

        // reset alpha
        mTransparentCirclePaint.setAlpha(alpha);
      }

      // draw the hole-circle
      mBitmapCanvas.drawCircle(center.x, center.y, radius / 100 * holeRadius, mHolePaint);
    }
  }
Example #17
0
  @Override
  public Bitmap transform(Bitmap source) {
    int size = Math.min(source.getWidth(), source.getHeight());

    int x = (source.getWidth() - size) / 2;
    int y = (source.getHeight() - size) / 2;

    Bitmap squaredBitmap = Bitmap.createBitmap(source, x, y, size, size);
    if (squaredBitmap != source) {
      source.recycle();
    }

    Bitmap bitmap = Bitmap.createBitmap(size, size, source.getConfig());

    Canvas canvas = new Canvas(bitmap);

    Paint avatarPaint = new Paint();
    BitmapShader shader =
        new BitmapShader(squaredBitmap, BitmapShader.TileMode.CLAMP, BitmapShader.TileMode.CLAMP);
    avatarPaint.setShader(shader);

    Paint outlinePaint = new Paint();
    outlinePaint.setColor(Color.WHITE);
    outlinePaint.setStyle(Paint.Style.STROKE);
    outlinePaint.setStrokeWidth(STROKE_WIDTH);
    outlinePaint.setAntiAlias(true);

    float r = size / 2f;
    canvas.drawCircle(r, r, r, avatarPaint);
    canvas.drawCircle(r, r, r - STROKE_WIDTH / 2, outlinePaint);

    squaredBitmap.recycle();
    return bitmap;
  }
Example #18
0
  @Override
  protected void onDraw(Canvas canvas) {
    // All of our positions are using our internal coordinate system.
    // Instead of translating
    // them we let Canvas do the work for us.
    canvas.translate(mTranslationOffset, mTranslationOffset);

    // Draw the color wheel.
    canvas.drawOval(mColorWheelRectangle, mColorWheelPaint);

    float[] pointerPosition = calculatePointerPosition(mAngle);

    // Draw the pointer's "halo"
    canvas.drawCircle(
        pointerPosition[0], pointerPosition[1], mColorPointerHaloRadius, mPointerHaloPaint);

    // Draw the pointer (the currently selected color) slightly smaller on
    // top.
    canvas.drawCircle(pointerPosition[0], pointerPosition[1], mColorPointerRadius, mPointerColor);

    // Draw the halo of the center colors.
    canvas.drawCircle(0, 0, mColorCenterHaloRadius, mCenterHaloPaint);

    // Draw the old selected color in the center.
    canvas.drawArc(mCenterRectangle, 90, 180, true, mCenterOldPaint);

    // Draw the new selected color in the center.
    canvas.drawArc(mCenterRectangle, 270, 180, true, mCenterNewPaint);
  }
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // calculate the left and right values
    float right = this.getWidth() - this.getPaddingRight();
    float left = right - this.getWidth() + this.getPaddingLeft();
    float height = this.getHeight() - this.getPaddingTop() - this.getPaddingBottom();
    float radius = height / 2; // 圓半徑

    oval.set(left, 0, right, height);
    if (this.isChecked()) {
      paint.setColor(Color.parseColor("#4B96C2"));
      // paint.setColor(Color.parseColor("#5a7fc0"));
      canvas.drawRoundRect(oval, radius, radius, paint);
      paint.setColor(Color.WHITE);
      canvas.drawCircle(right - radius, radius, radius - SWITCH_BOUND, paint);
    } else {
      paint.setColor(Color.GRAY);
      canvas.drawRoundRect(oval, radius, radius, paint);
      paint.setColor(Color.WHITE);
      canvas.drawCircle(left + radius, radius, radius - SWITCH_BOUND, paint);
    }

    canvas.save();
  }
  @Override
  protected void onDraw(Canvas canvas) {

    canvas.save();
    // 去除状态栏高度偏差
    canvas.translate(0, -mStatusBarHeight);

    if (!isDisappear) {
      if (!isOutOfRange) {
        // 画两圆连接处
        ShapeDrawable drawGooView = drawGooView();
        drawGooView.setBounds(rect);
        drawGooView.draw(canvas);

        // 画固定圆
        canvas.drawCircle(mStickCenter.x, mStickCenter.y, stickCircleTempRadius, mPaintRed);
      }
      // 画拖拽圆
      canvas.drawCircle(mDragCenter.x, mDragCenter.y, dragCircleRadius, mPaintRed);
      // 画数字
      canvas.drawText(text, mDragCenter.x, mDragCenter.y + dragCircleRadius / 2f, mTextPaint);
    }

    canvas.restore();
  }
  @Override
  public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    Projection projection = mapView.getProjection();

    if (shadow == false) {
      // Get the current location
      Double latitude = 0.0, longitude = 0.0;
      if (location != null) {
        latitude = location.getLatitude() * 1E6;
        longitude = location.getLongitude() * 1E6;
      }
      GeoPoint geoPoint = new GeoPoint(latitude.intValue(), longitude.intValue());
      // Convert the location to screen pixles
      Point point = new Point();
      projection.toPixels(geoPoint, point);
      // Start Drawing
      Paint paint = new Paint();
      paint.setAntiAlias(true);
      paint.setARGB(150, 238, 17, 100);
      canvas.drawCircle(point.x, point.y, mRadius + 4, paint);
      paint.setARGB(255, 255, 255, 0);
      canvas.drawCircle(point.x, point.y, mRadius + 2, paint);
      paint.setARGB(250, 255, 0, 0);
      canvas.drawCircle(point.x, point.y, mRadius, paint);
    }
    super.draw(canvas, mapView, shadow);
  }
    @SuppressLint("DrawAllocation")
    @Override
    protected void onDraw(Canvas canvas) {
      // 移动中心
      canvas.translate(mWidth / 2 - 50, mHeight / 2);
      // 画中心圆
      canvas.drawCircle(0, 0, mCenterRadius, mCenterPaint);
      // 是否显示中心圆外的小圆环
      if (mHighlightCenter || mlittleLightCenter) {
        int c = mCenterPaint.getColor();
        mCenterPaint.setStyle(Paint.Style.STROKE);
        if (mHighlightCenter) {
          mCenterPaint.setAlpha(0xFF);
        } else if (mlittleLightCenter) {
          mCenterPaint.setAlpha(0x90);
        }
        canvas.drawCircle(0, 0, mCenterRadius + mCenterPaint.getStrokeWidth(), mCenterPaint);

        mCenterPaint.setStyle(Paint.Style.FILL);
        mCenterPaint.setColor(c);
      }
      // 画色环
      canvas.drawOval(
          new RectF(-mCircleRadius, -mCircleRadius, mCircleRadius, mCircleRadius), mCirclePaint);
      // 画黑白渐变块
      if (mDownInCircle) {
        mRectColors[1] = mCenterPaint.getColor();
      }
      mRectShader =
          new LinearGradient(
              0, mRectTop, 0, mRectBottom, mRectColors, null, Shader.TileMode.MIRROR);
      mRectPaint.setShader(mRectShader);
      canvas.drawRect(mRectLeft, mRectTop, mRectRight, mRectBottom, mRectPaint);
      float offset = mLinePaint.getStrokeWidth() / 2;
      canvas.drawLine(
          mRectLeft - offset,
          mRectTop - offset * 2,
          mRectLeft - offset,
          mRectBottom + offset * 2,
          mLinePaint); // 左
      canvas.drawLine(
          mRectLeft - offset * 2,
          mRectTop - offset,
          mRectRight + offset * 2,
          mRectTop - offset,
          mLinePaint); // 上
      canvas.drawLine(
          mRectRight + offset,
          mRectTop - offset * 2,
          mRectRight + offset,
          mRectBottom + offset * 2,
          mLinePaint); // 右
      canvas.drawLine(
          mRectLeft - offset * 2,
          mRectBottom + offset,
          mRectRight + offset * 2,
          mRectBottom + offset,
          mLinePaint); // 下
      super.onDraw(canvas);
    }
Example #23
0
  Bitmap drawEye() {
    Paint paint_eyebg = new Paint();
    paint_eyebg.setColor(Color.parseColor("#EDEDED"));

    Paint paint_eyerim = new Paint();
    paint_eyerim.setColor(Color.parseColor("#F2E16C"));

    Paint paint_eyeinside = new Paint();
    paint_eyeinside.setColor(Color.parseColor("#FFFFFF"));

    Paint paint_red = new Paint();
    paint_red.setColor(Color.parseColor("#FFE342"));

    Paint paint_black = new Paint();
    paint_black.setColor(Color.parseColor("#000000"));

    Bitmap bg = Bitmap.createBitmap(480, 800, Bitmap.Config.ARGB_8888);
    Canvas canvas_eye = new Canvas(bg);

    Bitmap bg_eyeinside =
        Bitmap.createBitmap(bg.getWidth(), bg.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas_bg_inside = new Canvas(bg_eyeinside);
    canvas_bg_inside.drawOval(new RectF(240, 200, 300, 280), paint_red);
    canvas_bg_inside.drawBitmap(bg_eyeinside, 0, 0, null);

    canvas_eye.drawCircle(230, 200, 60, paint_eyebg);
    canvas_eye.drawCircle(230, 200, 50, paint_eyebg);
    canvas_eye.drawBitmap(bg_eyeinside, -40, -40, null);
    canvas_eye.drawCircle(230, 200, 35, paint_eyeinside);
    canvas_eye.drawCircle(220, 200, 20, paint_black);
    canvas_eye.drawCircle(220, 200, 2, paint_eyebg);

    return bg;
  }
Example #24
0
 @Override
 public void draw(Canvas canvas) {
   canvas.drawCircle(radius, radius, radius, mPaint);
   if (mStrokePaint != null) {
     canvas.drawCircle(radius, radius, mStrokeRadius, mStrokePaint);
   }
 }
Example #25
0
  @Override
  public void drawEffects(Canvas canvas) {
    if (firing) {
      float radius = POWER_CIRCLE_RADIUS * powerLevel / MAX_POWER_LEVEL;
      if (radius > 0f) {
        tempPaint.set(paint);

        paint.setStyle(Style.FILL);
        paint.setColor(Color.GRAY);

        paint.setStrokeWidth(radius);
        canvas.drawLine(getX(), getY(), fireTarget.getX(), fireTarget.getY(), paint);

        canvas.drawCircle(fireTarget.getX(), fireTarget.getY(), radius * .7f, paint);

        paint.setColor(Color.WHITE);
        canvas.drawCircle(getX(), getY(), radius, paint);
        canvas.drawCircle(fireTarget.getX(), fireTarget.getY(), radius * .45f, paint);

        paint.setStrokeWidth(radius * .5f);
        canvas.drawLine(getX(), getY(), fireTarget.getX(), fireTarget.getY(), paint);

        paint.set(tempPaint);
      }
    }
  }
  @Override
  protected void onDraw(Canvas canvas) {
    if (getDrawable() == null) {
      return;
    }

    canvas.drawCircle(getWidth() / 2, getHeight() / 2, mDrawableRadius, mBitmapPaint);
    if (mBorderWidth != 0) {
      canvas.save();
      canvas.rotate(20, getWidth() / 2, getHeight() / 2);
      canvas.drawCircle(getWidth() / 2, getHeight() / 2, mBorderRadius, mBorderPaint);
      canvas.restore();
    }

    if (mShowFlag && mFlagText != null) {
      canvas.drawArc(mBorderRect, 40, 100, false, mFlagBackgroundPaint);
      mFlagTextPaint.getTextBounds(mFlagText, 0, mFlagText.length(), mFlagTextBounds);
      canvas.drawText(
          mFlagText,
          getWidth() / 2,
          (3 + FloatMath.cos((float) (Math.PI * 5 / 18))) * getHeight() / 4
              + mFlagTextBounds.height() / 3,
          mFlagTextPaint);
    }
  }
  protected void onDraw(Canvas canvas) {
    int paintSize = ApplicationManager.getPaintSize();
    boolean showPaintSize = ApplicationManager.isShowPaintSize();
    if (paintSize > 0 && showPaintSize) {
      paint.setAlpha(100);
      canvas.drawCircle(CX, CY, paintSize / 2, paint);
      paint.setAlpha(50);
      canvas.drawCircle(CX, CY, (int) (paintSize / (1.5)), paint);
    }

    /*
    paint.setAlpha(255);
    paint.setTypeface(FontFactory.getFont1(getContext()));
    paint.setTextSize(20f);
    canvas.drawText("Choose your color here", 10, 20,paint);
    */

    // Immagini ai bordi
    /*
    if(lt != null) {
    	canvas.drawBitmap(lt, 0,0, paint);
    }
    if(lb != null) {
    	canvas.drawBitmap(lb, 0,SCREEN_HEIGHT-CORNER_DIM, paint);
    }
    if(rt != null) {
    	canvas.drawBitmap(rt, SCREEN_WIDTH-CORNER_DIM,0, paint);
    }
    if(rb != null) {
    	canvas.drawBitmap(rb, SCREEN_WIDTH-CORNER_DIM,SCREEN_HEIGHT-CORNER_DIM, paint);
    }
    */
  }
  private void drawPoint(
      float startX,
      float startY,
      float stopX,
      float stopY,
      float endX,
      float pointRadius,
      Canvas canvas) {
    // NONE,BEGIN,END,ALL
    switch (getLinePointStyle()) {
      case NONE:
        break;
      case BEGIN:
        canvas.drawCircle(startX, startY, pointRadius, getPointPaint());
        break;
      case END:
        canvas.drawCircle(endX, stopY, pointRadius, getPointPaint());
        break;
      case ALL:
        canvas.drawCircle(startX, startY, pointRadius, getPointPaint());

        canvas.drawCircle(endX, stopY, pointRadius, getPointPaint());
        break;
      default:
        break;
    }
  }
  @Override
  protected void onDraw(Canvas canvas) {
    // avoids drawing too much
    canvas.drawBitmap(mBitmap, xoffset, yoffset, mBitmapPaint);
    Paint paintBlue = new Paint();
    paintBlue.setStyle(Paint.Style.STROKE);
    paintBlue.setStrokeWidth(3);
    paintBlue.setTextSize(ROW_HEIGHT);
    paintBlue.setColor(Color.WHITE);
    canvas.drawText("X:" + x0, 10, VERTICAL_MARGIN, paintBlue);
    canvas.drawText("Y:" + y0, 10, VERTICAL_MARGIN + 32, paintBlue);
    canvas.drawText("scale:" + scale, 10, VERTICAL_MARGIN + 32 * 2, paintBlue);

    if (mode == ZOOM) {
      float w = width / scaleFactor;
      float h = height / scaleFactor;
      Paint paint = new Paint();
      paint.setStyle(Paint.Style.STROKE);
      paint.setStrokeWidth(3);
      paint.setTextSize(ROW_HEIGHT);
      paint.setColor(Color.RED);
      canvas.drawCircle(mid.x, mid.y, Math.min(w, h), paint);
      canvas.drawCircle(mid.x, mid.y, 5, paint);
      canvas.drawText("Scale:" + scale * scaleFactor, width / 2, height * 0.95f, paint);
      canvas.drawText("Mid:" + mid.x + "," + mid.y, width / 2, height * 0.95f + ROW_HEIGHT, paint);
    }
    // stops only after drawing a last time
    invalidate();
  }
Example #30
0
  @Override
  public void onDraw(Canvas canvas) {
    loadBitmap();

    if (image != null) {
      shader =
          new BitmapShader(
              Bitmap.createScaledBitmap(image, canvas.getWidth(), canvas.getHeight(), false),
              Shader.TileMode.CLAMP,
              Shader.TileMode.CLAMP);
      paint.setShader(shader);
      int circleCenter = viewWidth / 2;

      canvas.drawCircle(
          circleCenter + borderWidth,
          circleCenter + borderWidth,
          circleCenter + borderWidth - 4.0f,
          paintBorder);

      if ((getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK)
          == Configuration.SCREENLAYOUT_SIZE_LARGE) {
        canvas.drawCircle(
            circleCenter + borderWidth, circleCenter + borderWidth, circleCenter - 2.0f, paint);

      } else {
        canvas.drawCircle(
            circleCenter + borderWidth, circleCenter + borderWidth, circleCenter - 4.0f, paint);
      }

      //			canvas.drawCircle(circleCenter + borderWidth, circleCenter + borderWidth, circleCenter -
      // 4.0f, paint);
    }
  }