當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。