use of android.graphics.ColorMatrix in project Launcher3 by chislon.
the class Utilities method initStatics.
private static void initStatics(Context context) {
final Resources resources = context.getResources();
final DisplayMetrics metrics = resources.getDisplayMetrics();
final float density = metrics.density;
sIconWidth = sIconHeight = (int) resources.getDimension(R.dimen.app_icon_size);
sIconTextureWidth = sIconTextureHeight = sIconWidth;
sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL));
sGlowColorPressedPaint.setColor(0xffffc300);
sGlowColorFocusedPaint.setColor(0xffff8e00);
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0.2f);
sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm));
sDisabledPaint.setAlpha(0x88);
}
use of android.graphics.ColorMatrix in project Fairphone by Kwamecorp.
the class Utilities method initStatics.
private static void initStatics(Context context) {
final Resources resources = context.getResources();
final DisplayMetrics metrics = resources.getDisplayMetrics();
final float density = metrics.density;
sIconWidth = sIconHeight = (int) resources.getDimension(R.dimen.app_icon_size);
sIconTextureWidth = sIconTextureHeight = sIconWidth;
sBlurPaint.setMaskFilter(new BlurMaskFilter(5 * density, BlurMaskFilter.Blur.NORMAL));
sGlowColorPressedPaint.setColor(0xffffc300);
sGlowColorFocusedPaint.setColor(0xffff8e00);
ColorMatrix cm = new ColorMatrix();
cm.setSaturation(0.2f);
sDisabledPaint.setColorFilter(new ColorMatrixColorFilter(cm));
sDisabledPaint.setAlpha(0x88);
}
use of android.graphics.ColorMatrix in project 9GAG by Mixiaoxiao.
the class SquareProgressBar method setImageGrayscale.
/**
* You can set the image to b/w with this method. Works fine with the
* opacity.
*
* @param greyscale
* true if the grayscale should be activated.
* @since 1.2.0 / but never used in the example application
*/
public void setImageGrayscale(boolean greyscale) {
this.greyscale = greyscale;
if (greyscale) {
ColorMatrix matrix = new ColorMatrix();
matrix.setSaturation(0);
imageView.setColorFilter(new ColorMatrixColorFilter(matrix));
} else {
imageView.setColorFilter(null);
}
}
use of android.graphics.ColorMatrix in project Carbon by ZieIony.
the class AnimUtils method brightnessSaturationFadeIn.
public static ValueAnimator brightnessSaturationFadeIn(final ImageView imageView, Animator.AnimatorListener listener) {
final ValueAnimator animator = ValueAnimator.ofFloat(0, 1);
final AccelerateDecelerateInterpolator interpolator = new AccelerateDecelerateInterpolator();
animator.setInterpolator(interpolator);
animator.setDuration(800);
if (listener != null)
animator.addListener(listener);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
ColorMatrix saturationMatrix = new ColorMatrix();
ColorMatrix brightnessMatrix = new ColorMatrix();
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float fraction = animator.getAnimatedFraction();
saturationMatrix.setSaturation((Float) animator.getAnimatedValue());
float scale = 2 - interpolator.getInterpolation(Math.min(fraction * 4 / 3, 1));
brightnessMatrix.setScale(scale, scale, scale, interpolator.getInterpolation(Math.min(fraction * 2, 1)));
saturationMatrix.preConcat(brightnessMatrix);
imageView.setColorFilter(new ColorMatrixColorFilter(saturationMatrix));
if (imageView.getParent() != null)
((View) imageView.getParent()).postInvalidate();
}
});
animator.start();
return animator;
}
use of android.graphics.ColorMatrix in project robolectric by robolectric.
the class ShadowBitmapDrawableTest method withColorFilterSet_draw_shouldCopyDescriptionToCanvas.
@Test
public void withColorFilterSet_draw_shouldCopyDescriptionToCanvas() throws Exception {
BitmapDrawable drawable = (BitmapDrawable) resources.getDrawable(R.drawable.an_image);
drawable.setColorFilter(new ColorMatrixColorFilter(new ColorMatrix()));
Canvas canvas = new Canvas();
drawable.draw(canvas);
assertThat(shadowOf(canvas).getDescription()).isEqualTo("Bitmap for resource:org.robolectric:drawable/an_image with ColorMatrixColorFilter<1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0>");
}
Aggregations