List of usage examples for android.support.v4.graphics ColorUtils HSLToColor
@ColorInt public static int HSLToColor(@NonNull float[] hsl)
From source file:com.owncloud.android.utils.ThemeUtils.java
public static int adjustLightness(float lightnessDelta, int color) { float[] hsl = colorToHSL(color); hsl[2] += lightnessDelta;/*from w w w . jav a 2 s . co m*/ return ColorUtils.HSLToColor(hsl); }
From source file:com.pixby.texo.EditTools.ColorTool.java
private @ColorInt int createTintOrShade(@ColorInt int color, float factor) { float[] hsl = new float[3]; ColorUtils.colorToHSL(color, hsl);//from w w w. j a v a 2 s .com hsl[2] *= factor; return ColorUtils.HSLToColor(hsl); }
From source file:com.tafayor.selfcamerashot.camera.CameraMenu.java
private Action buildAdsAction(int id, int resId) { int tintColor; Random r = new Random(); float h = r.nextFloat() * 365; float s = 0.9f; float l = 0.8f; tintColor = ColorUtils.HSLToColor(new float[] { h, s, l }); final int glowColor = mContext.getResources().getColor(R.color.camera_btn_glowColor); Bitmap bmp;//from w ww. j a v a 2 s . c o m Drawable icon; bmp = BitmapFactory.decodeResource(mContext.getResources(), resId); Drawable drawable = new BitmapDrawable(mContext.getResources(), bmp); icon = Util.tint(drawable, tintColor); bmp = GraphicsHelper.drawableToBitmap(icon); bmp = GraphicsHelper.addGlow(bmp, glowColor); icon = new BitmapDrawable(mContext.getResources(), bmp); return new Action(id, icon); }
From source file:com.google.samples.apps.iosched.util.UIUtils.java
/** * Calculate a darker variant of the given color to make it suitable for setting as the status * bar background./*from w w w . j a v a 2s .co m*/ * * @param color the color to adjust. * @return the adjusted color. */ public static @ColorInt int adjustColorForStatusBar(@ColorInt int color) { float[] hsl = new float[3]; ColorUtils.colorToHSL(color, hsl); // darken the color by 7.5% float lightness = hsl[2] * 0.925f; // constrain lightness to be within [01] lightness = Math.max(0f, Math.min(1f, lightness)); hsl[2] = lightness; return ColorUtils.HSLToColor(hsl); }
From source file:com.github.chenxiaolong.dualbootpatcher.switcher.RomDetailActivity.java
private void onCachedWallpaper(CacheWallpaperResult result) { File wallpaperFile = new File(mRomInfo.getWallpaperPath()); RequestCreator creator;/*from www . ja va 2s . c o m*/ if (result == CacheWallpaperResult.USES_LIVE_WALLPAPER) { Toast.makeText(this, "Cannot preview live wallpaper", Toast.LENGTH_SHORT).show(); } if (result == CacheWallpaperResult.UP_TO_DATE || result == CacheWallpaperResult.UPDATED) { creator = Picasso.with(this).load(wallpaperFile).error(R.drawable.material); } else { creator = Picasso.with(this).load(R.drawable.material); } creator.transform(PaletteGeneratorTransformation.getInstance()).into(mWallpaper, new PaletteGeneratorCallback(mWallpaper) { @Override public void onObtainedPalette(Palette palette) { if (palette == null) { return; } Swatch swatch = palette.getMutedSwatch(); if (swatch == null) { swatch = palette.getDarkVibrantSwatch(); } if (swatch != null) { // Status bar should be slightly darker float[] hsl = swatch.getHsl(); hsl[2] -= 0.05; if (hsl[2] < 0) { hsl[2] = 0; } mCollapsing.setContentScrimColor(swatch.getRgb()); mCollapsing.setStatusBarScrimColor(ColorUtils.HSLToColor(hsl)); mFab.setBackgroundTintList(ColorStateList.valueOf(swatch.getRgb())); } //Swatch lightVibrant = palette.getLightVibrantSwatch(); //if (lightVibrant != null) { // collapsingToolbar.setCollapsedTitleTextColor(lightVibrant.getRgb()); // collapsingToolbar.setExpandedTitleColor(lightVibrant.getRgb()); //} } }); }