android.graphics.Matrix.postScale()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(417)

本文整理了Java中android.graphics.Matrix.postScale()方法的一些代码示例,展示了Matrix.postScale()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.postScale()方法的具体详情如下:
包路径:android.graphics.Matrix
类名称:Matrix
方法名:postScale

Matrix.postScale介绍

暂无

代码示例

代码示例来源:origin: PhilJay/MPAndroidChart

public void zoomOut(float x, float y, Matrix outputMatrix) {
  outputMatrix.reset();
  outputMatrix.set(mMatrixTouch);
  outputMatrix.postScale(0.7f, 0.7f, x, y);
}

代码示例来源:origin: PhilJay/MPAndroidChart

public void zoomIn(float x, float y, Matrix outputMatrix) {
  outputMatrix.reset();
  outputMatrix.set(mMatrixTouch);
  outputMatrix.postScale(1.4f, 1.4f, x, y);
}

代码示例来源:origin: PhilJay/MPAndroidChart

/**
 * Zooms out to original size.
 * @param outputMatrix
 */
public void resetZoom(Matrix outputMatrix) {
  outputMatrix.reset();
  outputMatrix.set(mMatrixTouch);
  outputMatrix.postScale(1.0f, 1.0f, 0.0f, 0.0f);
}

代码示例来源:origin: PhilJay/MPAndroidChart

public void zoom(float scaleX, float scaleY, Matrix outputMatrix) {
  outputMatrix.reset();
  outputMatrix.set(mMatrixTouch);
  outputMatrix.postScale(scaleX, scaleY);
}

代码示例来源:origin: PhilJay/MPAndroidChart

public void zoom(float scaleX, float scaleY, float x, float y, Matrix outputMatrix) {
  outputMatrix.reset();
  outputMatrix.set(mMatrixTouch);
  outputMatrix.postScale(scaleX, scaleY, x, y);
}

代码示例来源:origin: PhilJay/MPAndroidChart

/**
 * Prepares the matrix that transforms values to pixels. Calculates the
 * scale factors from the charts size and offsets.
 *
 * @param xChartMin
 * @param deltaX
 * @param deltaY
 * @param yChartMin
 */
public void prepareMatrixValuePx(float xChartMin, float deltaX, float deltaY, float yChartMin) {
  float scaleX = (float) ((mViewPortHandler.contentWidth()) / deltaX);
  float scaleY = (float) ((mViewPortHandler.contentHeight()) / deltaY);
  if (Float.isInfinite(scaleX)) {
    scaleX = 0;
  }
  if (Float.isInfinite(scaleY)) {
    scaleY = 0;
  }
  // setup all matrices
  mMatrixValueToPx.reset();
  mMatrixValueToPx.postTranslate(-xChartMin, -yChartMin);
  mMatrixValueToPx.postScale(scaleX, -scaleY);
}

代码示例来源:origin: chrisbanes/PhotoView

@Override
  public void onScale(float scaleFactor, float focusX, float focusY) {
    if (getScale() < mMaxScale || scaleFactor < 1f) {
      if (mScaleChangeListener != null) {
        mScaleChangeListener.onScaleChange(scaleFactor, focusX, focusY);
      }
      mSuppMatrix.postScale(scaleFactor, scaleFactor, focusX, focusY);
      checkAndDisplayMatrix();
    }
  }
};

代码示例来源:origin: rey5137/material

private void fillCanvasWithHole(Canvas canvas, ColorChangeTask task, float radius, boolean transparent){
  if(transparent)
    return;
  
  float scale = radius / GRADIENT_RADIUS;
  
  mMatrix.reset();
  mMatrix.postScale(scale, scale, task.x, task.y);
  RadialGradient shader = getShader(task);
  shader.setLocalMatrix(mMatrix);
  mShaderPaint.setShader(shader);
  canvas.drawRect(getBounds(), mShaderPaint);
}

代码示例来源:origin: PhilJay/MPAndroidChart

/**
 * Prepares the matrix that contains all offsets.
 *
 * @param inverted
 */
public void prepareMatrixOffset(boolean inverted) {
  mMatrixOffset.reset();
  // offset.postTranslate(mOffsetLeft, getHeight() - mOffsetBottom);
  if (!inverted)
    mMatrixOffset.postTranslate(mViewPortHandler.offsetLeft(),
        mViewPortHandler.getChartHeight() - mViewPortHandler.offsetBottom());
  else {
    mMatrixOffset
        .setTranslate(mViewPortHandler.offsetLeft(), -mViewPortHandler.offsetTop());
    mMatrixOffset.postScale(1.0f, -1.0f);
  }
}

代码示例来源:origin: bumptech/glide

@Test
public void testInitializeMatrixSetsScaleAndRotateIfFlipVertical() {
 Matrix matrix = mock(Matrix.class);
 TransformationUtils
   .initializeMatrixForRotation(ExifInterface.ORIENTATION_FLIP_VERTICAL, matrix);
 verify(matrix).setRotate(180);
 verify(matrix).postScale(-1, 1);
}

代码示例来源:origin: bumptech/glide

@Test
public void testInitializeMatrixSetsScaleAndRotateIfTranspose() {
 Matrix matrix = mock(Matrix.class);
 TransformationUtils.initializeMatrixForRotation(ExifInterface.ORIENTATION_TRANSPOSE, matrix);
 verify(matrix).setRotate(90);
 verify(matrix).postScale(-1, 1);
}

