这是我读到的有关它的内容,但无法准确理解它的作用:
One way to implement rubber-banding is to draw in XOR mode. You set XOR mode by calling the setXORMode() method for a graphics context and passing a color to it — usually the background color. In this mode the pixels are not written directly to the screen. The color in which you are drawing is combined with the color of the pixel currently displayed together with a third color that you specify, by exclusive ORing them together, and the resultant pixel color is written to the screen. The third color is usually set to be the background color, so the color of the pixel that is written is the result of the following operation:
resultant_Color = foreground_color^background_color^current_color
我知道异或运算的工作原理,但不知道上面的段落是什么意思。请帮我解释一下
最佳答案
它接受颜色并应用 XOR 掩码,就像常规 XOR 会位掩码一样,但它是在 RGB 颜色上,因此如果它覆盖具有相同值或相同值的颜色,它会生成您传入的颜色。如果值不同,则为该颜色 RGB 的反转,以及低于其 RGB 的颜色。
只需编写一些代码并尝试一下,就会立即看出会发生什么。
关于java - 简单来说,Graphics.setXORMode(Color) 的作用是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12127187/