本文整理了Java中android.graphics.Matrix.<init>()
方法的一些代码示例,展示了Matrix.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.<init>()
方法的具体详情如下:
包路径:android.graphics.Matrix
类名称:Matrix
方法名:<init>
暂无
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Sets the scale factor to the specified values. x and y is pivot.
*
* @param scaleX
* @param scaleY
* @param x
* @param y
* @return
*/
public Matrix setZoom(float scaleX, float scaleY, float x, float y) {
Matrix save = new Matrix();
save.set(mMatrixTouch);
save.setScale(scaleX, scaleY, x, y);
return save;
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Post-scales by the specified scale factors.
*
* @param scaleX
* @param scaleY
* @return
*/
public Matrix zoom(float scaleX, float scaleY) {
Matrix save = new Matrix();
zoom(scaleX, scaleY, save);
return save;
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Zooms out by 0.7f, x and y are the coordinates (in pixels) of the zoom
* center.
*/
public Matrix zoomOut(float x, float y) {
Matrix save = new Matrix();
zoomOut(x, y, save);
return save;
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Sets the scale factor to the specified values.
*
* @param scaleX
* @param scaleY
* @return
*/
public Matrix setZoom(float scaleX, float scaleY) {
Matrix save = new Matrix();
setZoom(scaleX, scaleY, save);
return save;
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Resets all zooming and dragging and makes the chart fit exactly it's
* bounds.
*/
public Matrix fitScreen() {
Matrix save = new Matrix();
fitScreen(save);
return save;
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Post-translates to the specified points. Less Performant.
*
* @param transformedPts
* @return
*/
public Matrix translate(final float[] transformedPts) {
Matrix save = new Matrix();
translate(transformedPts, save);
return save;
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Zooms in by 1.4f, x and y are the coordinates (in pixels) of the zoom
* center.
*
* @param x
* @param y
*/
public Matrix zoomIn(float x, float y) {
Matrix save = new Matrix();
zoomIn(x, y, save);
return save;
}
代码示例来源:origin: Curzibn/Luban
private Bitmap rotatingImage(Bitmap bitmap, int angle) {
Matrix matrix = new Matrix();
matrix.postRotate(angle);
return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}
代码示例来源:origin: PhilJay/MPAndroidChart
/**
* Post-scales by the specified scale factors. x and y is pivot.
*
* @param scaleX
* @param scaleY
* @param x
* @param y
* @return
*/
public Matrix zoom(float scaleX, float scaleY, float x, float y) {
Matrix save = new Matrix();
zoom(scaleX, scaleY, x, y, save);
return save;
}
代码示例来源:origin: bumptech/glide
FixedSizeDrawable(State state, Drawable wrapped) {
this.state = Preconditions.checkNotNull(state);
this.wrapped = Preconditions.checkNotNull(wrapped);
// We will do our own scaling.
wrapped.setBounds(0, 0, wrapped.getIntrinsicWidth(), wrapped.getIntrinsicHeight());
matrix = new Matrix();
wrappedRect = new RectF(0, 0, wrapped.getIntrinsicWidth(), wrapped.getIntrinsicHeight());
bounds = new RectF();
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
mRect.set(0, 0, bounds.width(), bounds.height());
radius = Math.min(bounds.width(), bounds.height()) / 2;
strokeRadius = radius - strokeWidth / 2;
// Resize the original bitmap to fit the new bound
Matrix shaderMatrix = new Matrix();
shaderMatrix.setRectToRect(mBitmapRect, mRect, Matrix.ScaleToFit.FILL);
bitmapShader.setLocalMatrix(shaderMatrix);
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
mRect.set(margin, margin, bounds.width() - margin, bounds.height() - margin);
// Resize the original bitmap to fit the new bound
Matrix shaderMatrix = new Matrix();
shaderMatrix.setRectToRect(mBitmapRect, mRect, Matrix.ScaleToFit.FILL);
bitmapShader.setLocalMatrix(shaderMatrix);
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
protected void onBoundsChange(Rect bounds) {
super.onBoundsChange(bounds);
RadialGradient vignette = new RadialGradient(
mRect.centerX(), mRect.centerY() * 1.0f / 0.7f, mRect.centerX() * 1.3f,
new int[]{0, 0, 0x7f000000}, new float[]{0.0f, 0.7f, 1.0f},
Shader.TileMode.CLAMP);
Matrix oval = new Matrix();
oval.setScale(1.0f, 0.7f);
vignette.setLocalMatrix(oval);
paint.setShader(new ComposeShader(bitmapShader, vignette, PorterDuff.Mode.SRC_OVER));
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void visualize_shouldReturnDescription() throws Exception {
Canvas canvas = new Canvas(targetBitmap);
canvas.drawBitmap(imageBitmap, new Matrix(), new Paint());
canvas.drawBitmap(imageBitmap, new Matrix(), new Paint());
assertEquals("Bitmap for file:/an/image.jpg transformed by Matrix[pre=[], set={}, post=[]]\n" +
"Bitmap for file:/an/image.jpg transformed by Matrix[pre=[], set={}, post=[]]", ShadowCanvas.visualize(canvas));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testPostTranslate() {
final Matrix matrix1 = new Matrix();
matrix1.postTranslate(1.0f, 1.0f);
assertPointsEqual(mapPoint(matrix1, 1.0f, 1.0f), new PointF(2.0f, 2.0f));
matrix1.postTranslate(2.0f, 2.0f);
assertPointsEqual(mapPoint(matrix1, 1.0f, 1.0f), new PointF(4.0f, 4.0f));
final Matrix matrix2 = new Matrix();
matrix2.setScale(2.0f, 2.0f);
matrix2.postTranslate(-5.0f, 10.0f);
assertPointsEqual(mapPoint(matrix2, 1.0f, 1.0f), new PointF(-3.0f, 12.0f));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldDescribeBitmapDrawing_WithMatrix() throws Exception {
Canvas canvas = new Canvas(targetBitmap);
canvas.drawBitmap(imageBitmap, new Matrix(), new Paint());
canvas.drawBitmap(imageBitmap, new Matrix(), new Paint());
assertEquals("Bitmap for file:/an/image.jpg transformed by Matrix[pre=[], set={}, post=[]]\n" +
"Bitmap for file:/an/image.jpg transformed by Matrix[pre=[], set={}, post=[]]", shadowOf(canvas).getDescription());
assertEquals("Bitmap for file:/an/image.jpg transformed by Matrix[pre=[], set={}, post=[]]\n" +
"Bitmap for file:/an/image.jpg transformed by Matrix[pre=[], set={}, post=[]]", shadowOf(targetBitmap).getDescription());
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testSetScale() {
final Matrix matrix = new Matrix();
matrix.setScale(2.0f, 2.0f);
assertPointsEqual(mapPoint(matrix, 1.0f, 1.0f), new PointF(2.0f, 2.0f));
matrix.setScale(-2.0f, -3.0f);
assertPointsEqual(mapPoint(matrix, 2.0f, 3.0f), new PointF(-4.0f, -9.0f));
matrix.setScale(-2.0f, -3.0f, 1.0f, 1.0f);
assertPointsEqual(mapPoint(matrix, 2.0f, 3.0f), new PointF(-1.0f, -5.0f));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testSetTranslate() {
final Matrix matrix = new Matrix();
matrix.setTranslate(2.0f, 2.0f);
assertPointsEqual(mapPoint(matrix, 1.0f, 1.0f), new PointF(3.0f, 3.0f));
matrix.setTranslate(-2.0f, -2.0f);
assertPointsEqual(mapPoint(matrix, 1.0f, 1.0f), new PointF(-1.0f, -1.0f));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void preOperationsAreStacked() {
Matrix m = new Matrix();
m.preRotate(4, 8, 15);
m.preTranslate(16, 23);
m.preSkew(42, 108);
assertThat(shadowOf(m).getPreOperations()).containsExactly(
"skew 42.0 108.0",
"translate 16.0 23.0",
"rotate 4.0 8.0 15.0"
);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void setOperationsOverride() {
Matrix m = new Matrix();
m.setRotate(4);
m.setRotate(8);
m.setRotate(15);
m.setRotate(16);
m.setRotate(23);
m.setRotate(42);
m.setRotate(108);
assertThat(shadowOf(m).getSetOperations()).containsEntry("rotate", "108.0");
}
内容来源于网络,如有侵权,请联系作者删除!