android.graphics.Path#offset ( )源码实例Demo

下面列出了android.graphics.Path#offset ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: cythara   文件: CanvasPainter.java
private void drawIndicator() {
    float xPos = x + (getNearestDeviation() * gaugeWidth / MAX_DEVIATION);
    float yPosition = y * 1.15f;

    Matrix matrix = new Matrix();
    float scalingFactor = numbersPaint.getTextSize() / 3;
    matrix.setScale(scalingFactor, scalingFactor);

    Path indicator = new Path();
    indicator.moveTo(0, -2);
    indicator.lineTo(1, 0);
    indicator.lineTo(-1, 0);
    indicator.close();

    indicator.transform(matrix);

    indicator.offset(xPos, yPosition);
    canvas.drawPath(indicator, gaugePaint);
}
 
源代码2 项目: UltimateAndroid   文件: PathInfo.java
PathInfo(Path path, float width, float height) {
    this.path = path;

    float tmpWidth = width;
    float tmpHeight = height;
    RectF bounds = new RectF();
    path.computeBounds(bounds, true);
    if(width <= 0 && height <= 0) {
        tmpWidth = (float) Math.ceil(bounds.width());
        tmpHeight = (float) Math.ceil(bounds.height());
        path.offset(-1 * (float) Math.floor(bounds.left),
                -1 * (float) Math.round(bounds.top));
    }

    this.width = tmpWidth;
    this.height = tmpHeight;
}
 
源代码3 项目: UltimateAndroid   文件: PathInfo.java
PathInfo(Path path, float width, float height) {
    this.path = path;

    float tmpWidth = width;
    float tmpHeight = height;
    RectF bounds = new RectF();
    path.computeBounds(bounds, true);
    if(width <= 0 && height <= 0) {
        tmpWidth = (float) Math.ceil(bounds.width());
        tmpHeight = (float) Math.ceil(bounds.height());
        path.offset(-1 * (float) Math.floor(bounds.left),
                -1 * (float) Math.round(bounds.top));
    }

    this.width = tmpWidth;
    this.height = tmpHeight;
}
 
源代码4 项目: EhViewer   文件: CardBgTest.java
private void doGenCardBg(OutputStream os, int color, float radius, float base,
        float topAlpha, float topOffset, float topBlur,
        float bottomAlpha, float bottomOffset, float bottomBlur) throws FileNotFoundException {

    Path path = getPath(radius, base);
    path.offset(MAX_SIZE / 2, MAX_SIZE / 2);

    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.DITHER_FLAG);
    paint.setColor(color);
    Bitmap bitmap = Bitmap.createBitmap(MAX_SIZE, MAX_SIZE, Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);

    // Draw bottom
    paint.setShadowLayer(bottomBlur, 0, bottomOffset, getColor(bottomAlpha));
    canvas.drawPath(path, paint);

    // Draw top
    paint.setShadowLayer(topBlur, 0, topOffset, getColor(topAlpha));
    canvas.drawPath(path, paint);

    bitmap.compress(Bitmap.CompressFormat.PNG, 100, os);
}
 
源代码5 项目: android_9.0.0_r45   文件: Gesture.java
/**
 * Creates a bitmap of the gesture with a transparent background.
 * 
 * @param width
 * @param height
 * @param inset
 * @param color
 * @return the bitmap
 */
public Bitmap toBitmap(int width, int height, int inset, int color) {
    final Bitmap bitmap = Bitmap.createBitmap(width, height,
            Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(bitmap);

    final Paint paint = new Paint();
    paint.setAntiAlias(BITMAP_RENDERING_ANTIALIAS);
    paint.setDither(BITMAP_RENDERING_DITHER);
    paint.setColor(color);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeJoin(Paint.Join.ROUND);
    paint.setStrokeCap(Paint.Cap.ROUND);
    paint.setStrokeWidth(BITMAP_RENDERING_WIDTH);

    final Path path = toPath();
    final RectF bounds = new RectF();
    path.computeBounds(bounds, true);

    final float sx = (width - 2 * inset) / bounds.width();
    final float sy = (height - 2 * inset) / bounds.height();
    final float scale = sx > sy ? sy : sx;
    paint.setStrokeWidth(2.0f / scale);

    path.offset(-bounds.left + (width - bounds.width() * scale) / 2.0f,
            -bounds.top + (height - bounds.height() * scale) / 2.0f);

    canvas.translate(inset, inset);
    canvas.scale(scale, scale);

    canvas.drawPath(path, paint);

    return bitmap;
}
 
源代码6 项目: zone-sdk   文件: WaveHelper.java
private Bitmap getWave() {
    int count = (int) Math.ceil(width / mLength);

    canvas.drawColor(Color.YELLOW, PorterDuff.Mode.CLEAR);

    Path path = new Path();
    path.moveTo(0, 0);
    for (int i = 0; i < count * 2; i++) {
        path.quadTo(mLength / 4 + i * mLength, mAmplitude * 2, mLength / 2 + i * mLength, 0);
        path.quadTo(mLength * 3 / 4 + i * mLength, -mAmplitude * 2, mLength + i * mLength, 0);
    }
    //rectf.height()+mAmplitude 是因为进度为100的时候 下面不会出现暴露的假象
    path.rLineTo(0, height + mAmplitude);
    path.rLineTo(-count * 2 * mLength, 0);
    path.close();


    //弄到进度为0的位置
    path.offset(0, height + mAmplitude);
    //通过进度计算应该往上偏移多少
    float progressOffset = (height + mAmplitude * 2) * mLevelProgress;
    path.offset(0, -progressOffset);

    //计算水平速度
    path.offset(-speedOffsetX - offsetXRadioOfLength * mLength, 0);
    canvas.drawPath(path, mPaint);
    return waveBitmap;
}
 
源代码7 项目: FontDrawable   文件: FontDrawable.java
private void applyOffset(Path path, RectF textBounds) {
    Rect viewBounds = getBounds();
    float startX = viewBounds.centerX() - (textBounds.width() / 2);
    float offsetX = startX - textBounds.left;
    float startY = viewBounds.centerY() - (textBounds.height() / 2);
    float offsetY = startY - (textBounds.top);
    path.offset(offsetX, offsetY);
}
 
源代码8 项目: OpenMapKitAndroid   文件: SafeTranslatedPath.java
@Override
public void addPath(Path src, float dx, float dy) {
    boolean safePath = src instanceof SafeTranslatedPath;
    if (!safePath) {
        src.offset(xOffset, yOffset);
    }
    super.addPath(src, dx, dy);
    if (!safePath) {
        src.offset(-xOffset, -yOffset);
    }
}
 
源代码9 项目: OpenMapKitAndroid   文件: SafeTranslatedPath.java
@Override
public void addPath(Path src) {
    boolean safePath = src instanceof SafeTranslatedPath;
    if (!safePath) {
        src.offset(xOffset, yOffset);
    }
    super.addPath(src);
    if (!safePath) {
        src.offset(-xOffset, -yOffset);
    }
}
 
@Override public void transform(Canvas canvas, float currentFillPhase, View view) {
  cacheDimensions(view.getWidth(), view.getHeight());
  Path path = buildClippingPath();
  path.offset(0, height * -currentFillPhase);
  canvas.clipPath(path, Region.Op.DIFFERENCE);
}
 
@Override public void transform(Canvas canvas, float currentFillPhase, View view) {
  cacheDimensions(view.getWidth(), view.getHeight());
  Path path = buildClippingPath();
  path.offset(0, height * -currentFillPhase);
  canvas.clipPath(path, Region.Op.DIFFERENCE);
}