diff options
Diffstat (limited to 'graphics/java/android')
| -rw-r--r-- | graphics/java/android/graphics/ColorMatrix.java | 15 | ||||
| -rw-r--r-- | graphics/java/android/graphics/drawable/RotateDrawable.java | 24 |
2 files changed, 31 insertions, 8 deletions
diff --git a/graphics/java/android/graphics/ColorMatrix.java b/graphics/java/android/graphics/ColorMatrix.java index 2478712..c22cda1 100644 --- a/graphics/java/android/graphics/ColorMatrix.java +++ b/graphics/java/android/graphics/ColorMatrix.java @@ -110,22 +110,31 @@ public class ColorMatrix { a[18] = aScale; } + /** + * Set the rotation on a color axis by the specified values. + * axis=0 correspond to a rotation around the RED color + * axis=1 correspond to a rotation around the GREEN color + * axis=2 correspond to a rotation around the BLUE color + */ public void setRotate(int axis, float degrees) { reset(); float radians = degrees * (float)Math.PI / 180; float cosine = FloatMath.cos(radians); float sine = FloatMath.sin(radians); switch (axis) { + // Rotation around the red color case 0: mArray[6] = mArray[12] = cosine; mArray[7] = sine; mArray[11] = -sine; break; + // Rotation around the green color case 1: - mArray[0] = mArray[17] = cosine; - mArray[2] = sine; - mArray[15] = -sine; + mArray[0] = mArray[12] = cosine; + mArray[2] = -sine; + mArray[10] = sine; break; + // Rotation around the blue color case 2: mArray[0] = mArray[6] = cosine; mArray[1] = sine; diff --git a/graphics/java/android/graphics/drawable/RotateDrawable.java b/graphics/java/android/graphics/drawable/RotateDrawable.java index c4a7822..2083e05 100644 --- a/graphics/java/android/graphics/drawable/RotateDrawable.java +++ b/graphics/java/android/graphics/drawable/RotateDrawable.java @@ -204,13 +204,27 @@ public class RotateDrawable extends Drawable implements Drawable.Callback { com.android.internal.R.styleable.RotateDrawable_visible); TypedValue tv = a.peekValue(com.android.internal.R.styleable.RotateDrawable_pivotX); - boolean pivotXRel = tv.type == TypedValue.TYPE_FRACTION; - float pivotX = pivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); + boolean pivotXRel; + float pivotX; + if (tv == null) { + pivotXRel = true; + pivotX = 0.5f; + } else { + pivotXRel = tv.type == TypedValue.TYPE_FRACTION; + pivotX = pivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); + } tv = a.peekValue(com.android.internal.R.styleable.RotateDrawable_pivotY); - boolean pivotYRel = tv.type == TypedValue.TYPE_FRACTION; - float pivotY = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); - + boolean pivotYRel; + float pivotY; + if (tv == null) { + pivotYRel = true; + pivotY = 0.5f; + } else { + pivotYRel = tv.type == TypedValue.TYPE_FRACTION; + pivotY = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); + } + float fromDegrees = a.getFloat( com.android.internal.R.styleable.RotateDrawable_fromDegrees, 0.0f); float toDegrees = a.getFloat( |
