draw Tile - Java 2D Graphics

Java examples for 2D Graphics:Paint

Description

draw Tile

Demo Code


//package com.java2s;

import java.awt.*;

public class Main {
    public static void drawTile(Graphics2D g, int width, int height,
            int angle) {
        if (angle == 90)
            g.translate(height, 0);/*from  w  w  w  .  j  av  a  2 s .  co  m*/
        else if (angle == 180)
            g.translate(width, height);
        else if (angle == 270)
            g.translate(0, width);
        g.rotate(Math.toRadians(angle));

        // Draw white box
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, width, height);

        // Draw border around tile
        g.setColor(Color.BLACK);
        g.setStroke(new BasicStroke(3));
        g.drawRect(0, 0, width, height);
    }
}

Related Tutorials