当前位置: 首页>>代码示例>>Java>>正文


Java Color.green方法代码示例

本文整理汇总了Java中android.graphics.Color.green方法的典型用法代码示例。如果您正苦于以下问题:Java Color.green方法的具体用法?Java Color.green怎么用?Java Color.green使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Color的用法示例。


在下文中一共展示了Color.green方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setColor

import android.graphics.Color; //导入方法依赖的package包/类
/**
 * Set the color this view should show.
 * @param color The color that should be selected. #argb
 * @param callback If you want to get a callback to
 * your OnColorChangedListener.
 */
public void setColor(int color, boolean callback){

	int alpha = Color.alpha(color);
	int red = Color.red(color);
	int blue = Color.blue(color);
	int green = Color.green(color);
	
	float[] hsv = new float[3];
	
	Color.RGBToHSV(red, green, blue, hsv);
	
	mAlpha = alpha;
	mHue = hsv[0];
	mSat = hsv[1];
	mVal = hsv[2];
	
	if(callback && mListener != null){			
		mListener.onColorChanged(Color.HSVToColor(mAlpha, new float[]{mHue, mSat, mVal}));				
	}
	
	invalidate();
}
 
开发者ID:MohammadAlBanna,项目名称:Swift-Braille-Soft-keyboard,代码行数:29,代码来源:ColorPickerView.java

示例2: newColor

import android.graphics.Color; //导入方法依赖的package包/类
private void newColor(int color){
    this.color = color;

    // Sets action bar colors
    if (getSupportActionBar() == null) return;

    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(0xFF000000 | color));

    boolean dark = Color.red(color) * 0.299 + Color.green(color) * 0.587 + Color.blue(color) * 0.114 < 180;
    SpannableString s = new SpannableString(getSupportActionBar().getTitle());
    s.setSpan(new ForegroundColorSpan(dark ? Color.WHITE : Color.BLACK), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    getSupportActionBar().setTitle(s);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        float[] hsv = new float[3];
        Color.colorToHSV(color, hsv);
        hsv[2] *= 0.75;
        getWindow().setStatusBarColor(Color.HSVToColor(hsv));
    }
}
 
开发者ID:eltos,项目名称:SimpleDialogFragments,代码行数:21,代码来源:MainActivity.java

示例3: findClosest

import android.graphics.Color; //导入方法依赖的package包/类
/**
 * Returns index of palette color closest to c
 *
 */
