private void generateBackground(float delta) { // float x = Time.getTime() * backgroundColorSpeed; backgroundColor.r = MathUtils.sin(Time.getTime() * backgroundColorSpeed * 0.8f) * 0.1f + 0.7f; backgroundColor.g = MathUtils.sin(Time.getTime() * backgroundColorSpeed * 0.7f) * 0.1f + 0.7f; backgroundColor.b = MathUtils.sin(Time.getTime() * backgroundColorSpeed * 0.9f) * 0.1f + 0.56f; Gdx.app.log("LOG", String.valueOf(backgroundColor.r)); }
@Override public void blend(Color source, Color dest, Color output) { output.r = (1 - ((1 - dest.r) * (1 - source.r))); output.g = (1 - ((1 - dest.g) * (1 - source.g))); output.b = (1 - ((1 - dest.b) * (1 - source.b))); output.a = dest.a; output.clamp(); }
@Override public void blend(Color source, Color dest, Color output) { output.r = (dest.r == 1) ? 1 : source.r / (1 - dest.r); output.g = (dest.g == 1) ? 1 : source.g / (1 - dest.g); output.b = (dest.b == 1) ? 1 : source.b / (1 - dest.b); output.a = dest.a; output.clamp(); }
// TCOD_BKGND_OVERLAY @Override public void blend(Color source, Color dest, Color output) { output.r = source.r <= 0.5 ? 2 * (source.r) * dest.r : 1 - 2 * (1 - source.r) * (1 - dest.r); output.g = source.g <= 0.5 ? 2 * (source.g) * dest.g : 1 - 2 * (1 - source.g) * (1 - dest.g); output.b = source.b <= 0.5 ? 2 * (source.b) * dest.b : 1 - 2 * (1 - source.b) * (1 - dest.b); output.a = dest.a; output.clamp(); }
@Override public void blend(Color source, Color dest, Color output) { output.r = min(source.r, dest.r); output.g = min(source.g, dest.g); output.b = min(source.b, dest.b); output.a = dest.a; output.clamp(); }
// JCOD Extension @Override public void blend(Color source, Color dest, Color output) { output.r = source.r * source.a + dest.r * (1 - source.a); output.g = source.g * source.a + dest.g * (1 - source.a); output.b = source.b * source.a + dest.b * (1 - source.a); output.a = dest.a; output.clamp(); }
@Override public void blend(Color source, Color dest, Color output) { output.r = (source.r == 0) ? 0 : 1 - (1 - dest.r) / source.r; output.g = (source.g == 0) ? 0 : 1 - (1 - dest.g) / source.g; output.b = (source.b == 0) ? 0 : 1 - (1 - dest.b) / source.b; output.a = dest.a; output.clamp(); }
/** * @return the rendering color of this SpriteBatch. Manipulating the returned instance has no * effect. */ public Color getColor() { int intBits = NumberUtils.floatToIntColor(color); Color color = this.tempColor; color.r = (intBits & 0xff) / 255f; color.g = ((intBits >>> 8) & 0xff) / 255f; color.b = ((intBits >>> 16) & 0xff) / 255f; color.a = ((intBits >>> 24) & 0xff) / 255f; return color; }
@Override public void blend(Color source, Color dest, Color output) { // can't use set/add/sub methods, they clamp too soon output.r = source.r + dest.r - 1; output.g = source.g + dest.g - 1; output.b = source.b + dest.b - 1; output.a = dest.a; output.clamp(); }
/** * Returns the color of this font. Changing the returned color will have no affect, {@link * #setColor(Color)} or {@link #setColor(float, float, float, float)} must be used. */ public Color getColor() { int intBits = Float.floatToRawIntBits(color); Color color = this.tempColor; color.r = (intBits & 0xff) / 255f; color.g = ((intBits >>> 8) & 0xff) / 255f; color.b = ((intBits >>> 16) & 0xff) / 255f; color.a = ((intBits >>> 24) & 0xff) / 255f; return color; }
public static void showTips(String text, float originX, float originY, Color color) { // Vector3 pos = new Vector3(originX, originY, 0.0f); // CameraController.getInstance(CameraController.class).worldToScreen(pos); TipsBillborad tip = allocTipsBillboard(); tip.life = 0.0f; tip.text = text; tip.oringinX = originX; tip.oringinY = originY; tip.velocity.x = 0.0f; tip.velocity.y = Settings.UNIT * 0.2f; tip.color.r = color.r; tip.color.g = color.g; tip.color.b = color.b; }
@Override public Tint tween(Tint a, Tint b, float value) { final Interpolation linear = Interpolation.linear; final Color colorA = a.color; final Color colorB = b.color; color.r = linear.apply(colorA.r, colorB.r, value); color.g = linear.apply(colorA.g, colorB.g, value); color.b = linear.apply(colorA.b, colorB.b, value); color.a = linear.apply(colorA.a, colorB.a, value); return this; }
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); // setName(in.readUTF()); setX(in.readFloat()); setY(in.readFloat()); setWidth(in.readFloat()); setHeight(in.readFloat()); setOriginX(in.readFloat()); setOriginY(in.readFloat()); setScaleX(in.readFloat()); setScaleY(in.readFloat()); setRotation(in.readFloat()); Color color = new Color(); color.r = in.readFloat(); color.g = in.readFloat(); color.b = in.readFloat(); color.a = in.readFloat(); setColor(color); }
@Override public void start() { OwnedObjectData data = new OwnedObjectData(); data.drawAfter = true; if (bullet.getTicksAlive() < 20) animationPlaying = true; createTick = game.getTick(); bullet.addOwnedObject(this, data); final Sprite current = (Sprite) this.ani.getKeyFrame(getTicksAlive()); Polygon hitbox = bullet.getHitbox(); Rectangle rect = hitbox != null ? hitbox.getBoundingRectangle() : current.getBoundingRectangle(); final float modifier = 3f; float width = rect.getWidth() * modifier; float height = rect.getHeight() * modifier; final float scaleX = width / current.getWidth(); final float scaleY = height / current.getHeight(); current.setScale(scaleX, scaleY); current.setRotation(bullet.getRotationDeg()); current.setOriginCenter(); Color c = bullet.getDeletionColor().cpy(); float min = Math.min(c.g, Math.min(c.r, c.b)); c.r -= min; c.g -= min; c.b -= min; float mul = 0.8f; float start = (1f - mul) + 0.3f; Color color = new Color(start + (c.r * mul), start + (c.g * mul), start + (c.b * mul), 0f); current.setColor(color); current.setAlpha(1f); final SaveableObject<ScaleAlphaPhaseAnimation> sani = new SaveableObject<ScaleAlphaPhaseAnimation>(); Getter<Sprite> getter = new Getter<Sprite>() { @Override public Sprite get() { Sprite current = (Sprite) ani.getKeyFrame(getTicksAlive()); int over = 5; int ticks = (int) ((time.toTicks() - over) - getTicksAlive()); double mul = 1f - (ticks <= 0 ? -(float) ticks / over : 0f); ScaleAlphaPhaseAnimation ani = sani.getObject(); if (ani == null) return current; if (ticks <= 0) { animationPlaying = false; ani.setAlpha((float) Math.max(0, mul)); } current.setPosition( bullet.getX() - current.getWidth() / 2f, bullet.getY() - current.getHeight() / 2f); current.setOriginCenter(); current.setRotation(bullet.getRotationDeg()); return current; } }; final ScaleAlphaPhaseAnimation ani = new ScaleAlphaPhaseAnimation(getter, bullet); sani.setObject(ani); ani.setTime(time); ani.setAddedScale(scaleX * 3f, scaleY * 3f); ani.setAlpha(-0.1f); ani.start(); bullet.removeOwnedObject(ani); bullet.addOwnedObject(ani, data); }