当前位置: 首页>>代码示例>>Java>>正文


Java Canvas.concat方法代码示例

本文整理汇总了Java中android.graphics.Canvas.concat方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.concat方法的具体用法?Java Canvas.concat怎么用?Java Canvas.concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Canvas的用法示例。


在下文中一共展示了Canvas.concat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawIcon

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void drawIcon(Canvas canvas, float fraction, Drawable drawable, int colorOfIcon,
                     WidthAndHeightOfView widthAndHeightOfView) {
    int centerX = widthAndHeightOfView.getWidth() / 2;
    int centerY = widthAndHeightOfView.getHeight() / 2 - 150;
    canvas.save();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    float newFraction = (fraction - 0.65f) / 0.35f;
    paint.setColor(Color.parseColor("#e53935"));
    canvas.drawCircle(centerX, centerY - 50, 100 * (1 - newFraction), paint);
    paint.setColor(Color.parseColor("#fdd835"));
    canvas.drawCircle(centerX -35, centerY + 35,100 * (1 - newFraction), paint);
    paint.setColor(Color.parseColor("#1e88e5"));
    canvas.drawCircle(centerX + 35, centerY + 35, 100 * (1 - newFraction), paint);
    canvas.restore();
    canvas.save();
    Path path = new Path();
    Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
    Matrix matrix = new Matrix();
    matrix.postScale(1.7f, 1.7f, centerX, centerY);
    canvas.concat(matrix);
    path.addCircle(centerX, centerY, bitmap.getHeight() * 1.5f * newFraction, Path.Direction.CW);
    canvas.clipPath(path);
    canvas.drawBitmap(bitmap, centerX - bitmap.getWidth() / 2, centerY - bitmap.getHeight() / 2, paint);
    canvas.restore();
}
 
开发者ID:JoshuaRogue,项目名称:FancyView,代码行数:27,代码来源:RYBDrawStrategyStateTwo.java

示例2: onCaptureSharedElementSnapshot

import android.graphics.Canvas; //导入方法依赖的package包/类
public Parcelable onCaptureSharedElementSnapshot(View sharedElement, Matrix viewToGlobalMatrix, RectF screenBounds) {
    Bitmap bitmap;
    if (sharedElement instanceof ImageView) {
        ImageView imageView = (ImageView) sharedElement;
        Drawable d = imageView.getDrawable();
        Drawable bg = imageView.getBackground();
        if (d != null && bg == null) {
            bitmap = createDrawableBitmap(d);
            if (bitmap != null) {
                Bundle bundle = new Bundle();
                bundle.putParcelable(BUNDLE_SNAPSHOT_BITMAP, bitmap);
                bundle.putString(BUNDLE_SNAPSHOT_IMAGE_SCALETYPE, imageView.getScaleType().toString());
                if (imageView.getScaleType() != ScaleType.MATRIX) {
                    return bundle;
                }
                float[] values = new float[9];
                imageView.getImageMatrix().getValues(values);
                bundle.putFloatArray(BUNDLE_SNAPSHOT_IMAGE_MATRIX, values);
                return bundle;
            }
        }
    }
    int bitmapWidth = Math.round(screenBounds.width());
    int bitmapHeight = Math.round(screenBounds.height());
    bitmap = null;
    if (bitmapWidth > 0 && bitmapHeight > 0) {
        float scale = Math.min(1.0f, ((float) MAX_IMAGE_SIZE) / ((float) (bitmapWidth * bitmapHeight)));
        bitmapWidth = (int) (((float) bitmapWidth) * scale);
        bitmapHeight = (int) (((float) bitmapHeight) * scale);
        if (this.mTempMatrix == null) {
            this.mTempMatrix = new Matrix();
        }
        this.mTempMatrix.set(viewToGlobalMatrix);
        this.mTempMatrix.postTranslate(-screenBounds.left, -screenBounds.top);
        this.mTempMatrix.postScale(scale, scale);
        bitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        canvas.concat(this.mTempMatrix);
        sharedElement.draw(canvas);
    }
    return bitmap;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:43,代码来源:SharedElementCallback.java

示例3: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Shape shape, Canvas canvas, Paint paint) {
    canvas.save();
    Rect bounds = canvas.getClipBounds();

    // bottom etched line.
    if (mBottomEtchedPaint != null) shape.draw(canvas, mBottomEtchedPaint);
    canvas.restore();
    canvas.save();

    // separator.
    canvas.concat(getSeparatorPaintMatrix(bounds));
    shape.draw(canvas, mSeparatorPaint);
    canvas.restore();
    canvas.save();

    // top etched line.
    canvas.concat(getTopEtchedPaintMatrix(bounds));
    if (mTopEtchedPaint != null) shape.draw(canvas, mTopEtchedPaint);
    canvas.restore();
    canvas.save();

    // background.
    canvas.concat(getBackgroundPaintMatrix(bounds));
    shape.draw(canvas, mBackgroundPaint);
    canvas.restore();
    canvas.save();

    // selected.
    canvas.concat(getSelectedPaintMatrix(bounds));
    if (mSelectedPaint != null) {

        // we'll set the selected color on onDraw event since we don't know drawable height up to here.
        Shader shader = new LinearGradient(0, 0, 0, mRowHeight, mStartColor, mEndColor, Shader.TileMode.MIRROR);
        mSelectedPaint.setShader(shader);

        shape.draw(canvas, mSelectedPaint);
    }
}
 
