Thread: 2-d graphics
View Single Post
Old May 12th, 2006, 6:56 PM   #7
curiosity-killed-the-cat
Newbie
 
Join Date: May 2006
Location: England
Posts: 2
Rep Power: 0 curiosity-killed-the-cat is on a distinguished road
Quote:
Originally Posted by titaniumdecoy
What is the difference between Graphics and Graphics2D? They both appear to be for 2D drawing...
From memory, i recall one of the differences is the reuse of objects.

Graphics:
    // normal draw large rectangle
    g.drawRect(10,10,300,300);
    g.drawString("First Rectangle",10,10);

Graphics 2D:
    // define a Rectangle2D object and ask g2D to draw it
    Rectangle2D r = new Rectangle2D.Float( 200.0F,30.0F,50.0F,50.0F);
    g2D.draw(r);

    // redefine the position of the rectangle
    r.setRect(20.0F,150.0F,50.0F,50.0F);

Lisa
curiosity-killed-the-cat is offline   Reply With Quote