SETTING THE PAINT MODE
set drawing mode to XOR example..........
PAINTING MODE:
PAINTING MODE:
There are two painting or drawing modes for the Graphics class:- paint mode which is the default mode and XOR mode. In paint mode, anything we draw replaces whatever is already on the screen i.e. it overwrites any preexisting contents. If you draw a green circle, you get a green circle, no matter what was underneath.The paint mode determines how objects are drawn in a window. It is possible to have new objects XORed on to the window by using setXORMode().
XORColor:-color that will be XORed to the window when an object is drawn.
The advantage of XORMode is that the new object is always guaranteed to be visible no matter what color the object is drawn over.
To return the overwrite mode,call setPaintMode().
Syntax
void setPaintMode()
EXAMPLE:
/*<applet code="XOR" width=200 height=100> </applet>*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class XOR extends Applet
{
int x=100,y=50;
public void paint(Graphics g)
{
g.setXORMode(Color.green);
g.drawLine(chsx-50,chsy,chsx+10,chsy);
g.setPaintMode();
}
}
OUTPUT:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class XOR extends Applet
{
int x=100,y=50;
public void paint(Graphics g)
{
g.setXORMode(Color.green);
g.drawLine(chsx-50,chsy,chsx+10,chsy);
g.setPaintMode();
}
}
OUTPUT:
Simplest understandable explaination of the Paint mode-really appreciating thanks for ur efforts
ReplyDeleteTo do this, hold down the screen catch midway and then once the camera has centered; press it down right to take the shot.
ReplyDeleteBackground removal service