private int findClosest(int color) {
    if (colorTab == null)
        return -1;
    int r = Color.red(color);
    int g = Color.green(color);
    int b = Color.blue(color);
    int minpos = 0;
    int dmin = 256 * 256 * 256;
    int len = colorTab.length;
    for (int i = 0; i < len;) {
        int dr = r - (colorTab[i++] & 0xff);
        int dg = g - (colorTab[i++] & 0xff);
        int db = b - (colorTab[i] & 0xff);
        int d = dr * dr + dg * dg + db * db;
        int index = i / 3;
        if (usedEntry[index] && (d < dmin)) {
            dmin = d;
            minpos = index;
        }
        i++;
    }
    return minpos;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:AnimatedGifEncoder.java

示例4: computeColor

import android.graphics.Color; //导入方法依赖的package包/类
/**
 * 根据比例,在两个color值之间计算出一个color值
 * <b>注意该方法是ARGB通道分开计算比例的</b>
 *
 * @param fromColor 开始的color值
 * @param toColor   最终的color值
 * @param fraction  比例,取值为[0,1],为0时返回 fromColor, 为1时返回 toColor
 * @return 计算出的color值
 */
public static int computeColor(@ColorInt int fromColor, @ColorInt int toColor, float fraction) {
    fraction = Math.max(Math.min(fraction, 1), 0);

    int minColorA = Color.alpha(fromColor);
    int maxColorA = Color.alpha(toColor);
    int resultA = (int) ((maxColorA - minColorA) * fraction) + minColorA;

    int minColorR = Color.red(fromColor);
    int maxColorR = Color.red(toColor);
    int resultR = (int) ((maxColorR - minColorR) * fraction) + minColorR;

    int minColorG = Color.green(fromColor);
    int maxColorG = Color.green(toColor);
    int resultG = (int) ((maxColorG - minColorG) * fraction) + minColorG;

    int minColorB = Color.blue(fromColor);
    int maxColorB = Color.blue(toColor);
    int resultB = (int) ((maxColorB - minColorB) * fraction) + minColorB;

    return Color.argb(resultA, resultR, resultG, resultB);
}
 
开发者ID:coopese,项目名称:qmui,代码行数:31,代码来源:QMUIColorHelper.java

示例5: grayscaleFromRGB

import android.graphics.Color; //导入方法依赖的package包/类
private static int grayscaleFromRGB(final int color) {
    final int red = Color.red(color);
    final int green = Color.green(color);
    final int blue = Color.blue(color);
    // Magic weighting taken from a stackoverflow post, supposedly related to how
    // humans perceive color.
    return (int) (0.299 * red + 0.587 * green + 0.114 * blue);
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:9,代码来源:ColorUtils.java

示例6: blendColors

import android.graphics.Color; //导入方法依赖的package包/类
/**
 * Blend {@code color1} and {@code color2} using the given ratio.
 * @param ratio of which to blend. 1.0 will return {@code color1}, 0.5 will give an even blend,
 *              0.0 will return {@code color2}.
 */
private static int blendColors(int color1, int color2, float ratio) {
    final float inverseRation = 1f - ratio;
    float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
    float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
    float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
    return Color.rgb((int) r, (int) g, (int) b);
}
 
开发者ID:NEYouFan,项目名称:ht-viewpagerwithindicator,代码行数:13,代码来源:SlidingTabStrip.java

示例7: darken

import android.graphics.Color; //导入方法依赖的package包/类
public static int darken(int color, float factor) {
	int a = Color.alpha(color);
	int r = Color.red(color);
	int g = Color.green(color);
	int b = Color.blue(color);

	return Color.argb(a,
		Math.max((int)(r * factor), 0),
		Math.max((int)(g * factor), 0),
		Math.max((int)(b * factor), 0));
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:12,代码来源:ColorPickerPreference.java

示例8: blendColors

import android.graphics.Color; //导入方法依赖的package包/类
private static int blendColors(int color1, int color2, float factor) {
    final float inverseFactor = 1f - factor;
    float a = (Color.alpha(color1) * factor) + (Color.alpha(color2) * inverseFactor);
    float r = (Color.red(color1) * factor) + (Color.red(color2) * inverseFactor);
    float g = (Color.green(color1) * factor) + (Color.green(color2) * inverseFactor);
    float b = (Color.blue(color1) * factor) + (Color.blue(color2) * inverseFactor);
    return Color.argb((int) a, (int) r, (int) g, (int) b);
}
 
开发者ID:DuanJiaNing,项目名称:Musicoco,代码行数:9,代码来源:MarkerDrawable.java

示例9: generateTransparentColor

import android.graphics.Color; //导入方法依赖的package包/类
private int generateTransparentColor(float percent, int rgb) {
    int red = Color.red(rgb);
    int green = Color.green(rgb);
    int blue = Color.blue(rgb);
    int alpha = Color.alpha(rgb);
    alpha = (int) (alpha * percent);
    return Color.argb(alpha, red, green, blue);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:PaletteActivity1.java

示例10: getLightenColor

import android.graphics.Color; //导入方法依赖的package包/类
private int getLightenColor(int color){
    double fraction = 0.2;
    int red = Color.red(color);
    int green = Color.green(color);
    int blue = Color.blue(color);
    red = (int)Math.min(red + (red * fraction), 255);
    green = (int)Math.min(green + (green * fraction), 255);
    blue = (int)Math.min(blue + (blue * fraction), 255);
    int alpha = Color.alpha(color);
    return Color.argb(alpha, red, green, blue);
}
 
开发者ID:mjn1369,项目名称:PrettyDialog,代码行数:12,代码来源:PrettyDialogButton.java

示例11: blendColors

import android.graphics.Color; //导入方法依赖的package包/类
public static int blendColors(int color1, int color2, float ratio) {
    final float inverseRation = 1f - ratio;
    float r = (Color.red(color1) * ratio) + (Color.red(color2) * inverseRation);
    float g = (Color.green(color1) * ratio) + (Color.green(color2) * inverseRation);
    float b = (Color.blue(color1) * ratio) + (Color.blue(color2) * inverseRation);
    return Color.rgb((int) r, (int) g, (int) b);
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:8,代码来源:Utils.java

示例12: getSubTitleTextColor

import android.graphics.Color; //导入方法依赖的package包/类
static int getSubTitleTextColor(@ColorInt int color) {
    int titleColor = getTitleTextColor(color);
    int alpha2 = Math.round(Color.alpha(titleColor) * 0.7f);
    int red = Color.red(titleColor);
    int green = Color.green(titleColor);
    int blue = Color.blue(titleColor);
    return Color.argb(alpha2, red, green, blue);
}
 
开发者ID:danimahardhika,项目名称:cafebar,代码行数:9,代码来源:CafeBarUtil.java

示例13: blendColors

import android.graphics.Color; //导入方法依赖的package包/类
/**
 * Taken from CollapsingToolbarLayout's CollapsingTextHelper class.
 */
public static int blendColors(int color1, int color2, @FloatRange(from = 0.0, to = 1.0) float ratio) {
    final float inverseRatio = 1f - ratio;
    float a = (Color.alpha(color1) * inverseRatio) + (Color.alpha(color2) * ratio);
    float r = (Color.red(color1) * inverseRatio) + (Color.red(color2) * ratio);
    float g = (Color.green(color1) * inverseRatio) + (Color.green(color2) * ratio);
    float b = (Color.blue(color1) * inverseRatio) + (Color.blue(color2) * ratio);
    return Color.argb((int) a, (int) r, (int) g, (int) b);
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:12,代码来源:ColorUtil.java

示例14: getColorDarkness

import android.graphics.Color; //导入方法依赖的package包/类
public static double getColorDarkness(@ColorInt int color) {
    if (color == Color.BLACK)
        return 1.0;
    else if (color == Color.WHITE || color == Color.TRANSPARENT)
        return 0.0;
    else
        return (1 - (0.299 * Color.red(color) + 0.587 * Color.green(color) + 0.114 * Color.blue(color)) / 255);
}
 
开发者ID:htqqdd,项目名称:music_player,代码行数:9,代码来源:ColorUtil.java

示例15: convertToY

import android.graphics.Color; //导入方法依赖的package包/类
static int convertToY(int color) {
    double R = Color.red(color);
    double G = Color.green(color);
    double B = Color.blue(color);
    return clamp(16.0 + (.003906 * ((65.738 * R) + (129.057 * G) + (25.064 * B))));
}
 
开发者ID:olgamiller,项目名称:SSTVEncoder2,代码行数:7,代码来源:YuvConverter.java


注:本文中的android.graphics.Color.green方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。