Graphics samples2

为图形填充渐变色:

Graphics2D g2=(Graphics2D)g;

GradientPaint gra=new GradientPaint(20, 20, Color.BLUE, 100,80,Color.cyan,true);

g2.setPaint(gra);

g2.fillRect(50, 50, 150, 150);

平移坐标轴:

g2.translate(10,100);

创建椭圆对象:

Ellipse2D.Float ellipse=new Ellipse2D.Float(-80,5,160,10);

图形的加减运算:

Ellipse2D.Float ellipse=new Ellipse2D.Float(20,20,160,160);
Ellipse2D.Float ellip=new Ellipse2D.Float(90,20,160,160);
Area area=new Area(ellipse);
Area are=new Area(ellip);
area.subtract(are);
g2.fill(area);

加运算是add();

交运算是intersect();

yihuoyunsuanshi:exclusiveOr();

原文地址:https://www.cnblogs.com/mafeng/p/4457365.html