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();

posted @ 2015-04-26 10:10  ma_fighting  阅读(184)  评论(0编辑  收藏  举报
历史天气查