开发者ID:hh-in-zhuzhou,项目名称:ShangHanLun,代码行数:40,代码来源:ATableViewCellDrawable.java

示例4: drawLeftEdge

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawLeftEdge(DepthLayout dl, Canvas canvas, float[] src) {
    float[] dst = new float[]{dl.getTopLeft().x, dl.getTopLeft().y, dl.getTopLeftBack().x, dl.getTopLeftBack().y, dl.getBottomLeftBack().x, dl.getBottomLeftBack().y, dl.getBottomLeft().x, dl.getBottomLeft().y};
    int count = canvas.save();
    matrix.setPolyToPoly(src, 0, dst, 0, src.length >> 1);
    canvas.concat(matrix);
    drawRectancle(dl, canvas);
    drawShadow(dl.getTopLeft(), dl.getBottomLeft(), 0, canvas, dl);

    canvas.restoreToCount(count);

}
 
开发者ID:MSay2,项目名称:Mire,代码行数:12,代码来源:DepthRendrer.java

示例5: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    if (isAnimatedLogoShowing()) {
        if (mFadeAnimation != null) mFadeAnimation.cancel();
        // Free the old bitmaps to allow them to be GC'd.
        mLogo = null;
        mNewLogo = null;

        canvas.save();
        canvas.concat(mAnimatedLogoMatrix);
        mAnimatedLogoDrawable.draw(canvas);
        canvas.restore();
    } else {
        if (mLogo != null && mTransitionAmount < 0.5f) {
            mPaint.setAlpha((int) (255 * 2 * (0.5f - mTransitionAmount)));
            canvas.save();
            canvas.concat(mLogoMatrix);
            canvas.drawBitmap(mLogo, 0, 0, mPaint);
            canvas.restore();
        }

        if (mNewLogo != null && mTransitionAmount > 0.5f) {
            mPaint.setAlpha((int) (255 * 2 * (mTransitionAmount - 0.5f)));
            canvas.save();
            canvas.concat(mNewLogoMatrix);
            canvas.drawBitmap(mNewLogo, 0, 0, mPaint);
            canvas.restore();
        }
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:31,代码来源:LogoView.java

示例6: drawIconThree

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 根据角度绘制图标的类
 * @param canvas 画布
 * @param degree 角度
 * @param icon 图标
 * @param width view宽度
 * @param height view高度
 */
private void drawIconThree(Canvas canvas, int degree, Bitmap icon, int width, int height) {
    Camera camera = new Camera();
    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    int centerX = width / 2;
    int centerY = height / 2 - 200;
    int x = centerX - icon.getWidth()/2;
    int y = centerY - icon.getHeight()/2;
    Matrix matrix = new Matrix();
    matrix.postScale(1.7f, 1.7f, centerX, centerY);
    //绘制上半部分
    canvas.save();
    canvas.concat(matrix);
    canvas.clipRect(x, y, x + icon.getWidth(), y + icon.getHeight() / 2);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();

    //绘制下半部分
    canvas.save();
    canvas.concat(matrix);
    if (degree <= 90)
        canvas.clipRect(x, y, x + icon.getWidth(), y + icon.getHeight() / 2);
    else
        canvas.clipRect(x, y + icon.getHeight() / 2, x + icon.getWidth(), y + icon.getHeight());
    canvas.translate(centerX, centerY);
    camera.save();
    camera.rotateX(180 - degree);
    camera.applyToCanvas(canvas);
    camera.restore();
    canvas.translate(-centerX, -centerY);
    canvas.drawBitmap(icon, x, y, paint);
    canvas.restore();
}
 
开发者ID:JoshuaRogue,项目名称:FancyView,代码行数:41,代码来源:RotationDrawStrategy.java

示例7: draw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void draw(Canvas canvas) {
  if (mRotationAngle <= 0
      && (mExifOrientation == ExifInterface.ORIENTATION_UNDEFINED
          || mExifOrientation == ExifInterface.ORIENTATION_NORMAL)) {
    super.draw(canvas);
    return;
  }
  int saveCount = canvas.save();
  canvas.concat(mRotationMatrix);
  super.draw(canvas);
  canvas.restoreToCount(saveCount);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:OrientedDrawable.java

示例8: rotateCanvas

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 旋转画布
 *
 * @param canvas
 */
private void rotateCanvas(Canvas canvas) {
    matrixCanvas.reset();
    camera.save();
    camera.rotateX(canvasRotateX);
    camera.rotateY(canvasRotateY);
    camera.getMatrix(matrixCanvas);
    camera.restore();
    int matrixCenterX = mCy / 2;
    int matrixCenterY = mCy / 2;
    matrixCanvas.preTranslate(-matrixCenterX, -matrixCenterY);
    matrixCanvas.postTranslate(matrixCenterX, matrixCenterY);
    canvas.concat(matrixCanvas);
}
 
开发者ID:aohanyao,项目名称:SafeView,代码行数:19,代码来源:SafeView.java

示例9: drawShadow

import android.graphics.Canvas; //导入方法依赖的package包/类
public void drawShadow(Canvas canvas, DepthFAB dl, Drawable shadow) 
{
          shadow.setBounds(-padding, -padding, dl.getWidth() + padding, dl.getHeight() + padding);
          float[] src = new float[]{0, 0, dl.getWidth(), 0, dl.getWidth(), dl.getHeight(), 0, dl.getHeight()};
          float[] dst = new float[]{topLeftBack.x, topLeftBack.y, topRightBack.x, topRightBack.y, bottomRightBack.x, bottomRightBack.y, bottomLeftBack.x, bottomLeftBack.y};
          int count = canvas.save();
          matrix.setPolyToPoly(src, 0, dst, 0, src.length >> 1);
          canvas.concat(matrix);
          shadow.draw(canvas);
          canvas.restoreToCount(count);
      }
 
开发者ID:MSay2,项目名称:Mire,代码行数:12,代码来源:DepthFAB.java

示例10: drawBottomEdge

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawBottomEdge(DepthRelativeLayout dl, Canvas canvas, float[] src) {

        float[] dst = new float[]{dl.getBottomLeft().x, dl.getBottomLeft().y, dl.getBottomRight().x, dl.getBottomRight().y, dl.getBottomRightBack().x, dl.getBottomRightBack().y, dl.getBottomLeftBack().x, dl.getBottomLeftBack().y};
        int count = canvas.save();
        matrix.setPolyToPoly(src, 0, dst, 0, dst.length >> 1);
        canvas.concat(matrix);
        drawRectancle(dl, canvas);
        drawShadow(dl.getBottomLeft(), dl.getBottomRight(), 0, canvas, dl);
        canvas.restoreToCount(count);
    }
 
开发者ID:florent37,项目名称:Depth,代码行数:11,代码来源:DepthRelativeLayoutContainer.java

示例11: drawLeftEdge

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawLeftEdge(DepthRelativeLayout dl, Canvas canvas, float[] src) {
    float[] dst = new float[]{dl.getTopLeft().x, dl.getTopLeft().y, dl.getTopLeftBack().x, dl.getTopLeftBack().y, dl.getBottomLeftBack().x, dl.getBottomLeftBack().y, dl.getBottomLeft().x, dl.getBottomLeft().y};
    int count = canvas.save();
    matrix.setPolyToPoly(src, 0, dst, 0, src.length >> 1);
    canvas.concat(matrix);
    drawRectancle(dl, canvas);
    drawShadow(dl.getTopLeft(), dl.getBottomLeft(), 0, canvas, dl);

    canvas.restoreToCount(count);

}
 
开发者ID:florent37,项目名称:Depth,代码行数:12,代码来源:DepthRelativeLayoutContainer.java

示例12: drawRightEdge

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawRightEdge(DepthRelativeLayout dl, Canvas canvas, float[] src) {
    float[] dst = new float[]{dl.getTopRight().x, dl.getTopRight().y, dl.getTopRightBack().x, dl.getTopRightBack().y, dl.getBottomRightBack().x, dl.getBottomRightBack().y, dl.getBottomRight().x, dl.getBottomRight().y};
    int count = canvas.save();
    matrix.setPolyToPoly(src, 0, dst, 0, src.length >> 1);
    canvas.concat(matrix);
    drawRectancle(dl, canvas);
    drawShadow(dl.getTopRight(), dl.getBottomRight(), -180f, canvas, dl);
    canvas.restoreToCount(count);
}
 
开发者ID:florent37,项目名称:Depth,代码行数:10,代码来源:DepthRelativeLayoutContainer.java

示例13: drawCenterClouds

import android.graphics.Canvas; //导入方法依赖的package包/类
private void drawCenterClouds(Canvas canvas, int width, int height) {
    Matrix matrix = mMatrix;
    matrix.reset();
    float dragPercent = Math.min(1f, Math.abs(mPercent));

    if (isInEditMode()) {
        dragPercent = 1;
        mHeaderHeight = height;
    }

    float scale;
    float overdragPercent = 0;
    boolean overdrag = false;

    if (mPercent > 1.0f) {
        overdrag = true;
        // Here we want know about how mach percent of over drag we done
        overdragPercent = Math.abs(1.0f - mPercent);
    }

    float scalePercentDelta = dragPercent - SCALE_START_PERCENT;
    if (scalePercentDelta > 0) {
        float scalePercent = scalePercentDelta / (1.0f - SCALE_START_PERCENT);
        scale = CENTER_CLOUDS_INITIAL_SCALE + (CENTER_CLOUDS_FINAL_SCALE - CENTER_CLOUDS_INITIAL_SCALE) * scalePercent;
    } else {
        scale = CENTER_CLOUDS_INITIAL_SCALE;
    }

    float parallaxPercent = 0;
    boolean parallax = false;
    // Current y position of clouds
    float dragYOffset = mHeaderHeight * dragPercent;
    // Position when should start parallax scrolling
    int startParallaxHeight = mHeaderHeight - mCloudCenter.height()/2;

    if (dragYOffset > startParallaxHeight) {
        parallax = true;
        parallaxPercent = dragYOffset - startParallaxHeight;
    }

    float offsetX = (width / 2) - mCloudCenter.width() / 2;
    float offsetY = dragYOffset
            - (parallax ? mCloudCenter.height()/2 + parallaxPercent : mCloudCenter.height()/2);

    float sx = overdrag ? scale + overdragPercent / 4 : scale;
    float sy = overdrag ? scale + overdragPercent / 2 : scale;

    if (isRefreshing && !overdrag) {
        if (checkCurrentAnimationPart(AnimationPart.FIRST)) {
            sx = scale - (getAnimationPartValue(AnimationPart.FIRST) / LOADING_ANIMATION_COEFFICIENT) / 8;
        } else if (checkCurrentAnimationPart(AnimationPart.SECOND)) {
            sx = scale - (getAnimationPartValue(AnimationPart.SECOND) / LOADING_ANIMATION_COEFFICIENT) / 8;
        } else if (checkCurrentAnimationPart(AnimationPart.THIRD)) {
            sx = scale + (getAnimationPartValue(AnimationPart.THIRD) / LOADING_ANIMATION_COEFFICIENT) / 6;
        } else if (checkCurrentAnimationPart(AnimationPart.FOURTH)) {
            sx = scale + (getAnimationPartValue(AnimationPart.FOURTH) / LOADING_ANIMATION_COEFFICIENT) / 6;
        }
        sy = sx;
    }


    matrix.postScale(sx, sy, mCloudCenter.width() / 2, 0);

    if (offsetY + sy * mCloudCenter.height() < height + 2) {
        offsetY = height + 2 - sy * mCloudCenter.height();
    }

    final int saveCount = canvas.getSaveCount();
    canvas.save();
    canvas.translate(offsetX, offsetY);
    canvas.concat(matrix);
    mCloudCenter.draw(canvas);
    canvas.restoreToCount(saveCount);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:75,代码来源:TaurusHeader.java

示例14: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    float progress = mProgress;
    int c1 = canvas.save();
    int len = mItemList.size();

    for (int i = 0; i < len; i++) {

        canvas.save();
        StoreHouseBarItem storeHouseBarItem = mItemList.get(i);
        float offsetX = mOffsetX + storeHouseBarItem.midPoint.x;
        float offsetY = mOffsetY + storeHouseBarItem.midPoint.y;

        if (mIsInLoading) {
            storeHouseBarItem.getTransformation(getDrawingTime(), mTransformation);
            canvas.translate(offsetX, offsetY);
        } else {

            if (progress == 0) {
                storeHouseBarItem.resetPosition(mHorizontalRandomness);
                continue;
            }

            float startPadding = (1 - mInternalAnimationFactor) * i / len;
            float endPadding = 1 - mInternalAnimationFactor - startPadding;

            // done
            if (progress == 1 || progress >= 1 - endPadding) {
                canvas.translate(offsetX, offsetY);
                storeHouseBarItem.setAlpha(mBarDarkAlpha);
            } else {
                float realProgress;
                if (progress <= startPadding) {
                    realProgress = 0;
                } else {
                    realProgress = Math.min(1, (progress - startPadding) / mInternalAnimationFactor);
                }
                offsetX += storeHouseBarItem.translationX * (1 - realProgress);
                offsetY += -mDropHeight * (1 - realProgress);
                Matrix matrix = new Matrix();
                matrix.postRotate(360 * realProgress);
                matrix.postScale(realProgress, realProgress);
                matrix.postTranslate(offsetX, offsetY);
                storeHouseBarItem.setAlpha(mBarDarkAlpha * realProgress);
                canvas.concat(matrix);
            }
        }
        storeHouseBarItem.draw(canvas);
        canvas.restore();
    }
    if (mIsInLoading) {
        invalidate();
    }
    canvas.restoreToCount(c1);
}
 
开发者ID:sathishmscict,项目名称:android-Ultra-Pull-To-Refresh,代码行数:57,代码来源:StoreHouseHeader.java

示例15: onDraw

import android.graphics.Canvas; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
    if (bubbleDrawable == null) {
        return; // couldn't resolve the URI
    }

    if (bubbleDrawable.getIntrinsicHeight() == 0 || bubbleDrawable.getIntrinsicWidth() == 0) {
        return;     // nothing to draw (empty bounds)
    }

    final Matrix mDrawMatrix = getImageMatrix();
    final int mPaddingLeft = getPaddingLeft();
    final int mPaddingTop = getPaddingTop();

    if (mDrawMatrix == null && getPaddingTop() == 0 && getPaddingLeft() == 0) {
        bubbleDrawable.draw(canvas);
    } else {
        final int saveCount = canvas.getSaveCount();
        canvas.save();

        //crop to padding api above 16
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            if (getCropToPadding()) {
                final int scrollX = getScrollX();
                final int scrollY = getScrollY();
                canvas.clipRect(scrollX + mPaddingLeft, scrollY + mPaddingTop,
                        scrollX + getRight() - getLeft() - getRight(),
                        scrollY + getBottom() - getTop() - getBottom());
            }
        }

        canvas.translate(mPaddingLeft, mPaddingTop);

        if (mDrawMatrix != null) {
            canvas.concat(mDrawMatrix);

            mDrawMatrix.getValues(matrixValues);
            final float scaleX = matrixValues[Matrix.MSCALE_X];
            final float scaleY = matrixValues[Matrix.MSCALE_Y];
            final float translateX = matrixValues[Matrix.MTRANS_X];
            final float translateY = matrixValues[Matrix.MTRANS_Y];

            final ScaleType scaleType = getScaleType();

            if (scaleType == ScaleType.CENTER) {
                bubbleDrawable.setOffsetLeft(-translateX);
                bubbleDrawable.setOffsetTop(-translateY);
                bubbleDrawable.setOffsetBottom(-translateY);
                bubbleDrawable.setOffsetRight(-translateX);
            } else if (scaleType == ScaleType.CENTER_CROP) {
                float scale = scaleX > scaleY ? 1 / scaleY : 1 / scaleX;
                bubbleDrawable.setOffsetLeft(-translateX * scale);
                bubbleDrawable.setOffsetTop(-translateY * scale);
                bubbleDrawable.setOffsetBottom(-translateY * scale);
                bubbleDrawable.setOffsetRight(-translateX * scale);
                bubbleDrawable.setScale(scale);
            } else {
                bubbleDrawable.setScale(scaleX > scaleY ? 1 / scaleY : 1 / scaleX);
            }
        }

        bubbleDrawable.draw(canvas);
        canvas.restoreToCount(saveCount);
    }
}
 
开发者ID:leochuan,项目名称:BubbleView,代码行数:66,代码来源:BubbleImageView.java


注:本文中的android.graphics.Canvas.concat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。