代码示例来源:origin: bumptech/glide

@Test
public void testInitializeMatrixSetsScaleAndRotateIfTransverse() {
 Matrix matrix = mock(Matrix.class);
 TransformationUtils.initializeMatrixForRotation(ExifInterface.ORIENTATION_TRANSVERSE, matrix);
 verify(matrix).setRotate(-90);
 verify(matrix).postScale(-1, 1);
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testReset() {
 final Matrix matrix = new Matrix();
 matrix.postScale(2.0f, 2.0f);
 matrix.postTranslate(1.0f, 2.0f);
 matrix.postRotate(45.0f);
 matrix.reset();
 assertThat(matrix.isIdentity())
   .isTrue();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testMapRect() {
 final Matrix matrix = new Matrix();
 matrix.postScale(2.0f, 3.0f);
 final RectF input = new RectF(1.0f, 1.0f, 2.0f, 2.0f);
 final RectF output1 = new RectF();
 matrix.mapRect(output1, input);
 assertThat(output1)
   .isEqualTo(new RectF(2.0f, 3.0f, 4.0f, 6.0f));
 matrix.postScale(-1.0f, -1.0f);
 final RectF output2 = new RectF();
 matrix.mapRect(output2, input);
 assertThat(output2)
   .isEqualTo(new RectF(-4.0f, -6.0f, -2.0f, -3.0f));
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testSet() {
 final Matrix matrix1 = new Matrix();
 matrix1.postScale(2.0f, 2.0f);
 matrix1.postTranslate(1.0f, 2.0f);
 matrix1.postRotate(45.0f);
 final Matrix matrix2 = new Matrix();
 matrix2.set(matrix1);
 assertThat(matrix1)
   .isEqualTo(matrix2);
 matrix2.set(null);
 assertThat(matrix2.isIdentity())
   .isTrue();
}

代码示例来源:origin: PhilJay/MPAndroidChart

/**
   * Prepares the matrix that contains all offsets.
   * 
   * @param inverted
   */
  public void prepareMatrixOffset(boolean inverted) {

    mMatrixOffset.reset();

    // offset.postTranslate(mOffsetLeft, getHeight() - mOffsetBottom);

    if (!inverted)
      mMatrixOffset.postTranslate(mViewPortHandler.offsetLeft(),
          mViewPortHandler.getChartHeight() - mViewPortHandler.offsetBottom());
    else {
      mMatrixOffset
          .setTranslate(
              -(mViewPortHandler.getChartWidth() - mViewPortHandler.offsetRight()),
              mViewPortHandler.getChartHeight() - mViewPortHandler.offsetBottom());
      mMatrixOffset.postScale(-1.0f, 1.0f);
    }

    // mMatrixOffset.set(offset);

    // mMatrixOffset.reset();
    //
    // mMatrixOffset.postTranslate(mOffsetLeft, getHeight() -
    // mOffsetBottom);
  }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testPostScale() {
 final Matrix matrix1 = new Matrix();
 matrix1.postScale(2.0f, 2.0f);
 assertPointsEqual(mapPoint(matrix1, 1.0f, 1.0f), new PointF(2.0f, 2.0f));
 matrix1.postScale(2.0f, 2.0f);
 assertPointsEqual(mapPoint(matrix1, 1.0f, 1.0f), new PointF(4.0f, 4.0f));
 final Matrix matrix2 = new Matrix();
 matrix2.postScale(2.0f, 2.0f, 1.0f, 1.0f);
 assertPointsEqual(mapPoint(matrix2, 1.0f, 1.0f), new PointF(1.0f, 1.0f));
 matrix2.setTranslate(1.0f, 2.0f);
 matrix2.postScale(2.0f, 2.0f, 1.0f, 1.0f);
 assertPointsEqual(mapPoint(matrix2, 1.0f, 1.0f), new PointF(3.0f, 5.0f));
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testPostConcat() {
 final Matrix matrix = new Matrix();
 matrix.postScale(2.0f, 3.0f);
 final Matrix translateMatrix = new Matrix();
 translateMatrix.postTranslate(5.0f, 7.0f);
 matrix.postConcat(translateMatrix);
 assertPointsEqual(mapPoint(matrix, 2.0f, 2.0f), new PointF(9.0f, 13.0f));
 final Matrix rotateMatrix = new Matrix();
 rotateMatrix.postRotate(90.0f);
 matrix.postConcat(rotateMatrix);
 assertPointsEqual(mapPoint(matrix, 2.0f, 2.0f), new PointF(-13.0f, 9.0f));
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testIsIdentity() {
 final Matrix matrix = new Matrix();
 assertThat(matrix.isIdentity())
   .isTrue();
 matrix.postScale(2.0f, 2.0f);
 assertThat(matrix.isIdentity())
   .isFalse();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void set_shouldAddOpsToMatrix() {
 final Matrix matrix = new Matrix();
 matrix.setScale(1, 1);
 matrix.preScale(2, 2, 2, 2);
 matrix.postScale(3, 3, 3, 3);
 final ShadowMatrix shadow = shadowOf(matrix);
 assertThat(shadow.getSetOperations().get("scale")).isEqualTo("1.0 1.0");
 assertThat(shadow.getPreOperations().get(0)).isEqualTo("scale 2.0 2.0 2.0 2.0");
 assertThat(shadow.getPostOperations().get(0)).isEqualTo("scale 3.0 3.0 3.0 3.0");
}

相关文章