Search in sources :

Example 1 with Point

use of android.filterfw.geometry.Point in project android_frameworks_base by ParanoidAndroid.

the class Rectangle method fromCenterVerticalAxis.

public static Rectangle fromCenterVerticalAxis(Point center, Point vAxis, Point size) {
    Point dy = vAxis.scaledTo(size.y / 2.0f);
    Point dx = vAxis.rotated90(1).scaledTo(size.x / 2.0f);
    return new Rectangle(center.minus(dx).minus(dy), center.plus(dx).minus(dy), center.minus(dx).plus(dy), center.plus(dx).plus(dy));
}
Also used : Point(android.filterfw.geometry.Point)

Example 2 with Point

use of android.filterfw.geometry.Point in project android_frameworks_base by ParanoidAndroid.

the class Rectangle method fromRotatedRect.

public static Rectangle fromRotatedRect(Point center, Point size, float rotation) {
    Point p0 = new Point(center.x - size.x / 2f, center.y - size.y / 2f);
    Point p1 = new Point(center.x + size.x / 2f, center.y - size.y / 2f);
    Point p2 = new Point(center.x - size.x / 2f, center.y + size.y / 2f);
    Point p3 = new Point(center.x + size.x / 2f, center.y + size.y / 2f);
    return new Rectangle(p0.rotatedAround(center, rotation), p1.rotatedAround(center, rotation), p2.rotatedAround(center, rotation), p3.rotatedAround(center, rotation));
}
Also used : Point(android.filterfw.geometry.Point)

Example 3 with Point

use of android.filterfw.geometry.Point in project platform_frameworks_base by android.

the class Rectangle method fromCenterVerticalAxis.

public static Rectangle fromCenterVerticalAxis(Point center, Point vAxis, Point size) {
    Point dy = vAxis.scaledTo(size.y / 2.0f);
    Point dx = vAxis.rotated90(1).scaledTo(size.x / 2.0f);
    return new Rectangle(center.minus(dx).minus(dy), center.plus(dx).minus(dy), center.minus(dx).plus(dy), center.plus(dx).plus(dy));
}
Also used : Point(android.filterfw.geometry.Point)

Example 4 with Point

use of android.filterfw.geometry.Point in project platform_frameworks_base by android.

the class Rectangle method fromRotatedRect.

public static Rectangle fromRotatedRect(Point center, Point size, float rotation) {
    Point p0 = new Point(center.x - size.x / 2f, center.y - size.y / 2f);
    Point p1 = new Point(center.x + size.x / 2f, center.y - size.y / 2f);
    Point p2 = new Point(center.x - size.x / 2f, center.y + size.y / 2f);
    Point p3 = new Point(center.x + size.x / 2f, center.y + size.y / 2f);
    return new Rectangle(p0.rotatedAround(center, rotation), p1.rotatedAround(center, rotation), p2.rotatedAround(center, rotation), p3.rotatedAround(center, rotation));
}
Also used : Point(android.filterfw.geometry.Point)

Example 5 with Point

use of android.filterfw.geometry.Point in project platform_frameworks_base by android.

the class StraightenFilter method updateParameters.

private void updateParameters() {
    float cosTheta = (float) Math.cos(mAngle * DEGREE_TO_RADIAN);
    float sinTheta = (float) Math.sin(mAngle * DEGREE_TO_RADIAN);
    if (mMaxAngle <= 0)
        throw new RuntimeException("Max angle is out of range (0-180).");
    mMaxAngle = (mMaxAngle > 90) ? 90 : mMaxAngle;
    Point p0 = new Point(-cosTheta * mWidth + sinTheta * mHeight, -sinTheta * mWidth - cosTheta * mHeight);
    Point p1 = new Point(cosTheta * mWidth + sinTheta * mHeight, sinTheta * mWidth - cosTheta * mHeight);
    Point p2 = new Point(-cosTheta * mWidth - sinTheta * mHeight, -sinTheta * mWidth + cosTheta * mHeight);
    Point p3 = new Point(cosTheta * mWidth - sinTheta * mHeight, sinTheta * mWidth + cosTheta * mHeight);
    float maxWidth = (float) Math.max(Math.abs(p0.x), Math.abs(p1.x));
    float maxHeight = (float) Math.max(Math.abs(p0.y), Math.abs(p1.y));
    float scale = 0.5f * Math.min(mWidth / maxWidth, mHeight / maxHeight);
    p0.set(scale * p0.x / mWidth + 0.5f, scale * p0.y / mHeight + 0.5f);
    p1.set(scale * p1.x / mWidth + 0.5f, scale * p1.y / mHeight + 0.5f);
    p2.set(scale * p2.x / mWidth + 0.5f, scale * p2.y / mHeight + 0.5f);
    p3.set(scale * p3.x / mWidth + 0.5f, scale * p3.y / mHeight + 0.5f);
    Quad quad = new Quad(p0, p1, p2, p3);
    ((ShaderProgram) mProgram).setSourceRegion(quad);
}
Also used : Quad(android.filterfw.geometry.Quad) ShaderProgram(android.filterfw.core.ShaderProgram) Point(android.filterfw.geometry.Point)

Aggregations

Point (android.filterfw.geometry.Point)30 Quad (android.filterfw.geometry.Quad)18 ShaderProgram (android.filterfw.core.ShaderProgram)12 Frame (android.filterfw.core.Frame)6 FrameFormat (android.filterfw.core.FrameFormat)6 MutableFrameFormat (android.filterfw.core.MutableFrameFormat)6