Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.image.*;
- public class FrameImage extends BufferedImage {
- private int w, h;
- private int mW, mH;
- private static final int COLOR_BLACK = -16777216;
- private int s = 500; //size
- private int t = 2; //thickness
- public FrameImage(int wd, int ht) {
- super(wd, ht, TYPE_INT_ARGB);
- w = wd;
- h = ht;
- this.reset();
- }
- public FrameImage(int wd, int ht, int size, int thicc, boolean[][][] m) {
- super(wd, ht, BufferedImage.TYPE_INT_ARGB);
- s = size;
- t = thicc;
- mW = (wd-t*(m.length+1))/m.length;
- mH = (ht-t*(m[0].length+1))/m[0].length;
- w = wd;
- h = ht;
- reset();
- showMaze(m);
- }
- public void reset() {
- for (int y = 0; y < h; y++) {
- for (int x = 0; x < w; x++) {
- this.setRGB(x, y, -1);
- }
- }
- }
- public void showMaze(boolean[][][] m) {
- for (int i = mW+t; i < w; i++) {
- for (int n = 0; n < t; n++) {
- this.setRGB(i, n, COLOR_BLACK);
- }
- }
- for (int i = 0; i < w-mW-t; i++) {
- for (int n = 0; n < t; n++) {
- this.setRGB(i, h-1-n, COLOR_BLACK);
- }
- }
- for (int i = 0; i < h; i++) {
- for (int n = 0; n < t; n++) {
- this.setRGB(n, i, COLOR_BLACK);
- this.setRGB(w-1-n, i, COLOR_BLACK);
- }
- }
- for (int y = 0; y < m[0].length; y++) {
- for (int x = 0; x < m.length; x++) {
- if (m[x][y][1] && x < m.length-1) {
- for (int i = (mH+t)*y; i < (mH+t)*(y+1)+t; i++) {
- for (int n = 0; n < t; n++) {
- this.setRGB((mW+t)*(x+1)+n, i, COLOR_BLACK);
- }
- }
- }
- if (m[x][y][2] && y < m[0].length-1) {
- for (int i = (mW+t)*x; i < (mW+t)*(x+1)+t; i++) {
- for (int n = 0; n < t; n++) {
- this.setRGB(i, (mH+t)*(y+1)+n, COLOR_BLACK);
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement