add: Color.premulFade, fade should not be premultiplied by default
This commit is contained in:
parent
438c8d15e1
commit
87f4277b8b
@ -21,7 +21,7 @@ import org.oscim.utils.FastMath;
|
|||||||
|
|
||||||
public class Color {
|
public class Color {
|
||||||
|
|
||||||
public static int fade(int color, double alpha) {
|
public static int fadePremul(int color, double alpha) {
|
||||||
alpha = FastMath.clamp(alpha, 0, 1);
|
alpha = FastMath.clamp(alpha, 0, 1);
|
||||||
|
|
||||||
alpha *= (color >>> 24) & 0xff;
|
alpha *= (color >>> 24) & 0xff;
|
||||||
@ -36,6 +36,15 @@ public class Color {
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int fade(int color, double alpha) {
|
||||||
|
alpha = FastMath.clamp(alpha, 0, 1);
|
||||||
|
|
||||||
|
alpha *= (color >>> 24) & 0xff;
|
||||||
|
int c = (((int) alpha) & 0xff) << 24;
|
||||||
|
|
||||||
|
return c | (color & 0x00ffffff);
|
||||||
|
}
|
||||||
|
|
||||||
public static int rainbow(float pos) {
|
public static int rainbow(float pos) {
|
||||||
float i = 255 * pos;
|
float i = 255 * pos;
|
||||||
int r = (int) Math.round(Math.sin(0.024 * i + 0) * 127 + 128);
|
int r = (int) Math.round(Math.sin(0.024 * i + 0) * 127 + 128);
|
||||||
@ -81,8 +90,7 @@ public class Color {
|
|||||||
return ((color >>> 24) & 0xff) / 255f;
|
return ((color >>> 24) & 0xff) / 255f;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* Copyright (C) 2006 The Android Open Source Project
|
||||||
* Copyright (C) 2006 The Android Open Source Project
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -94,8 +102,7 @@ public class Color {
|
|||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License. */
|
||||||
*/
|
|
||||||
public static final int BLACK = 0xFF000000;
|
public static final int BLACK = 0xFF000000;
|
||||||
public static final int DKGRAY = 0xFF444444;
|
public static final int DKGRAY = 0xFF444444;
|
||||||
public static final int GRAY = 0xFF888888;
|
public static final int GRAY = 0xFF888888;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user