Code:
public class DrawingArea extends NodeSub {
public static void initDrawingArea(int drawingAreaHeight, int drawingAreaWidth, int ai[]) {//method331
pixels = ai;
width = drawingAreaWidth;
height = drawingAreaHeight;
setDrawingArea(drawingAreaHeight, 0, drawingAreaWidth, 0);
}
public static void defaultDrawingAreaSize() {//method332
startX = 0;
topY = 0;
endX = width;
bottomY = height;
lastColumnX = endX - 1;
centerX = endX / 2;
}
public static void setDrawingArea(int drawingAreaBottom, int drawingAreaLeft, int drawingAreaRight, int drawingAreaTop) {//method333
if(drawingAreaLeft < 0)
drawingAreaLeft = 0;
if(drawingAreaTop < 0)
drawingAreaTop = 0;
if(drawingAreaRight > width)
drawingAreaRight = width;
if(drawingAreaBottom > height)
drawingAreaBottom = height;
startX = drawingAreaLeft;
topY = drawingAreaTop;
endX = drawingAreaRight;
bottomY = drawingAreaBottom;
lastColumnX = endX - 1;
centerX = endX / 2;
centerY = bottomY / 2;
}
public static void setAllPixelsToZero() {//method334
int totalPixels = width * height;
for(int j = 0; j < totalPixels; j++)
pixels[j] = 0;
}
public static void drawPixelsWithOpacity(int color, int yPos, int pixelWidth, int pixelHeight, int opacityLevel, int xPos) {//method335
if(xPos < startX) {
pixelWidth -= startX - xPos;
xPos = startX;
}
if(yPos < topY) {
pixelHeight -= topY - yPos;
yPos = topY;
}
if(xPos + pixelWidth > endX)
pixelWidth = endX - xPos;
if(yPos + pixelHeight > bottomY)
pixelHeight = bottomY - yPos;
int l1 = 256 - opacityLevel;
int i2 = (color >> 16 & 0xff) * opacityLevel;
int j2 = (color >> 8 & 0xff) * opacityLevel;
int k2 = (color & 0xff) * opacityLevel;
int k3 = width - pixelWidth;
int l3 = xPos + yPos * width;
for(int i4 = 0; i4 < pixelHeight; i4++) {
for(int j4 = -pixelWidth; j4 < 0; j4++) {
int l2 = (pixels[l3] >> 16 & 0xff) * l1;
int i3 = (pixels[l3] >> 8 & 0xff) * l1;
int j3 = (pixels[l3] & 0xff) * l1;
int k4 = ((i2 + l2 >> 8) << 16) + ((j2 + i3 >> 8) << 8) + (k2 + j3 >> 8);
pixels[l3++] = k4;
}
l3 += k3;
}
}
public static void drawPixels(int pixelHeight, int yPos, int xPos, int color, int pixelWidth) {//method336
if(xPos < startX) {
pixelWidth -= startX - xPos;
xPos = startX;
}
if(yPos < topY) {
pixelHeight -= topY - yPos;
yPos = topY;
}
if(xPos + pixelWidth > endX)
pixelWidth = endX - xPos;
if(yPos + pixelHeight > bottomY)
pixelHeight = bottomY - yPos;
int k1 = width - pixelWidth;
int l1 = xPos + yPos * width;
for(int i2 = -pixelHeight; i2 < 0; i2++) {
for(int j2 = -pixelWidth; j2 < 0; j2++)
pixels[l1++] = color;
l1 += k1;
}
}
public static void drawUnfilledPixels(int xPos, int pixelWidth, int pixelHeight, int color, int yPos) {//method337
drawHorizontalLine(yPos, color, pixelWidth, xPos);
drawHorizontalLine((yPos + pixelHeight) - 1, color, pixelWidth, xPos);
drawVerticalLine(yPos, color, pixelHeight, xPos);
drawVerticalLine(yPos, color, pixelHeight, (xPos + pixelWidth) - 1);
}
public static void drawUnfilledPixelsWithOpacity(int yPos, int pixelHeight, int opacityLevel, int color, int pixelWidth, int xPos) {//method338
drawHorizontalLineWithOpacity(color, pixelWidth, yPos, opacityLevel, xPos);
drawHorizontalLineWithOpacity(color, pixelWidth, (yPos + pixelHeight) - 1, opacityLevel, xPos);
if(pixelHeight >= 3) {
drawVerticalLineWithOpacity(color, xPos, opacityLevel, yPos + 1, pixelHeight - 2);
drawVerticalLineWithOpacity(color, (xPos + pixelWidth) - 1, opacityLevel, yPos + 1, pixelHeight - 2);
}
}
public static void drawHorizontalLine(int yPos, int lineColor, int lineWidth, int xPos) {//method339
if(yPos < topY || yPos >= bottomY)
return;
if(xPos < startX) {
lineWidth -= startX - xPos;
xPos = startX;
}
if(xPos + lineWidth > endX)
lineWidth = endX - xPos;
int i1 = xPos + yPos * width;
for(int j1 = 0; j1 < lineWidth; j1++)
pixels[i1 + j1] = lineColor;
}
public static void drawHorizontalLineWithOpacity(int lineColor, int lineWidth, int yPos, int opacityLevel, int xPos) {//method340
if(yPos < topY || yPos >= bottomY)
return;
if(xPos < startX) {
lineWidth -= startX - xPos;
xPos = startX;
}
if(xPos + lineWidth > endX)
lineWidth = endX - xPos;
int j1 = 256 - opacityLevel;
int k1 = (lineColor >> 16 & 0xff) * opacityLevel;
int l1 = (lineColor >> 8 & 0xff) * opacityLevel;
int i2 = (lineColor & 0xff) * opacityLevel;
int i3 = xPos + yPos * width;
for(int j3 = 0; j3 < lineWidth; j3++) {
int j2 = (pixels[i3] >> 16 & 0xff) * j1;
int k2 = (pixels[i3] >> 8 & 0xff) * j1;
int l2 = (pixels[i3] & 0xff) * j1;
int k3 = ((k1 + j2 >> 8) << 16) + ((l1 + k2 >> 8) << 8) + (i2 + l2 >> 8);
pixels[i3++] = k3;
}
}
public static void drawVerticalLine(int yPos, int lineColor, int lineHeight, int xPos) {//method341
if(xPos < startX || xPos >= endX)
return;
if(yPos < topY) {
lineHeight -= topY - yPos;
yPos = topY;
}
if(yPos + lineHeight > bottomY)
lineHeight = bottomY - yPos;
int j1 = xPos + yPos * width;
for(int k1 = 0; k1 < lineHeight; k1++)
pixels[j1 + k1 * width] = lineColor;
}
private static void drawVerticalLineWithOpacity(int color, int xPos, int opacityLevel, int yPos, int lineHeight) {//method342
if(xPos < startX || xPos >= endX)
return;
if(yPos < topY) {
lineHeight -= topY - yPos;
yPos = topY;
}
if(yPos + lineHeight > bottomY)
lineHeight = bottomY - yPos;
int j1 = 256 - opacityLevel;
int k1 = (color >> 16 & 0xff) * opacityLevel;
int l1 = (color >> 8 & 0xff) * opacityLevel;
int i2 = (color & 0xff) * opacityLevel;
int i3 = xPos + yPos * width;
for(int j3 = 0; j3 < lineHeight; j3++) {
int j2 = (pixels[i3] >> 16 & 0xff) * j1;
int k2 = (pixels[i3] >> 8 & 0xff) * j1;
int l2 = (pixels[i3] & 0xff) * j1;
int k3 = ((k1 + j2 >> 8) << 16) + ((l1 + k2 >> 8) << 8) + (i2 + l2 >> 8);
pixels[i3] = k3;
i3 += width;
}
}
DrawingArea() {
}
public static int pixels[];
public static int width;
public static int height;
public static int topY;
public static int bottomY;
public static int startX;
public static int endX;
public static int lastColumnX;
public static int centerX;
public static int centerY;
}