List of usage examples for android.support.v4.graphics ColorUtils compositeColors
public static int compositeColors(@ColorInt int foreground, @ColorInt int background)
From source file:ooo.oxo.moments.util.ColorMixer.java
public static int mix(@ColorInt int background, @ColorInt int foreground, float ratio) { int alpha = Color.alpha(foreground); alpha = (int) Math.floor((float) alpha * Math.max(0f, Math.min(1f, ratio))); foreground = ColorUtils.setAlphaComponent(foreground, alpha); return ColorUtils.compositeColors(foreground, background); }
From source file:me.xingrz.gankmeizhi.util.ColorMixer.java
/** * ??/*w w w .jav a 2 s. c o m*/ * * @param background * @param foreground ? * @param ratio ?? * @return ?? */ public static int mix(@ColorInt int background, @ColorInt int foreground, float ratio) { int alpha = Color.alpha(foreground); alpha = (int) Math.floor((float) alpha * ratio); foreground = ColorUtils.setAlphaComponent(foreground, alpha); return ColorUtils.compositeColors(foreground, background); }
From source file:net.xpece.android.colorpicker.ColorStateDrawable.java
private int getPressedColor() { return ColorUtils.compositeColors(mPressed, mColor); }
From source file:com.fastbootmobile.encore.app.tv.CardPresenter.java
private static void updateCardBackgroundColor(ImageCardView view, boolean selected) { int color = selected ? sSelectedBackgroundColor : sDefaultBackgroundColor; if (view.getTag() != null && view.getTag() instanceof Palette) { Palette palette = (Palette) view.getTag(); final int darkVibColor = palette.getDarkVibrantColor(sSelectedBackgroundColor); final int darkVibColorDim = ColorUtils.compositeColors(0xA0FFFFFF & darkVibColor, 0xFF000000); color = selected ? darkVibColor : darkVibColorDim; }//from w ww .j av a 2 s . c om // Both background colors should be set because the view's background is temporarily visible // during animations. view.setBackgroundColor(color); view.findViewById(R.id.info_field).setBackgroundColor(color); }
From source file:org.mariotaku.twidere.text.OriginalStatusSpan.java
@Override public void draw(final Canvas canvas, final CharSequence text, final int start, final int end, final float x, final int top, final int y, final int bottom, final Paint paint) { if (!(paint instanceof TextPaint)) return;//from w ww . j a v a 2s . c om final TextPaint tp = (TextPaint) paint; mBounds.left = x; mBounds.right = x + paint.measureText(text, start, end) + mPadding * 2; mBounds.top = top; mBounds.bottom = bottom; final int innerTextColor = TwidereColorUtils.getContrastYIQ(tp.linkColor, ThemeUtils.ACCENT_COLOR_THRESHOLD, mDarkLightColors[0], mDarkLightColors[1]); mPaint.setStyle(Paint.Style.FILL); mPaint.setColor(tp.linkColor); mBounds.inset(mPaint.getStrokeWidth() / 2, mPaint.getStrokeWidth() / 2); canvas.drawRoundRect(mBounds, mCornerRadius, mCornerRadius, mPaint); mBounds.inset(-mPaint.getStrokeWidth() / 2, -mPaint.getStrokeWidth() / 2); mPaint.setStyle(Paint.Style.STROKE); mPaint.setColor( ColorUtils.compositeColors(ColorUtils.setAlphaComponent(innerTextColor, 0x80), tp.linkColor)); mBounds.inset(mPaint.getStrokeWidth() / 2, mPaint.getStrokeWidth() / 2); canvas.drawRoundRect(mBounds, mCornerRadius, mCornerRadius, mPaint); paint.setColor(innerTextColor); canvas.drawText(text, start, end, x + mPadding, top + (bottom - top) / 2 - (paint.descent() + paint.ascent()) / 2, paint); }
From source file:jp.tkgktyk.xposed.forcetouchdetector.app.util.fab.CircularBorderDrawable.java
/** * Creates a vertical {@link LinearGradient} * @return//w w w . j av a2 s . co m */ private Shader createGradientShader() { final Rect rect = mRect; copyBounds(rect); final float borderRatio = mBorderWidth / rect.height(); final int[] colors = new int[6]; colors[0] = ColorUtils.compositeColors(mTopOuterStrokeColor, mTintColor); colors[1] = ColorUtils.compositeColors(mTopInnerStrokeColor, mTintColor); colors[2] = ColorUtils.compositeColors(ColorUtils.setAlphaComponent(mTopInnerStrokeColor, 0), mTintColor); colors[3] = ColorUtils.compositeColors(ColorUtils.setAlphaComponent(mBottomInnerStrokeColor, 0), mTintColor); colors[4] = ColorUtils.compositeColors(mBottomInnerStrokeColor, mTintColor); colors[5] = ColorUtils.compositeColors(mBottomOuterStrokeColor, mTintColor); final float[] positions = new float[6]; positions[0] = 0f; positions[1] = borderRatio; positions[2] = 0.5f; positions[3] = 0.5f; positions[4] = 1f - borderRatio; positions[5] = 1f; return new LinearGradient(0, rect.top, 0, rect.bottom, colors, positions, Shader.TileMode.CLAMP); }
From source file:android.support.v7.app.MediaRouterThemeHelper.java
public static void setVolumeSliderColor(Context context, MediaRouteVolumeSlider volumeSlider, View backgroundView) {//from w w w.jav a 2 s.c om int controllerColor = getControllerColor(context, 0); if (Color.alpha(controllerColor) != 0xFF) { // Composite with the background in order not to show the underlying progress bar // through the thumb. int backgroundColor = (int) backgroundView.getTag(); controllerColor = ColorUtils.compositeColors(controllerColor, backgroundColor); } volumeSlider.setColor(controllerColor); }
From source file:android.support.design.widget.CircularBorderDrawable.java
/** * Creates a vertical {@link LinearGradient} * @return// www .ja v a2s . c o m */ private Shader createGradientShader() { final Rect rect = mRect; copyBounds(rect); final float borderRatio = mBorderWidth / rect.height(); final int[] colors = new int[6]; colors[0] = ColorUtils.compositeColors(mTopOuterStrokeColor, mCurrentBorderTintColor); colors[1] = ColorUtils.compositeColors(mTopInnerStrokeColor, mCurrentBorderTintColor); colors[2] = ColorUtils.compositeColors(ColorUtils.setAlphaComponent(mTopInnerStrokeColor, 0), mCurrentBorderTintColor); colors[3] = ColorUtils.compositeColors(ColorUtils.setAlphaComponent(mBottomInnerStrokeColor, 0), mCurrentBorderTintColor); colors[4] = ColorUtils.compositeColors(mBottomInnerStrokeColor, mCurrentBorderTintColor); colors[5] = ColorUtils.compositeColors(mBottomOuterStrokeColor, mCurrentBorderTintColor); final float[] positions = new float[6]; positions[0] = 0f; positions[1] = borderRatio; positions[2] = 0.5f; positions[3] = 0.5f; positions[4] = 1f - borderRatio; positions[5] = 1f; return new LinearGradient(0, rect.top, 0, rect.bottom, colors, positions, Shader.TileMode.CLAMP); }
From source file:com.tr4android.support.extension.widget.LabelView.java
private static ColorStateList createColorStateList(int rippleColor, int backgroundColor) { final int compositeColor = ColorUtils.compositeColors(rippleColor, backgroundColor); return new ColorStateList(new int[][] { // states new int[] { android.R.attr.state_focused }, new int[] { android.R.attr.state_pressed }, new int[] {} // state_default }, new int[] { // colors compositeColor, compositeColor, backgroundColor }); }
From source file:com.max.library.view.v7.AppCompatDrawableManager.java
private ColorStateList createButtonColorStateList(Context context, int baseColorAttr) { final int[][] states = new int[4][]; final int[] colors = new int[4]; int i = 0;/*from ww w . j a v a 2 s . c om*/ final int baseColor = getThemeAttrColor(context, baseColorAttr); final int colorControlHighlight = getThemeAttrColor(context, R.attr.colorControlHighlight); // Disabled state states[i] = ThemeUtils.DISABLED_STATE_SET; colors[i] = getDisabledThemeAttrColor(context, R.attr.colorButtonNormal); i++; states[i] = ThemeUtils.PRESSED_STATE_SET; colors[i] = ColorUtils.compositeColors(colorControlHighlight, baseColor); i++; states[i] = ThemeUtils.FOCUSED_STATE_SET; colors[i] = ColorUtils.compositeColors(colorControlHighlight, baseColor); i++; // Default enabled state states[i] = ThemeUtils.EMPTY_STATE_SET; colors[i] = baseColor; i++; return new ColorStateList(states, colors); }