/** * Adds the values of the given source color to those of this color and returns them in store. * * @param source * @param store * the color to store the result in for return. If null, a new color object is created and returned. * @return (this.r + source.r, this.g + source.g, this.b + source.b, this.a + source.a) * @throws NullPointerException * if source is null. */ @Override public ColorRGBA add(final ReadOnlyColorRGBA source, final ColorRGBA store) { return add(source.getRed(), source.getGreen(), source.getBlue(), source.getAlpha(), store); }
@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); }
/** * Adds the values of the given source color to those of this color and returns them in store. * * @param source * @param store * the color to store the result in for return. If null, a new color object is created and returned. * @return (this.r + source.r, this.g + source.g, this.b + source.b, this.a + source.a) * @throws NullPointerException * if source is null. */ @Override public ColorRGBA add(final ReadOnlyColorRGBA source, final ColorRGBA store) { return add(source.getRed(), source.getGreen(), source.getBlue(), source.getAlpha(), store); }