本文整理汇总了Java中android.graphics.Color.HSVToColor方法的典型用法代码示例。如果您正苦于以下问题:Java Color.HSVToColor方法的具体用法?Java Color.HSVToColor怎么用?Java Color.HSVToColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Color
的用法示例。
在下文中一共展示了Color.HSVToColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: calculateColor
import android.graphics.Color; //导入方法依赖的package包/类
/**
* Calculate the color selected by the pointer on the bar.
*
* @param coord
* Coordinate of the pointer.
*/
private void calculateColor(int coord) {
coord = coord - mBarPointerHaloRadius;
if (coord < 0) {
coord = 0;
} else if (coord > mBarLength) {
coord = mBarLength;
}
mColor = Color.HSVToColor(Math.round(mPosToOpacFactor * coord),
mHSVColor);
if (Color.alpha(mColor) > 250) {
mColor = Color.HSVToColor(mHSVColor);
} else if (Color.alpha(mColor) < 5) {
mColor = Color.TRANSPARENT;
}
}
示例2: makeBitmap
import android.graphics.Color; //导入方法依赖的package包/类
protected Bitmap makeBitmap(int w, int h) {
final boolean isWide = w > h;
final int n = Math.max(w, h);
int[] colors = new int[n];
float[] hsv = new float[]{0, 0, 0};
observableColor.getHsv(hsv);
for (int i = 0; i < n; ++i) {
hsv[2] = isWide ? (float)i / n : 1 - (float)i / n;
colors[i] = Color.HSVToColor(hsv);
}
final int bmpWidth = isWide ? w : 1;
final int bmpHeight = isWide ? 1 : h;
return Bitmap.createBitmap(colors, bmpWidth, bmpHeight, Bitmap.Config.ARGB_8888);
}
示例3: createColorWheelBitmap
import android.graphics.Color; //导入方法依赖的package包/类
private Bitmap createColorWheelBitmap(int width, int height) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
int colorCount = 12;
int colorAngleStep = 360 / 12;
int colors[] = new int[colorCount + 1];
float hsv[] = new float[] { 0f, 1f, 1f };
for (int i = 0; i < colors.length; i++) {
hsv[0] = (i * colorAngleStep + 180) % 360;
colors[i] = Color.HSVToColor(hsv);
}
colors[colorCount] = colors[0];
SweepGradient sweepGradient = new SweepGradient(width / 2, height / 2, colors, null);
RadialGradient radialGradient = new RadialGradient(width / 2, height / 2, colorWheelRadius, 0xFFFFFFFF, 0x00FFFFFF, TileMode.CLAMP);
ComposeShader composeShader = new ComposeShader(sweepGradient, radialGradient, PorterDuff.Mode.SRC_OVER);
colorWheelPaint.setShader(composeShader);
Canvas canvas = new Canvas(bitmap);
canvas.drawCircle(width / 2, height / 2, colorWheelRadius, colorWheelPaint);
return bitmap;
}
示例4: createColorDiscBitmap
import android.graphics.Color; //导入方法依赖的package包/类
private Bitmap createColorDiscBitmap(int radius) {
int centerColor, edgeColor;
Bitmap bitmap = Bitmap.createBitmap(2 * radius, 2 * radius, Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
mHSV[0] = 0; mHSV[1] = 1; mHSV[2] = 1; //red
SweepGradient sweepGradient = new SweepGradient(radius, radius, getColors(mHSV), null);
mColorPaint.setShader(sweepGradient);
canvas.drawCircle(radius, radius, radius, mColorPaint);
mHSV[0] = 0; mHSV[1] = 0; mHSV[2] = 1; //white
centerColor = Color.HSVToColor(255, mHSV);
edgeColor = Color.HSVToColor(0, mHSV);
RadialGradient radialGradient = new RadialGradient(radius, radius, radius, centerColor, edgeColor, TileMode.CLAMP);
mColorPaint.setShader(radialGradient);
canvas.drawCircle(radius, radius, radius, mColorPaint);
return bitmap;
}
示例5: setColor
import android.graphics.Color; //导入方法依赖的package包/类
/**
* Set the bar color. <br>
* <br>
* Its discouraged to use this method.
*
* @param color
*/
public void setColor(int color) {
int x1, y1;
if (mOrientation == ORIENTATION_HORIZONTAL) {
x1 = (mBarLength + mBarPointerHaloRadius);
y1 = mBarThickness;
} else {
x1 = mBarThickness;
y1 = (mBarLength + mBarPointerHaloRadius);
}
Color.colorToHSV(color, mHSVColor);
shader = new LinearGradient(mBarPointerHaloRadius, 0, x1, y1,
new int[] { Color.HSVToColor(0x00, mHSVColor), color }, null,
Shader.TileMode.CLAMP);
mBarPaint.setShader(shader);
calculateColor(mBarPointerPosition);
mBarPointerPaint.setColor(mColor);
if (mPicker != null) {
mPicker.setNewCenterColor(mColor);
}
invalidate();
}
示例6: buildHueColorArray
import android.graphics.Color; //导入方法依赖的package包/类
private int[] buildHueColorArray(){
int[] hue = new int[361];
int count = 0;
for(int i = hue.length -1; i >= 0; i--, count++){
hue[count] = Color.HSVToColor(new float[]{i, 1f, 1f});
}
return hue;
}
示例7: getClearerColor
import android.graphics.Color; //导入方法依赖的package包/类
public static int getClearerColor(int color) {
float[] hsv = new float[3];
Color.colorToHSV(color, hsv);
hsv[2] *= 1.4f; // value component
color = Color.HSVToColor(hsv);
return color;
}
示例8: makeColorDark
import android.graphics.Color; //导入方法依赖的package包/类
/**
* Get the darker version of the given color.
*
* @param color Normal color.
* @return Darker shade of the color.
* @see 'http://stackoverflow.com/a/4928826'
*/
@ColorInt
public static int makeColorDark(@ColorInt int color) {
float[] hsv = new float[3];
Color.colorToHSV(color, hsv);
hsv[2] = 1f - 0.8f * hsv[2]; // value component
return Color.HSVToColor(hsv);
}
示例9: getComplementaryColor
import android.graphics.Color; //导入方法依赖的package包/类
public static int getComplementaryColor(int colorToInvert) {
float[] hsv = new float[3];
Color.RGBToHSV(Color.red(colorToInvert), Color.green(colorToInvert),
Color.blue(colorToInvert), hsv);
hsv[0] = (hsv[0] + 180) % 360;
return Color.HSVToColor(hsv);
}
示例10: onColorsClicked
import android.graphics.Color; //导入方法依赖的package包/类
@OnClick(R.id.button_set_colors)
void onColorsClicked() {
int color = Color.HSVToColor(new float[]{
random.nextFloat() * 360,
1f,
0.75f
});
widget.setArrowColor(color);
widget.setSelectionColor(color);
}
示例11: darkenColor
import android.graphics.Color; //导入方法依赖的package包/类
public static int darkenColor(int color) {
float[] hsv = new float[3];
int alpha = Color.alpha(color);
Color.colorToHSV(color, hsv);
hsv[1] = Math.min(hsv[1] * DARKEN_SATURATION, 1.0f);
hsv[2] = hsv[2] * DARKEN_INTENSITY;
int tempColor = Color.HSVToColor(hsv);
return Color.argb(alpha, Color.red(tempColor), Color.green(tempColor), Color.blue(tempColor));
}
示例12: darkenColor
import android.graphics.Color; //导入方法依赖的package包/类
public static int darkenColor(int color) {
hsv = new float[3];
int alpha = Color.alpha(color);
Color.colorToHSV(color, hsv);
hsv[1] = Math.min(hsv[1] * DARKEN_SATURATION, 1.0f);
hsv[2] = hsv[2] * DARKEN_INTENSITY;
int tempColor = Color.HSVToColor(hsv);
return Color.argb(alpha, Color.red(tempColor), Color.green(tempColor), Color.blue(tempColor));
}
示例13: lightenColor
import android.graphics.Color; //导入方法依赖的package包/类
private static int lightenColor(int color) {
float[] hsv = new float[3];
Color.colorToHSV(color, hsv);
hsv[2] *= 1.1f;
return Color.HSVToColor(hsv);
}
示例14: getLighterColor
import android.graphics.Color; //导入方法依赖的package包/类
private int getLighterColor(int color) {
float[] hsv = new float[3];
Color.colorToHSV(color, hsv);
hsv[2] *= 1.1f;
return Color.HSVToColor(hsv);
}
示例15: getStatusBarColor
import android.graphics.Color; //导入方法依赖的package包/类
public static int getStatusBarColor(int primaryColor) {
float[] arrayOfFloat = new float[3];
Color.colorToHSV(primaryColor, arrayOfFloat);
arrayOfFloat[2] *= 0.9F;
return Color.HSVToColor(arrayOfFloat);
}