Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. public BufferedImage getImage(RenderingHints rh) {
  2.         if (needReDraw) {
  3.             image = new BufferedImage(size, size, BufferedImage.TYPE_4BYTE_ABGR);
  4.             Graphics2D g = image.createGraphics();
  5.             if(rh!=null)g.setRenderingHints(rh);
  6.             g.rotate(angle);
  7.             for (int i = 0; i < color.length; i++) {
  8.                 g.setColor(new Color(color[i][0], color[i][1], color[i][2]));
  9.                 g.fillPolygon(pointX[i], pointY[i], pointX[i].length);
  10.             }
  11.             needReDraw = false;
  12.         }
  13.         return image;
  14.     }
  15.  
  16.     public void rotate(int angle){
  17.         this.angle = Math.toRadians(angle);
  18.         needReDraw = true;
  19.     }
  20.  
  21.     @Override
  22.     public void draw(Graphics2D g) {
  23.         g.drawImage(getImage(g.getRenderingHints()), 0, 0, null);
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement