check range in blendColors
This commit is contained in:
parent
4408a86a5b
commit
2b68d93891
@ -104,16 +104,14 @@ public final class PolygonRenderer {
|
||||
/* fade in/out || draw alpha color */
|
||||
if (l.area.fade >= zoom) {
|
||||
f = (scale > FADE_START ? scale : FADE_START) - f;
|
||||
if (f > 1.0f)
|
||||
f = 1.0f;
|
||||
}
|
||||
|
||||
}
|
||||
if (!blend) {
|
||||
glEnable(GL_BLEND);
|
||||
blend = true;
|
||||
}
|
||||
if (f != 1) {
|
||||
f *= l.area.color[3];
|
||||
f = (f > 1 ? 1 : f) * l.area.color[3];
|
||||
GlUtils.setColor(hPolygonColor, l.area.color, f);
|
||||
} else {
|
||||
glUniform4fv(hPolygonColor, 1, l.area.color, 0);
|
||||
@ -121,14 +119,8 @@ public final class PolygonRenderer {
|
||||
} else if (l.area.blend == zoom) {
|
||||
/* blend colors */
|
||||
f = scale - 1.0f;
|
||||
if (f > 1.0f)
|
||||
f = 1.0f;
|
||||
else if (f < 0)
|
||||
f = 0;
|
||||
|
||||
GlUtils.setBlendColors(hPolygonColor,
|
||||
l.area.color, l.area.blendColor, f);
|
||||
|
||||
} else {
|
||||
/* draw solid */
|
||||
if (blend) {
|
||||
|
@ -185,13 +185,18 @@ public class GlUtils {
|
||||
// this is save as it can only be called from glThread
|
||||
private static float[] tmpColor = new float[4];
|
||||
|
||||
public static void setBlendColors(int handle, float[] c1, float[] c2, float alpha) {
|
||||
tmpColor[0] = c1[0] * (1 - alpha) + c2[0] * alpha;
|
||||
tmpColor[1] = c1[1] * (1 - alpha) + c2[1] * alpha;
|
||||
tmpColor[2] = c1[2] * (1 - alpha) + c2[2] * alpha;
|
||||
tmpColor[3] = c1[3] * (1 - alpha) + c2[3] * alpha;
|
||||
|
||||
GLES20.glUniform4fv(handle, 1, tmpColor, 0);
|
||||
public static void setBlendColors(int handle, float[] c1, float[] c2, float mix) {
|
||||
if (mix <= 0f)
|
||||
GLES20.glUniform4fv(handle, 1, c1, 0);
|
||||
else if (mix >= 1f)
|
||||
GLES20.glUniform4fv(handle, 1, c2, 0);
|
||||
else {
|
||||
tmpColor[0] = c1[0] * (1 - mix) + c2[0] * mix;
|
||||
tmpColor[1] = c1[1] * (1 - mix) + c2[1] * mix;
|
||||
tmpColor[2] = c1[2] * (1 - mix) + c2[2] * mix;
|
||||
tmpColor[3] = c1[3] * (1 - mix) + c2[3] * mix;
|
||||
GLES20.glUniform4fv(handle, 1, tmpColor, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setColor(int handle, float[] c, float alpha) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user