mixing color

hi ,..anyone know how to mix color in Java. for example, i've drawn a yellow color on applet canvas, and now i choose new color of brushes, and i overlap the "yellow" drawing, i want to make the color become "yellow + new color"
[236 byte] By [don.juan9a] at [2007-11-27 9:21:18]
# 1
Get the color attribute of the pixel, then getRed(), getBlue(), getGreen() - add the red, blue, green attributes of your new color to these and change the color of the pixel to the new color. Should work, no?
Navy_Codera at 2007-7-12 22:15:04 > top of Java-index,Java Essentials,Java Programming...
# 2

i try this, getting the red, blue, and green and + with the new color's red, green, and blue. then i mod 256 to prevent bounding.

it;s color is not like the mix color that i want.

for example , black = 255. then i add with some bright color, say its value is 100. it becomes 100 instead of the combination of both color (because 255 + 100 = 355%256 = 100)

don.juan9a at 2007-7-12 22:15:04 > top of Java-index,Java Essentials,Java Programming...
# 3

> i try this, getting the red, blue, and green and +

> with the new color's red, green, and blue. then i mod

> 256 to prevent bounding.

You should average the two values. So if you had two red values, one is 255 and the other is 100, then:

255 + 100

= 177 (<-- new red value)

2

You can also draw with a translucent color. If the background color is yellow and you want to mix it with red, then create the red color like this.

Color translucentRed = new Color(255, 0, 0, 128);

http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Color.html#Color(int,%20int,%20int,%20int)

CaptainMorgan08a at 2007-7-12 22:15:04 > top of Java-index,Java Essentials,Java Programming...