为图形填充渐变色:
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();
时间: 2024-12-25 05:40:48