/** * Increments the values of this color with the given r, g, b and a values. * * @param r * @param g * @param b * @param a * @return this color for chaining */ public ColorRGBA addLocal(final float r, final float g, final float b, final float a) { return set(getRed() + r, getGreen() + g, getBlue() + b, getAlpha() + a); }
/** * Performs a linear interpolation between this color and the given end color, using the given scalar as a percent. * iow, if changeAmnt is closer to 0, the result will be closer to the current value of this color and if it is * closer to 1, the result will be closer to the end value. The result is stored back in this color. * * @param endColor * @param scalar * @return this color for chaining * @throws NullPointerException * if endVec is null. */ public ColorRGBA lerpLocal(final ReadOnlyColorRGBA endColor, final float scalar) { setRed((1.0f - scalar) * getRed() + scalar * endColor.getRed()); setGreen((1.0f - scalar) * getGreen() + scalar * endColor.getGreen()); setBlue((1.0f - scalar) * getBlue() + scalar * endColor.getBlue()); setAlpha((1.0f - scalar) * getAlpha() + scalar * endColor.getAlpha()); return this; }
public void draw(final Renderer renderer, final ReadOnlyTransform xform) { if (getSelectionLength() == 0) { return; } // set our alpha final ColorRGBA color = ColorRGBA.fetchTempInstance(); color.set(_standin.getDefaultColor()).setAlpha(UIComponent.getCurrentOpacity()); _standin.setDefaultColor(color); ColorRGBA.releaseTempInstance(color); // set our location _standin.setWorldTransform(xform); // draw _standin.render(renderer); }
private static void setModelAmbient(final LightStateRecord record, final ReadOnlyColorRGBA color) { if (!record.isValid() || !record.globalAmbient.equals(color)) { record.lightBuffer.clear(); record.lightBuffer.put(color.getRed()); record.lightBuffer.put(color.getGreen()); record.lightBuffer.put(color.getBlue()); record.lightBuffer.put(color.getAlpha()); record.lightBuffer.flip(); GL11.glLightModel(GL11.GL_LIGHT_MODEL_AMBIENT, record.lightBuffer); record.globalAmbient.set(color); } }
/** * Sets the value of this color to (r, g, b, a) * * @param r * new red value, generally should be in the range [0.0f, 1.0f] * @param g * new green value, generally should be in the range [0.0f, 1.0f] * @param b * new blue value, generally should be in the range [0.0f, 1.0f] * @param a * new alpha value, generally should be in the range [0.0f, 1.0f] * @return this color for chaining */ public ColorRGBA set(final float r, final float g, final float b, final float a) { setRed(r); setGreen(g); setBlue(b); setAlpha(a); return this; }
/** * Set transparency based on native screen size. * * @param capSize * 1/(font point size) * @param depthScale * @param alphaFallof */ protected void screenSizeCapAlphaFade(final double capSize, final double depthScale, final float alphaFallof) { if (capSize < depthScale) { final float unit = (float) ((depthScale - capSize) / capSize); float f = alphaFallof - unit; f = (f < 0) ? 0 : f / alphaFallof; final float alpha = _textClr.getAlpha() * f; _tempClr.set(_textClr); _tempClr.setAlpha(alpha); setDefaultColor(_tempClr); } else { setDefaultColor(_textClr); } }
@Test public void testValid() { final ColorRGBA clr1 = new ColorRGBA(0, 0, 0, 0); final ColorRGBA clr2A = new ColorRGBA(Float.POSITIVE_INFINITY, 0, 0, 0); final ColorRGBA clr2B = new ColorRGBA(0, Float.NEGATIVE_INFINITY, 0, 0); final ColorRGBA clr2C = new ColorRGBA(0, 0, Float.POSITIVE_INFINITY, 0); final ColorRGBA clr2D = new ColorRGBA(0, 0, 0, Float.POSITIVE_INFINITY); final ColorRGBA clr3A = new ColorRGBA(Float.NaN, 0, 0, 0); final ColorRGBA clr3B = new ColorRGBA(0, Float.NaN, 0, 0); final ColorRGBA clr3C = new ColorRGBA(0, 0, Float.NaN, 0); final ColorRGBA clr3D = new ColorRGBA(0, 0, 0, Float.NaN); assertTrue(ColorRGBA.isValid(clr1)); assertFalse(ColorRGBA.isValid(clr2A)); assertFalse(ColorRGBA.isValid(clr2B)); assertFalse(ColorRGBA.isValid(clr2C)); assertFalse(ColorRGBA.isValid(clr2D)); assertFalse(ColorRGBA.isValid(clr3A)); assertFalse(ColorRGBA.isValid(clr3B)); assertFalse(ColorRGBA.isValid(clr3C)); assertFalse(ColorRGBA.isValid(clr3D)); clr3C.zero(); assertTrue(ColorRGBA.isValid(clr3C)); assertFalse(ColorRGBA.isValid(null)); assertFalse(clr1.equals(null)); assertFalse(clr1.equals(new Vector2()));
/** * Instantiates a new drawable camera. */ public DrawableCamera() { this(null, new ColorRGBA(0, 1, 1, 1), (short) 0xF000); }
/** * Interpolates between the given colors using the * {@link ColorRGBA#lerpLocal(ReadOnlyColorRGBA, ReadOnlyColorRGBA, float)} method. */ @Override protected void interpolate(final ReadOnlyColorRGBA from, final ReadOnlyColorRGBA to, final double delta, final Mesh caller) { assert (null != from) : "parameter 'from' can not be null"; assert (null != to) : "parameter 'to' can not be null"; assert (null != caller) : "parameter 'caller' can not be null"; final ColorRGBA color = ColorRGBA.fetchTempInstance().set(caller.getDefaultColor()); color.lerpLocal(from, to, (float) delta); caller.setDefaultColor(color); ColorRGBA.releaseTempInstance(color); }
final ColorRGBA color = ColorRGBA.fetchTempInstance(); color.set(1, 1, 1, getCombinedOpacity()); _standin.setDefaultColor(color); ColorRGBA.releaseTempInstance(color);
/** * Checks to see if the given ColorRGBA is equals to the data stored in the buffer at the given data index. * * @param check * the color to check against - null will return false. * @param buf * the buffer to compare data with * @param index * the position (in terms of colors, not floats) of the color in the buffer to check against * @return */ public static boolean equals(final ReadOnlyColorRGBA check, final FloatBuffer buf, final int index) { final ColorRGBA temp = new ColorRGBA(); populateFromBuffer(temp, buf, index); return temp.equals(check); }
/** * sets a color that is used with CombinerSource.Constant * * @param red * @param green * @param blue * @param alpha */ public void setConstantColor(final float red, final float green, final float blue, final float alpha) { _constantColor.set(red, green, blue, alpha); }
public void actionPerformed(final ActionEvent e) { _sColorPanel.setEnabled(colorCheck.isSelected()); alphaLabel.setEnabled(colorCheck.isSelected()); colorLabel.setEnabled(colorCheck.isSelected()); _alphaSpinner.setEnabled(colorCheck.isSelected()); final ColorRGBA color = AwtColorUtil.makeColorRGBA(_sColorPanel.getBackground()); color.setAlpha(((Number) _alphaSpinner.getValue()).intValue() / 255f); entry.setColor(colorCheck.isSelected() ? color : RampEntry.DEFAULT_COLOR); } });
if (!_color.equals(other._color)) { return false;
public void draw(final Renderer renderer, final ReadOnlyTransform xform) { if (getSelectionLength() == 0) { return; } // set our alpha final ColorRGBA color = ColorRGBA.fetchTempInstance(); color.set(_standin.getDefaultColor()).setAlpha(UIComponent.getCurrentOpacity()); _standin.setDefaultColor(color); ColorRGBA.releaseTempInstance(color); // set our location _standin.setWorldTransform(xform); // draw _standin.render(renderer); }
private static void setAmbient(final int index, final LightStateRecord record, final ReadOnlyColorRGBA ambient, final LightRecord lr) { if (!record.isValid() || !lr.ambient.equals(ambient)) { record.lightBuffer.clear(); record.lightBuffer.put(ambient.getRed()); record.lightBuffer.put(ambient.getGreen()); record.lightBuffer.put(ambient.getBlue()); record.lightBuffer.put(ambient.getAlpha()); record.lightBuffer.flip(); GL11.glLight(GL11.GL_LIGHT0 + index, GL11.GL_AMBIENT, record.lightBuffer); lr.ambient.set(ambient); } }
/** * Updates the values of the given color from the specified buffer at the index provided. * * @param store * the color to set data on * @param buf * the buffer to read from * @param index * the position (in terms of colors, not floats) to read from the buf */ public static void populateFromBuffer(final ColorRGBA store, final FloatBuffer buf, final int index) { store.setRed(buf.get(index * 4)); store.setGreen(buf.get(index * 4 + 1)); store.setBlue(buf.get(index * 4 + 2)); store.setAlpha(buf.get(index * 4 + 3)); }