Skip to content

Commit

Permalink
Added method 'drawOverlayRect(int x, int y, int w, int h, int color, …
Browse files Browse the repository at this point in the history
…int thickness, boolean fill)'
  • Loading branch information
svenar-nl committed Sep 2, 2016
1 parent a7455cf commit 8469ae0
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions Java/src/me/winspeednl/libz/screen/Render.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,16 @@ public void setPixel(int x, int y, int color) {
pixels[x + y * width] = color;
}


public void setPixel(int pixel, int color) {
pixels[pixel] = color;
}

public void setOverlayPixel(int x, int y, int color) {
if ((x < 0 || x >= width || y < 0 || y >= height) || color == gc.getSpriteBGColor())
return;

getOverlayPixels()[x + y * width] = color;
}

public void setPixel(int pixel, int color) {
pixels[pixel] = color;
}

public void drawString(String text, int color, int offX, int offY){
drawString(text, color, offX, offY, Font.STANDARD);
Expand Down Expand Up @@ -196,6 +195,28 @@ public void drawRect(int x, int y, int w, int h, int color, int thickness, boole
}
}
}

public void drawOverlayRect(int x, int y, int w, int h, int color, int thickness, boolean fill) {
if (fill) {
for (int xi = 0; xi < w; xi++) {
for (int yi = 0; yi < h; yi++) {
setOverlayPixel(x + xi, y + yi, color);
}
}
} else {
for (int i = 0; i < thickness; i++) {
for (int xi = 0; xi < w; xi++) {
setOverlayPixel(x + xi, y + i, color);
setOverlayPixel(x + xi, y + h - i, color);
}

for (int yi = 0; yi < h; yi++) {
setOverlayPixel(x + i, y + yi, color);
setOverlayPixel(x + w - i, y + yi, color);
}
}
}
}

public void clear() {
for (int x = 0; x < width; x++) {
Expand Down

0 comments on commit 8469ae0

Please sign in to comment.