本文整理了Java中android.graphics.Matrix.mapVectors()
方法的一些代码示例,展示了Matrix.mapVectors()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Matrix.mapVectors()
方法的具体详情如下:
包路径:android.graphics.Matrix
类名称:Matrix
方法名:mapVectors
暂无
代码示例来源:origin: robolectric/robolectric
@Test
public void testMapVectors() {
final Matrix matrix = new Matrix();
matrix.postTranslate(-1.0f, -2.0f);
matrix.postScale(2.0f, 3.0f);
final float[] input = {
0.0f, 0.0f,
1.0f, 2.0f
};
final float[] output = new float[input.length];
matrix.mapVectors(output, input);
assertThat(output)
.usingExactEquality()
.containsExactly(0.0f, 0.0f, 2.0f, 6.0f);
}
代码示例来源:origin: burhanrashid52/PhotoEditor
private static void adjustTranslation(View view, float deltaX, float deltaY) {
float[] deltaVector = {deltaX, deltaY};
view.getMatrix().mapVectors(deltaVector);
view.setTranslationX(view.getTranslationX() + deltaVector[0]);
view.setTranslationY(view.getTranslationY() + deltaVector[1]);
}
代码示例来源:origin: GcsSloop/ViewSupport
private static float transformAngle(Matrix m, float angleRadians) {
// Construct and transform a vector oriented at the specified clockwise
// angle from vertical. Coordinate system: down is increasing Y, right is
// increasing X.
float[] v = new float[2];
v[0] = (float) Math.sin(angleRadians);
v[1] = (float) Math.cos(angleRadians);
m.mapVectors(v);
// Derive the transformed vector's clockwise angle from vertical.
float result = (float) Math.atan2(v[0], -v[1]);
if (result < -Math.PI / 2) {
result += Math.PI;
} else if (result > Math.PI / 2) {
result -= Math.PI;
}
return result;
}
}
代码示例来源:origin: alexjlockwood/kyrie
final float getMatrixScale(Matrix matrix) {
// Given unit vectors A = (0, 1) and B = (1, 0).
// After matrix mapping, we got A' and B'. Let theta = the angle b/t A' and B'.
// Therefore, the final scale we want is min(|A'| * sin(theta), |B'| * sin(theta)),
// which is (|A'| * |B'| * sin(theta)) / max (|A'|, |B'|);
// If max (|A'|, |B'|) = 0, that means either x or y has a scale of 0.
// For non-skew case, which is most of the cases, matrix scale is computing exactly the
// scale on x and y axis, and take the minimal of these two.
// For skew case, an unit square will mapped to a parallelogram. And this function will
// return the minimal height of the 2 bases.
final float[] unitVectors = tempUnitVectors;
unitVectors[0] = 0;
unitVectors[1] = 1;
unitVectors[2] = 1;
unitVectors[3] = 0;
matrix.mapVectors(unitVectors);
final float scaleX = (float) Math.hypot(unitVectors[0], unitVectors[1]);
final float scaleY = (float) Math.hypot(unitVectors[2], unitVectors[3]);
final float crossProduct =
cross(unitVectors[0], unitVectors[1], unitVectors[2], unitVectors[3]);
final float maxScale = Math.max(scaleX, scaleY);
return maxScale > 0 ? Math.abs(crossProduct) / maxScale : 0;
}
代码示例来源:origin: eventtus/photo-editor-android
private static void adjustTranslation(View view, float deltaX, float deltaY) {
float[] deltaVector = {deltaX, deltaY};
view.getMatrix().mapVectors(deltaVector);
view.setTranslationX(view.getTranslationX() + deltaVector[0]);
view.setTranslationY(view.getTranslationY() + deltaVector[1]);
}
代码示例来源:origin: PeterStaev/nativescript-photo-editor
private static void adjustTranslation(View view, float deltaX, float deltaY) {
float[] deltaVector = {deltaX, deltaY};
view.getMatrix().mapVectors(deltaVector);
view.setTranslationX(view.getTranslationX() + deltaVector[0]);
view.setTranslationY(view.getTranslationY() + deltaVector[1]);
}
内容来源于网络,如有侵权,请联系作者删除!