In this section, we are going to implements of exclusive OR in Graphics. Exclusive OR is a Boolean operator also known as XOR shows here the uncommon part between the two areas.
Show the Exclusive OR between the Area of two Shapes
This section illustrates you how to show the exclusive OR in Graphics.
In this section, we are going to implements of exclusive OR in Graphics. Exclusive OR is a Boolean operator also known as XOR shows here the uncommon part between the two areas. In the given example, the classes Rectangle2D and Ellipse2D are provided by the package java.awt.geom.*. These classes provides the shapes rectangle and oval respectively. Set the frame of rectangle with rect.setFrame(150, 150, 150, 100) and size of oval with oval.setFrame(100, 100, 150, 100).
Following code shows the ExclusiveOR between the two shapes:
area1.exclusiveOr(area2); |
On removing the common part, the remaining part shows the ExclusiveOR for specified shapes.
Here is the code of XORAreaExample.javaThe
mport java.awt.*;
|
Output will be displayed as: