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


Java Matrix.reset方法代码示例

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


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

示例1: pixelsToValue

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Transforms the given array of touch positions (pixels) (x, y, x, y, ...)
 * into values on the chart.
 *
 * @param pixels
 */
public void pixelsToValue(float[] pixels) {

    Matrix tmp = mPixelToValueMatrixBuffer;
    tmp.reset();

    // invert all matrixes to convert back to the original value
    mMatrixOffset.invert(tmp);
    tmp.mapPoints(pixels);

    mViewPortHandler.getMatrixTouch().invert(tmp);
    tmp.mapPoints(pixels);

    mMatrixValueToPx.invert(tmp);
    tmp.mapPoints(pixels);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:Transformer.java

示例2: computeRect

import android.graphics.Matrix; //导入方法依赖的package包/类
private void computeRect(RectF r, View view) {
    r.set(0.0f, 0.0f, (float) view.getWidth(), (float) view.getHeight());
    Matrix m = this.mTempMatrix;
    m.reset();
    transformMatrix(m, view);
    this.mTempMatrix.mapRect(r);
    r.offset((float) view.getLeft(), (float) view.getTop());
    if (r.right < r.left) {
        float f = r.right;
        r.right = r.left;
        r.left = f;
    }
    if (r.bottom < r.top) {
        f = r.top;
        r.top = r.bottom;
        r.bottom = f;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:AnimatorProxy.java

示例3: getProperBaseMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
private void getProperBaseMatrix(RotateBitmap bitmap, Matrix matrix, boolean includeRotation) {
    float viewWidth = getWidth();
    float viewHeight = getHeight();

    float w = bitmap.getWidth();
    float h = bitmap.getHeight();
    matrix.reset();

    // We limit up-scaling to 3x otherwise the result may look bad if it's a small icon
    float widthScale = Math.min(viewWidth / w, 3.0f);
    float heightScale = Math.min(viewHeight / h, 3.0f);
    float scale = Math.min(widthScale, heightScale);

    if (includeRotation) {
        matrix.postConcat(bitmap.getRotateMatrix());
    }
    matrix.postScale(scale, scale);
    matrix.postTranslate((viewWidth  - w * scale) / 2F, (viewHeight - h * scale) / 2F);
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:20,代码来源:ImageViewTouchBase.java

示例4: drawSky

import android.graphics.Matrix; //导入方法依赖的package包/类
private void drawSky(Canvas canvas, int width, int height) {
        Matrix matrix = mMatrix;
        matrix.reset();

        int bWidth = mDrawableSky.width();//mSky.getWidth();
        int bHeight = mDrawableSky.height();//mSky.getHeight();
        float townScale = 1f * width / bWidth;
        float offsetx = 0;
        float offsety = height / 2 - bHeight / 2;

//        matrix.postScale(townScale, townScale);
//        matrix.postTranslate(offsetx, offsety);
//
//        canvas.drawBitmap(mSky, matrix, null);

        final int saveCount = canvas.getSaveCount();
        canvas.save();
        canvas.translate(offsetx, offsety);
        matrix.postScale(townScale, townScale);
        mDrawableSky.draw(canvas);
        canvas.restoreToCount(saveCount);
    }
 
开发者ID:Brave-wan,项目名称:SmartRefresh,代码行数:23,代码来源:PhoenixHeader.java

示例5: draw

import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
public void draw(Context context, Canvas canvas) {
    TextSticker textSticker = (TextSticker) sticker;
    if (textSticker.textFile == null || textSticker.textFile.exists() == false) {
        return;
    }

    TextMakingInfo textMakingInfo = textSticker.getTextMakeInfo(context);

    int canvasWidth = canvas.getWidth();
    int canvasHeight = canvas.getHeight();

    float targetWidthDP = Util.px2dp(context, canvasWidth * widthRatio);
    float textSize = targetWidthDP / textMakingInfo.getWidthTextRatio();

    textMakingInfo.setTextSize(textSize);

    Rect rect = new Rect();
    textMakingInfo.getTextRect(context, rect);

    float textRectWidth = rect.width();
    float textRectHeight = rect.height();

    Matrix matrix = new Matrix();
    matrix.reset();

    matrix.postTranslate((canvasWidth - textRectWidth) / 2, (canvasHeight - textRectHeight) / 2);
    matrix.postRotate(angle, canvasWidth / 2, canvasHeight / 2);
    matrix.postTranslate(canvasWidth / 2 * posX, canvasHeight / 2 * posY);

    canvas.setMatrix(matrix);
    canvas.saveLayerAlpha(0, 0, textRectWidth, textRectHeight, (int) (alpha * 255), Canvas.ALL_SAVE_FLAG);
    textMakingInfo.draw(context, (int) textRectWidth, (int) textRectHeight, canvas);
    canvas.restore();
    matrix.reset();
    canvas.setMatrix(matrix);
}
 
开发者ID:monthlypub,项目名称:SmingZZick_App,代码行数:38,代码来源:TextStickerAttachInfo.java

示例6: translate

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Post-translates to the specified points.  Output matrix allows for caching objects.
 *
 * @param transformedPts
 * @return
 */
public void translate(final float[] transformedPts, Matrix outputMatrix) {
    outputMatrix.reset();
    outputMatrix.set(mMatrixTouch);
    final float x = transformedPts[0] - offsetLeft();
    final float y = transformedPts[1] - offsetTop();
    outputMatrix.postTranslate(-x, -y);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:ViewPortHandler.java

示例7: centerViewPort

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * Centers the viewport around the specified position (x-index and y-value)
 * in the chart. Centering the viewport outside the bounds of the chart is
 * not possible. Makes most sense in combination with the
 * setScaleMinima(...) method.
 *
 * @param transformedPts the position to center view viewport to
 * @param view
 * @return save
 */
public void centerViewPort(final float[] transformedPts, final View view) {

    Matrix save = mCenterViewPortMatrixBuffer;
    save.reset();
    save.set(mMatrixTouch);

    final float x = transformedPts[0] - offsetLeft();
    final float y = transformedPts[1] - offsetTop();

    save.postTranslate(-x, -y);

    refresh(save, view, true);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:ViewPortHandler.java

示例8: genRotateBitmap

import android.graphics.Matrix; //导入方法依赖的package包/类
public static Bitmap genRotateBitmap(byte[] data) {
    Bitmap bMap = BitmapFactory.decodeByteArray(data, 0, data.length);
    // 自定义相机拍照需要旋转90预览支持竖屏
    Matrix matrix = new Matrix();// 矩阵
    matrix.reset();// 设置为单位矩阵
    matrix.postRotate(90);// 旋转90度
    Bitmap bMapRotate = Bitmap.createBitmap(bMap, 0, 0, bMap.getWidth(), bMap.getHeight(),
            matrix, true);
    bMap.recycle();
    bMap = null;
    System.gc();
    return bMapRotate;
}
 
开发者ID:viseator,项目名称:MontageCam,代码行数:14,代码来源:BitmapUtils.java

示例9: drawTown

import android.graphics.Matrix; //导入方法依赖的package包/类
private void drawTown(Canvas canvas, int width, int height) {
        Matrix matrix = mMatrix;
        matrix.reset();

        int bWidth = mDrawableTown.width();//mTown.getWidth();
        int bHeight = mDrawableTown.height();//mTown.getHeight();
        float townScale = 1f * width / bWidth;
        float amplification = (0.3f * Math.max(mPercent - 1, 0) + 1);
        float offsetx = width / 2 - (int) (width * amplification) / 2;
        float offsety = mHeaderHeight * 0.1f * mPercent;
        townScale = amplification * townScale;

        if (offsety + bHeight * townScale < height) {
            offsety = height - bHeight * townScale;
        }

//        matrix.postScale(townScale, townScale, mDrawableTown.width() / 2, mDrawableTown.height() / 2);
//        matrix.postTranslate(offsetx, offsety);
//        canvas.drawBitmap(mTown, matrix, null);

        final int saveCount = canvas.getSaveCount();
        canvas.save();
        canvas.translate(offsetx, offsety);
        canvas.scale(townScale, townScale);
        mDrawableTown.draw(canvas);
        canvas.restoreToCount(saveCount);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:PhoenixHeader.java

示例10: calculateRectTranslateMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
/**
 * 计算两个矩形之间的变换矩阵
 * <p>
 * unknownMatrix.mapRect(to, from)
 * 已知from矩形和to矩形,求unknownMatrix
 *
 * @param from
 * @param to
 * @param result unknownMatrix
 */
public static void calculateRectTranslateMatrix(RectF from, RectF to, Matrix result) {
    if (from == null || to == null || result == null) {
        return;
    }
    if (from.width() == 0 || from.height() == 0) {
        return;
    }
    result.reset();
    result.postTranslate(-from.left, -from.top);
    result.postScale(to.width() / from.width(), to.height() / from.height());
    result.postTranslate(to.left, to.top);
}
 
开发者ID:JJS-CN,项目名称:JBase,代码行数:23,代码来源:PinchImageView.java

示例11: zoomIn

import android.graphics.Matrix; //导入方法依赖的package包/类
public void zoomIn(float x, float y, Matrix outputMatrix) {
    outputMatrix.reset();
    outputMatrix.set(mMatrixTouch);
    outputMatrix.postScale(1.4f, 1.4f, x, y);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:ViewPortHandler.java

示例12: zoom

import android.graphics.Matrix; //导入方法依赖的package包/类
public void zoom(float scaleX, float scaleY, Matrix outputMatrix) {
    outputMatrix.reset();
    outputMatrix.set(mMatrixTouch);
    outputMatrix.postScale(scaleX, scaleY);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:ViewPortHandler.java

示例13: drawCenterClouds

import android.graphics.Matrix; //导入方法依赖的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:scwang90,项目名称:SmartRefreshLayout,代码行数:75,代码来源:TaurusHeader.java

示例14: setZoom

import android.graphics.Matrix; //导入方法依赖的package包/类
public void setZoom(float scaleX, float scaleY, Matrix outputMatrix) {
    outputMatrix.reset();
    outputMatrix.set(mMatrixTouch);
    outputMatrix.setScale(scaleX, scaleY);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:ViewPortHandler.java

示例15: drawJet

import android.graphics.Matrix; //导入方法依赖的package包/类
private void drawJet(Canvas canvas) {
    Matrix matrix = mMatrix;
    matrix.reset();

    float dragPercent = mPercent;
    float rotateAngle = 0;

    // Check overdrag
    if (dragPercent > 1.0f && !mEndOfRefreshing) {
        if (dragPercent > 2)
            dragPercent = 2;
        rotateAngle = (dragPercent - 1) * 10;
        dragPercent = 1.0f;
    }
    if (mEndOfRefreshing) {
        dragPercent = 2 - dragPercent;
    }

    float offsetX = ((mScreenWidth * dragPercent) / 2) - mJetWidthCenter;

    float offsetY = mJetTopOffset
            + (getTotalDragDistance / 2)
            * (1.0f - dragPercent)
            - mJetHeightCenter;

    if (isRefreshing) {
        if (checkCurrentAnimationPart(AnimationPart.FIRST)) {
            offsetY -= getAnimationPartValue(AnimationPart.FIRST);
        } else if (checkCurrentAnimationPart(AnimationPart.SECOND)) {
            offsetY -= getAnimationPartValue(AnimationPart.SECOND);
        } else if (checkCurrentAnimationPart(AnimationPart.THIRD)) {
            offsetY += getAnimationPartValue(AnimationPart.THIRD);
        } else if (checkCurrentAnimationPart(AnimationPart.FOURTH)) {
            offsetY += getAnimationPartValue(AnimationPart.FOURTH);
        }
    }

    matrix.setTranslate(offsetX, offsetY);

    if (dragPercent == 1.0f) {
        matrix.preRotate(rotateAngle, mJetWidthCenter, mJetHeightCenter);
    }

    canvas.drawBitmap(mJet, matrix, null);
}
 
开发者ID:tohodog,项目名称:QSRefreshLayout,代码行数:46,代码来源:PlainRefreshDraw.java


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