Graphics.setXORMode(Color) 简单来说是做什么的? [英] What does Graphics.setXORMode(Color) do in simple terms?

查看:50
本文介绍了Graphics.setXORMode(Color) 简单来说是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我读到的关于它的内容,但无法确切理解它的作用:

Here is what I read about it but cant understand exactly what it does:

实现橡皮筋的一种方法是在 XOR 模式下绘制.你设置XOR 模式通过调用图形上下文的 setXORMode() 方法和传递一种颜色——通常是背景颜色.在这种模式下像素不会直接写入屏幕.其中的颜色您正在绘制与当前像素的颜色相结合与您指定的第三种颜色一起显示将它们组合在一起,并将结果像素颜色写入屏幕.第三种颜色通常设置为背景颜色,所以写入的像素的颜色是以下结果操作:

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

我知道异或是如何工作的,但不知道上面的段落是什么意思.请帮我解释一下

I know how XORing works but don't know what the above paragraph means. Please elucidate it for me

推荐答案

它接受一个颜色并应用一个 XOR 掩码,就像普通的 XOR 将一个位掩码一样,除了它是在 RGB 颜色上,所以它产生了颜色如果它覆盖具有相同值的颜色或该颜色的倒数 RGB 和低于其 RGB 的颜色(如果值不同),则传入.

It takes a color in and applies an XOR mask just like a regular XOR would a bit mask, except it is on the RGB colors, so it produces the color you pass in if it overlays a color with the same values or the inverse of that colors RGB and and color below its RGB if the values are different.

只需编写一些代码并尝试一下,就会立即看到会发生什么.

Just write some code and try it and it will be immediate evident what happens.

这篇关于Graphics.setXORMode(Color) 简单来说是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