/** * Increments the values of this color with the r, g, b and a values of the given color. * * @param source * @return this color for chaining * @throws NullPointerException * if source is null. */ public ColorRGBA addLocal(final ReadOnlyColorRGBA source) { return addLocal(source.getRed(), source.getGreen(), source.getBlue(), source.getAlpha()); }
/** * Increments the values of this color with the r, g, b and a values of the given color. * * @param source * @return this color for chaining * @throws NullPointerException * if source is null. */ public ColorRGBA addLocal(final ReadOnlyColorRGBA source) { return addLocal(source.getRed(), source.getGreen(), source.getBlue(), source.getAlpha()); }
@Test public void testAdd() { final ColorRGBA clr1 = new ColorRGBA(ColorRGBA.BLACK_NO_ALPHA); final ColorRGBA clr2 = new ColorRGBA(ColorRGBA.WHITE); clr1.addLocal(1, 2, 3, 4); assertEquals(new ColorRGBA(1, 2, 3, 4), clr1); clr1.addLocal(-1, -2, -3, -4); assertEquals(ColorRGBA.BLACK_NO_ALPHA, clr1); clr1.zero(); clr1.addLocal(clr2); assertEquals(ColorRGBA.WHITE, clr1); clr1.zero(); final ColorRGBA clr3 = clr1.add(clr2, new ColorRGBA()); assertEquals(ColorRGBA.BLACK_NO_ALPHA, clr1); assertEquals(ColorRGBA.WHITE, clr3); final ColorRGBA clr4 = clr1.add(0, 0, 0, 1, null); assertEquals(ColorRGBA.BLACK_NO_ALPHA, clr1); assertEquals(ColorRGBA.BLACK, clr4); }