use of android.graphics.Matrix in project fresco by facebook.
the class ScaleTypeDrawableTest method testConfigureBounds_FOCUS_CROP_VC.
/**
* Underlying drawable's aspect ratio is smaller than view's, so it has to be slided vertically
* after scaling. Focus point is at 40% and it can be completely centered.
*/
@Test
public void testConfigureBounds_FOCUS_CROP_VC() {
Rect bounds = new Rect(10, 10, 410, 310);
int width = 200;
int height = 300;
PointF focusPoint = new PointF(0.5f, 0.4f);
Matrix expectedMatrix = new Matrix();
expectedMatrix.setScale(2.0f, 2.0f);
expectedMatrix.postTranslate(10, -79);
testConfigureBounds(bounds, width, height, ScaleType.FOCUS_CROP, focusPoint, expectedMatrix);
// expected bounds of the actual image after the scaling has been performed (without cropping)
testActualImageBounds(new RectF(10f, -79f, 410f, 521f));
}
use of android.graphics.Matrix in project fresco by facebook.
the class OrientedDrawableTest method testCreation_hundredAndEightyDegrees.
@Test
public void testCreation_hundredAndEightyDegrees() {
OrientedDrawable drawable = new OrientedDrawable(mDrawable, 180);
drawable.setBounds(mBounds);
drawable.draw(mCanvas);
Matrix expectedMatrix = new Matrix();
expectedMatrix.setRotate(180, drawable.getBounds().centerX(), drawable.getBounds().centerY());
assertFalse(drawable.mRotationMatrix.isIdentity());
AndroidGraphicsTestUtils.assertEquals(expectedMatrix, drawable.mRotationMatrix);
verifySetBounds(expectedMatrix);
}
use of android.graphics.Matrix in project fresco by facebook.
the class ScaleTypeDrawableTest method testConfigureBounds_FOCUS_CROP_HC.
/**
* Underlying drawable's aspect ratio is bigger than view's, so it has to be slided horizontally
* after scaling. Focus point is at 40% and it can be completely centered.
*/
@Test
public void testConfigureBounds_FOCUS_CROP_HC() {
Rect bounds = new Rect(10, 10, 410, 310);
int width = 400;
int height = 200;
PointF focusPoint = new PointF(0.40f, 0.5f);
Matrix expectedMatrix = new Matrix();
expectedMatrix.setScale(1.5f, 1.5f);
expectedMatrix.postTranslate(-29, 10);
testConfigureBounds(bounds, width, height, ScaleType.FOCUS_CROP, focusPoint, expectedMatrix);
}
use of android.graphics.Matrix in project fresco by facebook.
the class ScaleTypeDrawableTest method testConfigureBounds_FOCUS_CROP_VB.
/**
* Underlying drawable's aspect ratio is smaller than view's, so it has to be slided vertically
* after scaling. Focus point is too much bottom, so it cannot be completely centered. Bottom-most
* part of the image is displayed.
*/
@Test
public void testConfigureBounds_FOCUS_CROP_VB() {
Rect bounds = new Rect(10, 10, 410, 310);
int width = 200;
int height = 300;
PointF focusPoint = new PointF(0.5f, 0.9f);
Matrix expectedMatrix = new Matrix();
expectedMatrix.setScale(2.0f, 2.0f);
expectedMatrix.postTranslate(10, -289);
testConfigureBounds(bounds, width, height, ScaleType.FOCUS_CROP, focusPoint, expectedMatrix);
}
use of android.graphics.Matrix in project Keyframes by facebookincubator.
the class KFPathTest method testSimpleCommands.
@Test
public void testSimpleCommands() {
KFPathTestObject kfPathWrapper = new KFPathTestObject();
InOrder orderedMock = Mockito.inOrder(kfPathWrapper.mockPath);
kfPathWrapper.kfPath.isEmpty();
orderedMock.verify(kfPathWrapper.mockPath).isEmpty();
Matrix matrix = new Matrix();
kfPathWrapper.kfPath.transform(matrix);
orderedMock.verify(kfPathWrapper.mockPath).transform(matrix);
}
Aggregations