Skip to content

Instantly share code, notes, and snippets.

@hikilaka
Created January 31, 2016 05:29
Show Gist options
  • Save hikilaka/156fb30ee8ef0ba32a00 to your computer and use it in GitHub Desktop.
Save hikilaka/156fb30ee8ef0ba32a00 to your computer and use it in GitHub Desktop.
public void method212(int i, int j, int k, int l, int i1) {
int j1 = 256 - i1;
int k1 = (l >> 16 & 0xff) * i1;
int l1 = (l >> 8 & 0xff) * i1;
int i2 = (l & 0xff) * i1;
int i3 = j - k;
if (i3 < 0)
i3 = 0;
int j3 = j + k;
if (j3 >= menuDefaultHeight)
j3 = menuDefaultHeight - 1;
byte byte0 = 1;
if (f1Toggle) {
byte0 = 2;
if ((i3 & 1) != 0)
i3++;
}
for (int k3 = i3; k3 <= j3; k3 += byte0) {
int l3 = k3 - j;
int i4 = (int) Math.sqrt(k * k - l3 * l3);
int j4 = i - i4;
if (j4 < 0)
j4 = 0;
int k4 = i + i4;
if (k4 >= menuDefaultWidth)
k4 = menuDefaultWidth - 1;
int l4 = j4 + k3 * menuDefaultWidth;
for (int i5 = j4; i5 <= k4; i5++) {
int j2 = (imagePixelArray[l4] >> 16 & 0xff) * j1;
int k2 = (imagePixelArray[l4] >> 8 & 0xff) * j1;
int l2 = (imagePixelArray[l4] & 0xff) * j1;
int j5 = ((k1 + j2 >> 8) << 16) + ((l1 + k2 >> 8) << 8) + (i2 + l2 >> 8);
imagePixelArray[l4++] = j5;
}
}
}
/**
* Renders a transparent circle
*
* @param x The x coordinate
* @param y The y coordinate
* @param rad The radius of the circle
* @param col The color of the circle
* @param trans The transparency of the circle (ranging from 0-256)
*/
public void drawcircle(int x, int y, int rad, int col, int trans) {
int opacity = 256 - trans;
int r = (col >> 16 & 0xff) * trans;
int g = (col >> 8 & 0xff) * trans;
int b = (col & 0xff) * trans;
int miny = y - rad;
if (miny < 0)
miny = 0;
int maxy = y + rad;
if (maxy >= height)
maxy = height - 1;
byte skip = 1;
if (interlace) {
skip = 2;
if ((miny & 1) != 0)
miny++;
}
for(int yy = miny; yy <= maxy; yy += skip) {
int idx = yy - y;
int xrad = (int) Math.sqrt(rad * rad - idx * idx);
int minx = x - xrad;
if (minx < 0)
minx = 0;
int maxx = x + xrad;
if (maxx >= width)
maxx = width - 1;
int ptr = minx + yy * width;
for (int xx = minx; xx <= maxx; xx++) {
int cr = (pixels[ptr] >> 16 & 0xff) * opacity;
int cg = (pixels[ptr] >> 8 & 0xff) * opacity;
int cb = (pixels[ptr] & 0xff) * opacity;
int newcol = ((r + cr >> 8) << 16) + ((g + cg >> 8) << 8) + (b + cb >> 8);
pixels[ptr++] = newcol;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment