I have the following code:
Color3D pixel = new Color3D(200, 0, 0);
Color3D temporal = pixel;
System.out.println(util.printColor("Pixel: ", pixel));
System.out.println(util.printColor("Temporal: ", temporal));
pixel.setR(0);
pixel.setG(200);
pixel.setB(0);
System.out.println(util.printColor("Pixel: ", pixel));
System.out.println(util.printColor("Temporal: ", temporal));
Result:
Pixel: r: 200, g: 0, b: 0
Temporal: r: 200, g: 0, b: 0
Pixel: r: 0, g: 200, b: 0
Temporal: r: 0, g: 200, b: 0
My class Color3D saves RGB (int)values.
I use the object util to print the int values of a Color3D object.
If you look at the result, for some reason after changing the red and green values of the pixel object I'm also modifying the green's values and I don't want that behaviour.
I want to have:
Pixel: r: 200, g: 0, b: 0
Temporal: r: 200, g: 0, b: 0
Pixel: r: 0, g: 200, b: 0
Temporal: r: 200, g: 0, b: 0
The object temporal was created with the intention of saving the pixel object values for a future process. The object temporal will also change in future...