JAVA - swing - draw/fill with invert/negated colors of destination canvas -


i cannot find info on how draw shapes on graphic canvas, making sure draw not same color background

there solutions out there use images drawing per pixel operations/loops or filters; tried different composite operations, none suit want

so lets

g.setcolor(color.white) // relevant in case ? not sure g.fillrect(...) 

i want rectangle in inverted colors of background visible

sorry cant provide more code, dont know how achieve this

thanks

your paint method retrieve current color, , search complementary color:

        color originalcolor = g.getcolor();          g.setcolor(complementarycolor(originalcolor));         g.fillrect(0, 0, 50, 50); 

the complementarycolor method inspired topic : reverse opposing colors

color complementarycolor(final color bgcolor) {      color complement = new color(255 - bgcolor.getred(),             255 - bgcolor.getgreen(),             255 - bgcolor.getblue());      return complement; } 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -