A RuneTek3 client (377) that is deobfuscated, converted to Kotlin, and includes QoL improvements.
0

Configure Feed

Select the types of activity you want to include in your feed.

hybrid text rendering engine

+1395 -532
+19 -1
README.md
··· 1 1 refactored-client 2 2 ================= 3 3 4 - Refactoring the 377 deob. 4 + Refactoring the 377 deob. And extending it without adding rice. 5 + 6 + 7 + ----- 8 + New Features: 9 + * Mouse wheel zoom, scroll, and move view 10 + * Sound engine thanks to galkon (will be replaced with proper 400+) 11 + * 508+ and legacy text rendering engine: supports 12 + * all the old @red@ @str@ etc 13 + * all the new : (credits to a 508 deob and stewie for his half assed work) 14 + * <col=######></col> Custom colors 15 + <shad=######></shad> - Custom shadow color 16 + <shad></shad> - Default shadow color 17 + <trans=TRANS_AMOUNT></trans> 18 + <u=######></u> Custom underlining color 19 + <u></u> Default underlining 20 + <str=######></str> Custom Strikethrough color 21 + <str></str> Default strikethorough 22 + <img=#> whatever image you'd like
+8 -4
src/com/jagex/runescape/Game.java
··· 343 343 private static int anInt1139; 344 344 private int anInt1140 = -110; 345 345 private long aLong1141; 346 - private IndexedImage moderatorIcon[] = new IndexedImage[2]; 346 + private ImageRGB moderatorIcon[] = new ImageRGB[2]; 347 347 private byte aByte1143 = -80; 348 348 private boolean characterEditChangeGenger = true; 349 349 private int quakeTimes[] = new int[5]; ··· 5176 5176 aClass50_Sub1_Sub1_Sub3_987.flipVertical(); 5177 5177 5178 5178 for (int i = 0; i < 2; i++) 5179 - moderatorIcon[i] = new IndexedImage(archiveMedia, "mod_icons", i); 5179 + moderatorIcon[i] = new ImageRGB(archiveMedia, "mod_icons", i); 5180 5180 5181 5181 ImageRGB image = new ImageRGB(archiveMedia, "backleft1", 0); 5182 5182 aClass18_906 = new ProducingGraphicsBuffer(image.width, image.height, getParentComponent()); ··· 5256 5256 drawLoadingText(95, "Unpacking interfaces"); 5257 5257 5258 5258 TypeFace[] typefaces = {fontSmall, fontNormal, fontBold, fontFancy}; 5259 + 5260 + for(TypeFace typeFace: typefaces){ 5261 + typeFace.setNameIcons(moderatorIcon, (int[])null); 5262 + } 5259 5263 5260 5264 Widget.load(archiveInterface, typefaces, archiveMedia); 5261 5265 drawLoadingText(100, "Preparing game engine"); ··· 9829 9833 && method148(13292, ((Player) obj).playerName))) { 9830 9834 method136(((Actor) (obj)), false, ((Actor) (obj)).modelHeight); 9831 9835 if (anInt932 > -1 && anInt939 < anInt940) { 9832 - anIntArray944[anInt939] = fontBold.getStringWidth(((Actor) (obj)).forcedChat 9836 + anIntArray944[anInt939] = fontBold.getDisplayedWidth(((Actor) (obj)).forcedChat 9833 9837 ) / 2; 9834 9838 anIntArray943[anInt939] = fontBold.characterDefaultHeight; 9835 9839 anIntArray941[anInt939] = anInt932; ··· 9960 9964 ); 9961 9965 } 9962 9966 if (anIntArray946[j] == 4) { 9963 - int k3 = fontBold.getStringWidth(s); 9967 + int k3 = fontBold.getDisplayedWidth(s); 9964 9968 int i4 = ((150 - anIntArray947[j]) * (k3 + 100)) / 150; 9965 9969 Rasterizer.setCoordinates(0, anInt932 - 50, 334, anInt932 + 50); 9966 9970 fontBold.drawString(s, (anInt932 + 50) - i4, anInt933 + 1, 0);
+899 -343
src/com/jagex/runescape/cache/media/TypeFace.java
··· 4 4 import com.jagex.runescape.media.Rasterizer; 5 5 import com.jagex.runescape.net.Buffer; 6 6 7 + import java.awt.*; 7 8 import java.util.Random; 8 9 9 10 public class TypeFace extends Rasterizer { 10 11 11 12 12 - public byte characterPixels[][] = new byte[256][]; 13 - public int characterWidths[] = new int[256]; 14 - public int characterHeights[] = new int[256]; 15 - public int characterXOffsets[] = new int[256]; 16 - public int characterYOffsets[] = new int[256]; 17 - public int characterScreenWidths[] = new int[256]; 18 - public int characterDefaultHeight; 19 - public Random random = new Random(); 20 - public boolean strikethrough = false; 13 + public byte[][] characterPixels = new byte[256][]; 14 + public int[] characterWidths = new int[256]; 15 + public int[] characterHeights = new int[256]; 16 + public int[] characterXOffsets = new int[256]; 17 + public int[] characterYOffsets = new int[256]; 18 + public int[] characterScreenWidths = new int[256]; 19 + public int characterDefaultHeight; 20 + public Random random = new Random(); 21 21 22 - public TypeFace(boolean large, Archive archive, String archiveName) { 23 - Buffer dataBuffer = new Buffer(archive.getFile(archiveName + ".dat")); 24 - Buffer indexBuffer = new Buffer(archive.getFile("index.dat")); 25 - indexBuffer.currentPosition = dataBuffer.getUnsignedLEShort() + 4; 26 - int k = indexBuffer.getUnsignedByte(); 27 - if (k > 0) 28 - indexBuffer.currentPosition += 3 * (k - 1); 29 - for (int character = 0; character < 256; character++) { 30 - characterXOffsets[character] = indexBuffer.getUnsignedByte(); 31 - characterYOffsets[character] = indexBuffer.getUnsignedByte(); 32 - int characterWidth = characterWidths[character] = indexBuffer.getUnsignedLEShort(); 33 - int characterHeight = characterHeights[character] = indexBuffer.getUnsignedLEShort(); 34 - int characterType = indexBuffer.getUnsignedByte(); 35 - int characterSize = characterWidth * characterHeight; 36 - characterPixels[character] = new byte[characterSize]; 37 - if (characterType == 0) { 38 - for (int pixel = 0; pixel < characterSize; pixel++) 39 - characterPixels[character][pixel] = dataBuffer.getSignedByte(); 22 + private static int strikethroughColor = -1; 23 + private static int underlineColor = -1; 24 + private static int anInt3748 = 0; 25 + private static int defaultTextColor = 0; 26 + private static int opacity = 256; 27 + private static int defaultOpacity = 256; 28 + private static int defaultShadowColor = -1; 29 + private static int shadowColor = -1; 30 + private static int textColor = 0xff00ff; 31 + private static int whiteSpace = 0; 32 + private ImageRGB[] moderatorIcon = null; 33 + private int[] imageWidths; 34 + private static String greaterThan = "gt"; 35 + private static String lessThan = "lt"; 36 + private static String euroSymbol = "euro"; 37 + private static String startShadow = "shad="; 38 + private static String softHyphen = "shy"; 39 + private static String startTrans = "trans="; 40 + private static String startUnderline = "u="; 41 + private static String startStrikethrough = "str="; 42 + private static String endColor = "/col"; 43 + private static String endShadow = "/shad"; 44 + private static String endTrans = "/trans"; 45 + private static String endUnderline = "/u"; 46 + private static String endStrikeThrough = "/str"; 47 + private static String startDefaultUnderline = "u"; 48 + private static String startDefaultStrikeThrough = "str"; 49 + private static String startDefaultShadow = "shad"; 50 + private static String startColor = "col="; 51 + private static String multiplicationSymbol = "times"; 52 + private static String nonBreakingSpace = "nbsp"; 53 + private static String image = "img="; 54 + private static String copyright = "copy"; 55 + private static String lineBreak = "br"; 56 + private static String registeredTrademark = "reg"; 40 57 41 - } else if (characterType == 1) { 42 - for (int characterX = 0; characterX < characterWidth; characterX++) { 43 - for (int characterY = 0; characterY < characterHeight; characterY++) 44 - characterPixels[character][characterX + characterY * characterWidth] = dataBuffer.getSignedByte(); 58 + public TypeFace(boolean monospace, Archive archive, String archiveName) { 59 + Buffer dataBuffer = new Buffer(archive.getFile(archiveName + ".dat")); 60 + Buffer indexBuffer = new Buffer(archive.getFile("index.dat")); 61 + indexBuffer.currentPosition = dataBuffer.getUnsignedLEShort() + 4; 62 + int k = indexBuffer.getUnsignedByte(); 63 + if (k > 0) 64 + indexBuffer.currentPosition += 3 * (k - 1); 65 + for (int character = 0; character < 256; character++) { 66 + characterXOffsets[character] = indexBuffer.getUnsignedByte(); 67 + characterYOffsets[character] = indexBuffer.getUnsignedByte(); 68 + int characterWidth = characterWidths[character] = indexBuffer.getUnsignedLEShort(); 69 + int characterHeight = characterHeights[character] = indexBuffer.getUnsignedLEShort(); 70 + int characterType = indexBuffer.getUnsignedByte(); 71 + int characterSize = characterWidth * characterHeight; 72 + characterPixels[character] = new byte[characterSize]; 73 + if (characterType == 0) { 74 + for (int pixel = 0; pixel < characterSize; pixel++) 75 + characterPixels[character][pixel] = dataBuffer.getSignedByte(); 45 76 46 - } 77 + } else if (characterType == 1) { 78 + for (int characterX = 0; characterX < characterWidth; characterX++) { 79 + for (int characterY = 0; characterY < characterHeight; characterY++) 80 + characterPixels[character][characterX + characterY * characterWidth] = dataBuffer.getSignedByte(); 47 81 48 - } 49 - if (characterHeight > characterDefaultHeight && character < 128) 50 - characterDefaultHeight = characterHeight; 51 - characterXOffsets[character] = 1; 52 - characterScreenWidths[character] = characterWidth + 2; 53 - int pixelCount = 0; 54 - for (int characterY = characterHeight / 7; characterY < characterHeight; characterY++) 55 - pixelCount += characterPixels[character][characterY * characterWidth]; 82 + } 56 83 57 - if (pixelCount <= characterHeight / 7) { 58 - characterScreenWidths[character]--; 59 - characterXOffsets[character] = 0; 60 - } 61 - pixelCount = 0; 62 - for (int characterY = characterHeight / 7; characterY < characterHeight; characterY++) 63 - pixelCount += characterPixels[character][(characterWidth - 1) + characterY * characterWidth]; 84 + } 85 + if (characterHeight > characterDefaultHeight && character < 128) 86 + characterDefaultHeight = characterHeight; 87 + characterXOffsets[character] = 1; 88 + characterScreenWidths[character] = characterWidth + 2; 89 + int pixelCount = 0; 90 + for (int characterY = characterHeight / 7; characterY < characterHeight; characterY++) 91 + pixelCount += characterPixels[character][characterY * characterWidth]; 64 92 65 - if (pixelCount <= characterHeight / 7) 66 - characterScreenWidths[character]--; 67 - } 93 + if (pixelCount <= characterHeight / 7) { 94 + characterScreenWidths[character]--; 95 + characterXOffsets[character] = 0; 96 + } 97 + pixelCount = 0; 98 + for (int characterY = characterHeight / 7; characterY < characterHeight; characterY++) 99 + pixelCount += characterPixels[character][(characterWidth - 1) + characterY * characterWidth]; 68 100 69 - if (large) { 70 - characterScreenWidths[32] = characterScreenWidths[73]; 71 - } else { 72 - characterScreenWidths[32] = characterScreenWidths[105]; 73 - } 74 - } 101 + if (pixelCount <= characterHeight / 7) 102 + characterScreenWidths[character]--; 103 + } 75 104 76 - public void drawStringRight(String string, int x, int y, int colour) { 77 - drawString(string, x - getStringWidth(string), y, colour); 78 - } 105 + if (monospace) { 106 + characterScreenWidths[32] = characterScreenWidths[73]; 107 + } else { 108 + characterScreenWidths[32] = characterScreenWidths[105]; 109 + } 110 + } 79 111 80 - public void drawStringLeft(String string, int x, int y, int colour) { 81 - drawString(string, x - getStringWidth(string) / 2, y, colour); 82 - } 112 + public void drawStringRight(String string, int x, int y, int colour) { 113 + drawString(string, x - getDisplayedWidth(string), y, colour); 114 + } 83 115 84 - public void drawStringCenter(String string, int x, int y, int colour, boolean shadowed) { 85 - drawShadowedString(string, x - getStringEffectWidth(string) / 2, y, shadowed, colour); 86 - } 116 + public void drawStringLeft(String string, int x, int y, int colour) { 117 + drawString(string, x - getDisplayedWidth(string) / 2, y, colour); 118 + } 87 119 88 - public int getStringEffectWidth(String string) { 89 - if (string == null) 90 - return 0; 91 - int width = 0; 92 - for (int character = 0; character < string.length(); character++) 93 - if (string.charAt(character) == '@' && character + 4 < string.length() && string.charAt(character + 4) == '@') 94 - character += 4; 95 - else 96 - width += characterScreenWidths[string.charAt(character)]; 120 + public void drawStringCenter(String string, int x, int y, int colour, boolean shadowed) { 121 + drawShadowedString(string, x - getStringEffectWidth(string) / 2, y, shadowed, colour); 122 + } 97 123 98 - return width; 99 - } 124 + public int getStringEffectWidth(String string) { 125 + if (string == null) 126 + return 0; 127 + int width = 0; 128 + for (int character = 0; character < string.length(); character++) 129 + if (string.charAt(character) == '@' && character + 4 < string.length() && string.charAt(character + 4) == '@') 130 + character += 4; 131 + else 132 + width += characterScreenWidths[string.charAt(character)]; 100 133 101 - public int getStringWidth(String string) { 102 - if (string == null) 103 - return 0; 104 - int width = 0; 105 - for (int character = 0; character < string.length(); character++) 106 - width += characterScreenWidths[string.charAt(character)]; 134 + return width; 135 + } 107 136 108 - return width; 109 - } 137 + public final int getDisplayedWidth(String string) { 138 + if (string == null) { 139 + return 0; 140 + } 141 + int index = -1; 142 + int width = 0; 143 + int length = string.length(); 110 144 111 - public void drawString(String string, int x, int y, int colour) { 112 - if (string == null) 113 - return; 114 - y -= characterDefaultHeight; 115 - for (int index = 0; index < string.length(); index++) { 116 - char character = string.charAt(index); 117 - if (character != ' ') 118 - drawCharacter(characterPixels[character], x + characterXOffsets[character], y + characterYOffsets[character], characterWidths[character], 119 - characterHeights[character], colour); 120 - x += characterScreenWidths[character]; 121 - } 145 + for (int idx = 0; idx < length; ++idx) { 146 + int character = string.charAt(idx); 147 + if (character == 60) { 122 148 123 - } 149 + index = idx; 150 + } else { 151 + if (character == 62 && index != -1) { 152 + String effect = string.substring(index + 1, idx); 153 + index = -1; 154 + if (effect.equals(lessThan)) { 155 + character = 60; 156 + } else if (effect.equals(greaterThan)) { 157 + character = 62; 158 + } else if (effect.equals(nonBreakingSpace)) { 159 + character = 160; 160 + } else if (effect.equals(softHyphen)) { 161 + character = 173; 162 + } else if (effect.equals(multiplicationSymbol)) { 163 + character = 215; 164 + } else if (effect.equals(euroSymbol)) { 165 + character = 128; 166 + } else if (effect.equals(copyright)) { 167 + character = 169; 168 + } else { 169 + if (!effect.equals(registeredTrademark)) { 170 + if (effect.startsWith(image, 0)) { 171 + try { 172 + int icon = Integer.parseInt(effect.substring(4)); 173 + width += moderatorIcon[icon].maxWidth; 174 + } catch (Exception var10) { 124 175 125 - public void drawCenteredStringWaveY(String string, int x, int y, int wave, int colour) { 126 - if (string == null) 127 - return; 128 - x -= getStringWidth(string) / 2; 129 - y -= characterDefaultHeight; 130 - for (int index = 0; index < string.length(); index++) { 131 - char character = string.charAt(index); 132 - if (character != ' ') 133 - drawCharacter(characterPixels[character], x + characterXOffsets[character], y + characterYOffsets[character] 134 - + (int) (Math.sin(index / 2D + wave / 5D) * 5D), characterWidths[character], characterHeights[character], colour); 135 - x += characterScreenWidths[character]; 136 - } 176 + } 177 + } 178 + continue; 179 + } 137 180 138 - } 181 + character = 174; 182 + } 183 + } 184 + if (character == '@' && character + 4 < string.length() && string.charAt(character + 4) == '@') { 185 + int stringColour = getColour(string.substring(character + 1, character + 4)); 186 + if (stringColour != -1) 187 + textColor = stringColour; 188 + idx += 4; 189 + continue; 190 + } 139 191 140 - public void drawCeneteredStringWaveXY(String string, int x, int y, int wave, int colour) { 141 - if (string == null) 142 - return; 143 - x -= getStringWidth(string) / 2; 144 - y -= characterDefaultHeight; 145 - for (int index = 0; index < string.length(); index++) { 146 - char character = string.charAt(index); 147 - if (character != ' ') 148 - drawCharacter(characterPixels[character], x + characterXOffsets[character] + (int) (Math.sin(index / 5D + wave / 5D) * 5D), y 149 - + characterYOffsets[character] + (int) (Math.sin(index / 3D + wave / 5D) * 5D), characterWidths[character], 150 - characterHeights[character], colour); 151 - x += characterScreenWidths[character]; 152 - } 192 + if (index == -1) { 193 + width += characterScreenWidths[character]; 194 + } 195 + } 196 + } 153 197 154 - } 198 + return width; 155 199 156 - public void drawCenteredStringWaveXYMove(String string, int x, int y, int waveAmount, int waveSpeed, int colour) { 157 - if (string == null) 158 - return; 159 - double speed = 7D - waveSpeed / 8D; 160 - if (speed < 0.0D) 161 - speed = 0.0D; 162 - x -= getStringWidth(string) / 2; 163 - y -= characterDefaultHeight; 164 - for (int index = 0; index < string.length(); index++) { 165 - char character = string.charAt(index); 166 - if (character != ' ') 167 - drawCharacter(characterPixels[character], x + characterXOffsets[character], y + characterYOffsets[character] 168 - + (int) (Math.sin(index / 1.5D + waveAmount) * speed), characterWidths[character], characterHeights[character], colour); 169 - x += characterScreenWidths[character]; 170 - } 200 + } 171 201 172 - } 202 + public void drawString(String string, int x, int y, int colour) { 203 + if (this.moderatorIcon != null) { 204 + this.drawString(string, x, y, colour, -1); 173 205 174 - public void drawShadowedString(String string, int x, int y, boolean shadow, int colour) { 175 - strikethrough = false; 176 - int originalX = x; 177 - if (string == null) 178 - return; 179 - y -= characterDefaultHeight; 180 - for (int character = 0; character < string.length(); character++) 181 - if (string.charAt(character) == '@' && character + 4 < string.length() && string.charAt(character + 4) == '@') { 182 - int stringColour = getColour(string.substring(character + 1, character + 4)); 183 - if (stringColour != -1) 184 - colour = stringColour; 185 - character += 4; 186 - } else { 187 - char c = string.charAt(character); 188 - if (c != ' ') { 189 - if (shadow) 190 - drawCharacter(characterPixels[c], x + characterXOffsets[c] + 1, y + characterYOffsets[c] + 1, 191 - characterWidths[c], characterHeights[c], 0); 192 - drawCharacter(characterPixels[c], x + characterXOffsets[c], y + characterYOffsets[c], characterWidths[c], 193 - characterHeights[c], colour); 194 - } 195 - x += characterScreenWidths[c]; 196 - } 206 + } else { 207 + if (string == null) 208 + return; 209 + y -= characterDefaultHeight; 210 + for (int index = 0; index < string.length(); index++) { 211 + char character = string.charAt(index); 212 + if (character != ' ') 213 + drawCharacterLegacy(characterPixels[character], x + characterXOffsets[character], y + characterYOffsets[character], characterWidths[character], 214 + characterHeights[character], colour); 215 + x += characterScreenWidths[character]; 216 + } 217 + } 197 218 198 - if (strikethrough) 199 - Rasterizer.drawHorizontalLine(originalX, y + (int) (characterDefaultHeight * 0.69999999999999996D), x - originalX, 0x800000); 200 - } 201 219 202 - public void drawShadowedSeededAlphaString(String string, int x, int y, int colour, int seed) { 203 - if (string == null) 204 - return; 205 - random.setSeed(seed); 206 - int alpha = 192 + (random.nextInt() & 0x1f); 207 - y -= characterDefaultHeight; 208 - for (int index = 0; index < string.length(); index++) 209 - if (string.charAt(index) == '@' && index + 4 < string.length() && string.charAt(index + 4) == '@') { 210 - int stringColour = getColour(string.substring(index + 1, index + 4)); 211 - if (stringColour != -1) 212 - colour = stringColour; 213 - index += 4; 214 - } else { 215 - char c = string.charAt(index); 216 - if (c != ' ') { 220 + } 217 221 218 - drawAlphaCharacter(x + characterXOffsets[c] + 1, true, 0, characterPixels[c], 219 - y + characterYOffsets[c] + 1, characterHeights[c], characterWidths[c], 192); 220 - drawAlphaCharacter(x + characterXOffsets[c], true, colour, characterPixels[c], y + characterYOffsets[c], 221 - characterHeights[c], characterWidths[c], alpha); 222 - } 223 - x += characterScreenWidths[c]; 224 - if ((random.nextInt() & 3) == 0) 225 - x++; 226 - } 222 + public void drawCenteredStringWaveY(String string, int x, int y, int wave, int colour) { 223 + if (string == null) 224 + return; 225 + x -= getDisplayedWidth(string) / 2; 226 + y -= characterDefaultHeight; 227 + for (int index = 0; index < string.length(); index++) { 228 + char character = string.charAt(index); 229 + if (character != ' ') 230 + drawCharacterLegacy(characterPixels[character], x + characterXOffsets[character], y + characterYOffsets[character] 231 + + (int) (Math.sin(index / 2D + wave / 5D) * 5D), characterWidths[character], characterHeights[character], colour); 232 + x += characterScreenWidths[character]; 233 + } 227 234 228 - } 235 + } 229 236 230 - public int getColour(String code) { 231 - if (code.equals("red")) 232 - return 0xff0000; 233 - if (code.equals("gre")) 234 - return 65280; 235 - if (code.equals("blu")) 236 - return 255; 237 - if (code.equals("yel")) 238 - return 0xffff00; 239 - if (code.equals("cya")) 240 - return 65535; 241 - if (code.equals("mag")) 242 - return 0xff00ff; 243 - if (code.equals("whi")) 244 - return 0xffffff; 245 - if (code.equals("bla")) 246 - return 0; 247 - if (code.equals("lre")) 248 - return 0xff9040; 249 - if (code.equals("dre")) 250 - return 0x800000; 251 - if (code.equals("dbl")) 252 - return 128; 253 - if (code.equals("or1")) 254 - return 0xffb000; 255 - if (code.equals("or2")) 256 - return 0xff7000; 257 - if (code.equals("or3")) 258 - return 0xff3000; 259 - if (code.equals("gr1")) 260 - return 0xc0ff00; 261 - if (code.equals("gr2")) 262 - return 0x80ff00; 263 - if (code.equals("gr3")) 264 - return 0x40ff00; 265 - if (code.equals("str")) 266 - strikethrough = true; 267 - if (code.equals("end")) 268 - strikethrough = false; 269 - return -1; 270 - } 237 + public void drawCenteredString(String text, int x, int y, int color, int shadow) { 238 + if (text != null) { 239 + setEffects(color, shadow); 240 + drawBasicString(text, x - getDisplayedWidth(text) / 2, y); 241 + } 242 + } 271 243 272 - public void drawCharacter(byte pixels[], int x, int y, int width, int height, int colour) { 273 - int rasterizerPixel = x + y * Rasterizer.width; 274 - int remainingWidth = Rasterizer.width - width; 275 - int characterPixelOffset = 0; 276 - int characterPixel = 0; 277 - if (y < Rasterizer.topY) { 278 - int offsetY = Rasterizer.topY - y; 279 - height -= offsetY; 280 - y = Rasterizer.topY; 281 - characterPixel += offsetY * width; 282 - rasterizerPixel += offsetY * Rasterizer.width; 283 - } 284 - if (y + height >= Rasterizer.bottomY) 285 - height -= ((y + height) - Rasterizer.bottomY) + 1; 286 - if (x < Rasterizer.topX) { 287 - int offsetX = Rasterizer.topX - x; 288 - width -= offsetX; 289 - x = Rasterizer.topX; 290 - characterPixel += offsetX; 291 - rasterizerPixel += offsetX; 292 - characterPixelOffset += offsetX; 293 - remainingWidth += offsetX; 294 - } 295 - if (x + width >= Rasterizer.bottomX) { 296 - int endOffsetX = ((x + width) - Rasterizer.bottomX) + 1; 297 - width -= endOffsetX; 298 - characterPixelOffset += endOffsetX; 299 - remainingWidth += endOffsetX; 300 - } 301 - if (width > 0 && height > 0) { 302 - drawCharacterPixels(pixels, Rasterizer.pixels, characterPixel, rasterizerPixel, characterPixelOffset, remainingWidth, width, height, colour); 303 - } 304 - } 244 + public void drawCeneteredStringWaveXY(String string, int x, int y, int wave, int colour) { 245 + if (string == null) 246 + return; 247 + x -= getDisplayedWidth(string) / 2; 248 + y -= characterDefaultHeight; 249 + for (int index = 0; index < string.length(); index++) { 250 + char character = string.charAt(index); 251 + if (character != ' ') 252 + drawCharacterLegacy(characterPixels[character], x + characterXOffsets[character] + (int) (Math.sin(index / 5D + wave / 5D) * 5D), y 253 + + characterYOffsets[character] + (int) (Math.sin(index / 3D + wave / 5D) * 5D), characterWidths[character], 254 + characterHeights[character], colour); 255 + x += characterScreenWidths[character]; 256 + } 305 257 306 - public void drawCharacterPixels(byte[] characterPixels, int[] rasterizerPixels, int characterPixel, int rasterizerPixel, int characterPixelOffset, int rasterizerPixelOffset, int width, int height, int colour) { 307 - int negativeQuaterWidth = -(width >> 2); 308 - width = -(width & 3); 309 - for (int heightCounter = -height; heightCounter < 0; heightCounter++) { 310 - for (int widthCounter = negativeQuaterWidth; widthCounter < 0; widthCounter++) { 311 - if (characterPixels[characterPixel++] != 0) 312 - rasterizerPixels[rasterizerPixel++] = colour; 313 - else 314 - rasterizerPixel++; 315 - if (characterPixels[characterPixel++] != 0) 316 - rasterizerPixels[rasterizerPixel++] = colour; 317 - else 318 - rasterizerPixel++; 319 - if (characterPixels[characterPixel++] != 0) 320 - rasterizerPixels[rasterizerPixel++] = colour; 321 - else 322 - rasterizerPixel++; 323 - if (characterPixels[characterPixel++] != 0) 324 - rasterizerPixels[rasterizerPixel++] = colour; 325 - else 326 - rasterizerPixel++; 327 - } 258 + } 328 259 329 - for (int widthCounter = width; widthCounter < 0; widthCounter++) 330 - if (characterPixels[characterPixel++] != 0) 331 - rasterizerPixels[rasterizerPixel++] = colour; 332 - else 333 - rasterizerPixel++; 260 + public void drawCenteredStringWaveXYMove(String string, int x, int y, int waveAmount, int waveSpeed, int colour) { 261 + if (string == null) 262 + return; 263 + double speed = 7D - waveSpeed / 8D; 264 + if (speed < 0.0D) 265 + speed = 0.0D; 266 + x -= getDisplayedWidth(string) / 2; 267 + y -= characterDefaultHeight; 268 + for (int index = 0; index < string.length(); index++) { 269 + char character = string.charAt(index); 270 + if (character != ' ') 271 + drawCharacterLegacy(characterPixels[character], x + characterXOffsets[character], y + characterYOffsets[character] 272 + + (int) (Math.sin(index / 1.5D + waveAmount) * speed), characterWidths[character], characterHeights[character], colour); 273 + x += characterScreenWidths[character]; 274 + } 334 275 335 - rasterizerPixel += rasterizerPixelOffset; 336 - characterPixel += characterPixelOffset; 337 - } 276 + } 338 277 339 - } 278 + public void drawShadowedString(String string, int x, int y, boolean shadow, int colour) { 279 + if (this.moderatorIcon != null) { 280 + this.drawString(string, x, y, colour, 0); 281 + } else { 282 + strikethroughColor = -1; 283 + int originalX = x; 284 + if (string == null) 285 + return; 286 + y -= characterDefaultHeight; 287 + for (int character = 0; character < string.length(); character++) 288 + if (string.charAt(character) == '@' && character + 4 < string.length() && string.charAt(character + 4) == '@') { 289 + int stringColour = getColour(string.substring(character + 1, character + 4)); 290 + if (stringColour != -1) 291 + colour = stringColour; 292 + character += 4; 293 + } else { 294 + char c = string.charAt(character); 295 + if (c != ' ') { 296 + if (shadow) 297 + drawCharacterLegacy(characterPixels[c], x + characterXOffsets[c] + 1, y + characterYOffsets[c] + 1, 298 + characterWidths[c], characterHeights[c], 0); 299 + drawCharacterLegacy(characterPixels[c], x + characterXOffsets[c], y + characterYOffsets[c], characterWidths[c], 300 + characterHeights[c], colour); 301 + } 302 + x += characterScreenWidths[c]; 303 + } 340 304 341 - public void drawAlphaCharacter(int x, boolean flag, int j, byte abyte0[], int y, int height, int width, int j1) { 342 - int rasterizerPixel = x + y * Rasterizer.width; 343 - int rasterizerPixelOffset = Rasterizer.width - width; 344 - int characterPixelOffset = 0; 345 - int characterPixel = 0; 346 - if (y < Rasterizer.topY) { 347 - int yOffset = Rasterizer.topY - y; 348 - height -= yOffset; 349 - y = Rasterizer.topY; 350 - characterPixel += yOffset * width; 351 - rasterizerPixel += yOffset * Rasterizer.width; 352 - } 353 - if (y + height >= Rasterizer.bottomY) 354 - height -= ((y + height) - Rasterizer.bottomY) + 1; 355 - if (x < Rasterizer.topX) { 356 - int xOffset = Rasterizer.topX - x; 357 - width -= xOffset; 358 - x = Rasterizer.topX; 359 - characterPixel += xOffset; 360 - rasterizerPixel += xOffset; 361 - characterPixelOffset += xOffset; 362 - rasterizerPixelOffset += xOffset; 363 - } 364 - if (x + width >= Rasterizer.bottomX) { 365 - int widthoffset = ((x + width) - Rasterizer.bottomX) + 1; 366 - width -= widthoffset; 367 - characterPixelOffset += widthoffset; 368 - rasterizerPixelOffset += widthoffset; 369 - } 370 - if (width > 0 && height > 0) { 371 - drawCharacterPixelsAlpha(characterPixel, rasterizerPixelOffset, characterPixelOffset, rasterizerPixel, j1, Rasterizer.pixels, j, 2, height, width, abyte0); 372 - } 373 - } 305 + if (strikethroughColor != -1) 306 + Rasterizer.drawHorizontalLine(originalX, y + (int) (characterDefaultHeight * 0.69999999999999996D), x - originalX, strikethroughColor); 307 + } 308 + } 374 309 375 - public void drawCharacterPixelsAlpha(int characterPixel, int rasterizerPixelOffset, int characterPixelOffset, int rasterizerPixel, int alpha, int rasterizerPixels[], int colour, int k1, int height, int width, byte characterPixels[]) { 376 - colour = ((colour & 0xff00ff) * alpha & 0xff00ff00) + ((colour & 0xff00) * alpha & 0xff0000) >> 8; 377 - alpha = 256 - alpha; 378 - for (int heightCounter = -height; heightCounter < 0; heightCounter++) { 379 - for (int widthCounter = -width; widthCounter < 0; widthCounter++) 380 - if (characterPixels[characterPixel++] != 0) { 381 - int rasterizerPixelColor = rasterizerPixels[rasterizerPixel]; 382 - rasterizerPixels[rasterizerPixel++] = (((rasterizerPixelColor & 0xff00ff) * alpha & 0xff00ff00) + ((rasterizerPixelColor & 0xff00) * alpha & 0xff0000) >> 8) + colour; 383 - } else { 384 - rasterizerPixel++; 385 - } 310 + public void drawShadowedSeededAlphaString(String string, int x, int y, int colour, int seed) { 311 + if (string == null) 312 + return; 313 + random.setSeed(seed); 314 + int alpha = 192 + (random.nextInt() & 0x1f); 315 + y -= characterDefaultHeight; 316 + for (int index = 0; index < string.length(); index++) 317 + if (string.charAt(index) == '@' && index + 4 < string.length() && string.charAt(index + 4) == '@') { 318 + int stringColour = getColour(string.substring(index + 1, index + 4)); 319 + if (stringColour != -1) 320 + colour = stringColour; 321 + index += 4; 322 + } else { 323 + char c = string.charAt(index); 324 + if (c != ' ') { 386 325 387 - rasterizerPixel += rasterizerPixelOffset; 388 - characterPixel += characterPixelOffset; 389 - } 326 + drawAlphaCharacter(characterPixels[c], x + characterXOffsets[c] + 1, y + characterYOffsets[c] + 1, characterWidths[c], characterHeights[c], 0, 327 + 192); 328 + drawAlphaCharacter(characterPixels[c], x + characterXOffsets[c], y + characterYOffsets[c], characterWidths[c], characterHeights[c], colour, 329 + alpha); 330 + } 331 + x += characterScreenWidths[c]; 332 + if ((random.nextInt() & 3) == 0) 333 + x++; 334 + } 335 + 336 + } 337 + 338 + public int getColour(String code) { 339 + if (code.equals("red")) 340 + return 0xff0000; 341 + if (code.equals("gre")) 342 + return 65280; 343 + if (code.equals("blu")) 344 + return 255; 345 + if (code.equals("yel")) 346 + return 0xffff00; 347 + if (code.equals("cya")) 348 + return 65535; 349 + if (code.equals("mag")) 350 + return 0xff00ff; 351 + if (code.equals("whi")) 352 + return 0xffffff; 353 + if (code.equals("bla")) 354 + return 0; 355 + if (code.equals("lre")) 356 + return 0xff9040; 357 + if (code.equals("dre")) 358 + return 0x800000; 359 + if (code.equals("dbl")) 360 + return 128; 361 + if (code.equals("or1")) 362 + return 0xffb000; 363 + if (code.equals("or2")) 364 + return 0xff7000; 365 + if (code.equals("or3")) 366 + return 0xff3000; 367 + if (code.equals("gr1")) 368 + return 0xc0ff00; 369 + if (code.equals("gr2")) 370 + return 0x80ff00; 371 + if (code.equals("gr3")) 372 + return 0x40ff00; 373 + if (code.equals("str")) 374 + strikethroughColor = 0; 375 + if (code.equals("end")) 376 + strikethroughColor = -1; 377 + return -1; 378 + } 379 + 380 + 381 + public void drawCharacter(int character, int x, int y, int width, int height, 382 + int colour) { 383 + int rasterizerPixel = x + y * Rasterizer.width; 384 + int rasterizerPixelOffset = Rasterizer.width - width; 385 + int characterPixelOffset = 0; 386 + int characterPixel = 0; 387 + if (y < Rasterizer.topY) { 388 + int offsetY = Rasterizer.topY - y; 389 + height -= offsetY; 390 + y = Rasterizer.topY; 391 + characterPixel += offsetY * width; 392 + rasterizerPixel += offsetY * Rasterizer.width; 393 + } 394 + if (y + height > Rasterizer.bottomY) { 395 + height -= y + height - Rasterizer.bottomY; 396 + } 397 + if (x < Rasterizer.topX) { 398 + int offsetX = Rasterizer.topX - x; 399 + width -= offsetX; 400 + x = Rasterizer.topX; 401 + characterPixel += offsetX; 402 + rasterizerPixel += offsetX; 403 + characterPixelOffset += offsetX; 404 + rasterizerPixelOffset += offsetX; 405 + } 406 + if (x + width > Rasterizer.bottomX) { 407 + int endOffsetX = x + width - Rasterizer.bottomX; 408 + width -= endOffsetX; 409 + characterPixelOffset += endOffsetX; 410 + rasterizerPixelOffset += endOffsetX; 411 + } 412 + if (width > 0 && height > 0) { 413 + drawCharacterPixels(characterPixels[character], Rasterizer.pixels, characterPixel, rasterizerPixel, 414 + characterPixelOffset, rasterizerPixelOffset, width, height, colour); 415 + 416 + } 417 + } 418 + 419 + 420 + public void drawCharacterLegacy(byte[] pixels, int x, int y, int width, int height, int colour) { 421 + int rasterizerPixel = x + y * Rasterizer.width; 422 + int remainingWidth = Rasterizer.width - width; 423 + int characterPixelOffset = 0; 424 + int characterPixel = 0; 425 + if (y < Rasterizer.topY) { 426 + int offsetY = Rasterizer.topY - y; 427 + height -= offsetY; 428 + y = Rasterizer.topY; 429 + characterPixel += offsetY * width; 430 + rasterizerPixel += offsetY * Rasterizer.width; 431 + } 432 + if (y + height >= Rasterizer.bottomY) 433 + height -= ((y + height) - Rasterizer.bottomY) + 1; 434 + if (x < Rasterizer.topX) { 435 + int offsetX = Rasterizer.topX - x; 436 + width -= offsetX; 437 + x = Rasterizer.topX; 438 + characterPixel += offsetX; 439 + rasterizerPixel += offsetX; 440 + characterPixelOffset += offsetX; 441 + remainingWidth += offsetX; 442 + } 443 + if (x + width >= Rasterizer.bottomX) { 444 + int endOffsetX = ((x + width) - Rasterizer.bottomX) + 1; 445 + width -= endOffsetX; 446 + characterPixelOffset += endOffsetX; 447 + remainingWidth += endOffsetX; 448 + } 449 + if (width > 0 && height > 0) { 450 + drawCharacterPixels(pixels, Rasterizer.pixels, characterPixel, rasterizerPixel, characterPixelOffset, remainingWidth, width, height, colour); 451 + } 452 + } 453 + 454 + public void drawCharacterPixels(byte[] characterPixels, int[] rasterizerPixels, int characterPixel, 455 + int rasterizerPixel, int characterPixelOffset, int rasterizerPixelOffset, int width, int height, int colour) { 456 + int negativeQuaterWidth = -(width >> 2); 457 + width = -(width & 3); 458 + for (int heightCounter = -height; heightCounter < 0; heightCounter++) { 459 + for (int widthCounter = negativeQuaterWidth; widthCounter < 0; widthCounter++) { 460 + if (characterPixels[characterPixel++] != 0) 461 + rasterizerPixels[rasterizerPixel++] = colour; 462 + else 463 + rasterizerPixel++; 464 + if (characterPixels[characterPixel++] != 0) 465 + rasterizerPixels[rasterizerPixel++] = colour; 466 + else 467 + rasterizerPixel++; 468 + if (characterPixels[characterPixel++] != 0) 469 + rasterizerPixels[rasterizerPixel++] = colour; 470 + else 471 + rasterizerPixel++; 472 + if (characterPixels[characterPixel++] != 0) 473 + rasterizerPixels[rasterizerPixel++] = colour; 474 + else 475 + rasterizerPixel++; 476 + } 477 + 478 + for (int widthCounter = width; widthCounter < 0; widthCounter++) 479 + if (characterPixels[characterPixel++] != 0) 480 + rasterizerPixels[rasterizerPixel++] = colour; 481 + else 482 + rasterizerPixel++; 483 + 484 + rasterizerPixel += rasterizerPixelOffset; 485 + characterPixel += characterPixelOffset; 486 + } 487 + 488 + } 489 + 490 + private void setEffectsAlpha(int color, int shadow, int opac) { 491 + strikethroughColor = -1; 492 + underlineColor = -1; 493 + defaultShadowColor = shadow; 494 + shadowColor = shadow; 495 + defaultTextColor = color; 496 + textColor = color; 497 + defaultOpacity = opac; 498 + opacity = opac; 499 + whiteSpace = 0; 500 + anInt3748 = 0; 501 + } 502 + 503 + public void parseStringForEffects(String string) { 504 + do { 505 + try { 506 + if (string.startsWith(startColor)) { 507 + String color = string.substring(4); 508 + textColor = color.length() < 6 ? Color.decode(color).getRGB() : Integer.parseInt(color, 16); 509 + 510 + } else if (string.equals(endColor)) { 511 + textColor = defaultTextColor; 512 + } else if (string.startsWith(startTrans)) { 513 + opacity = Integer.valueOf(string.substring(6)); 514 + } else if (string.equals(endTrans)) { 515 + opacity = defaultOpacity; 516 + } else if (string.startsWith(startStrikethrough)) { 517 + String color = string.substring(4); 518 + strikethroughColor = color.length() < 6 ? Color.decode(color).getRGB() : Integer.parseInt(color, 16); 519 + } else if (string.equals(startDefaultStrikeThrough)) { 520 + strikethroughColor = 8388608; 521 + } else if (string.equals(endStrikeThrough)) { 522 + strikethroughColor = -1; 523 + } else if (string.startsWith(startUnderline)) { 524 + String color = string.substring(2); 525 + underlineColor = color.length() < 6 ? Color.decode(color).getRGB() : Integer.parseInt(color, 16); 526 + } else if (string.equals(startDefaultUnderline)) { 527 + underlineColor = 0; 528 + } else if (string.equals(endUnderline)) { 529 + underlineColor = -1; 530 + } else if (string.startsWith(startShadow)) { 531 + String color = string.substring(5); 532 + shadowColor = color.length() < 6 ? Color.decode(color).getRGB() : Integer.parseInt(color, 16); 533 + } else if (string.equals(startDefaultShadow)) { 534 + shadowColor = 0; 535 + } else if (string.equals(endShadow)) { 536 + shadowColor = defaultShadowColor; 537 + } else { 538 + if (!string.equals(lineBreak)) { 539 + break; 540 + } 541 + setEffectsAlpha(defaultTextColor, defaultShadowColor, defaultOpacity); 542 + } 543 + } catch (Exception exception) { 544 + break; 545 + } 546 + break; 547 + } while (false); 548 + } 549 + 550 + public final void drawBasicStringXYMods(String string, int drawX, int drawY, int[] xmodifiers, int[] ymodifiers) { 551 + drawY -= characterDefaultHeight; 552 + int effect = -1; 553 + int var7 = 0; 554 + int modifier = 0; 555 + int length = string.length(); 556 + 557 + for (int pos = 0; pos < length; ++pos) { 558 + int character = string.charAt(pos); 559 + if (character == 60) { 560 + effect = pos; 561 + } else { 562 + int xOff; 563 + int yOffset; 564 + int symbolWidth; 565 + if (character == 62 && effect != -1) { 566 + String symbol = string.substring(pos, effect + 1); 567 + effect = -1; 568 + if (symbol.equals(lessThan)) { 569 + character = 60; 570 + } else if (symbol.equals(greaterThan)) { 571 + character = 62; 572 + } else if (symbol.equals(nonBreakingSpace)) { 573 + character = 160; 574 + } else if (symbol.equals(softHyphen)) { 575 + character = 173; 576 + } else if (symbol.equals(multiplicationSymbol)) { 577 + character = 215; 578 + } else if (symbol.equals(euroSymbol)) { 579 + character = 128; 580 + } else if (symbol.equals(copyright)) { 581 + character = 169; 582 + } else { 583 + if (!symbol.equals(registeredTrademark)) { 584 + if (symbol.startsWith(image, 0)) { 585 + try { 586 + if (xmodifiers != null) { 587 + xOff = xmodifiers[modifier]; 588 + } else { 589 + xOff = 0; 590 + } 591 + 592 + if (ymodifiers != null) { 593 + yOffset = ymodifiers[modifier]; 594 + } else { 595 + yOffset = 0; 596 + } 597 + 598 + ++modifier; 599 + symbolWidth = Integer.parseInt(symbol.substring(4)); 600 + ImageRGB image = moderatorIcon[symbolWidth]; 601 + int imageHeight = imageWidths != null ? imageWidths[symbolWidth] : image.maxHeight; 602 + if (opacity == 256) { 603 + image.drawImage(drawX + xOff, drawY + characterDefaultHeight - imageHeight + yOffset); 604 + } else { 605 + image.drawImageAlpha( 606 + drawX + xOff, drawY + characterDefaultHeight - imageHeight + yOffset, opacity); 607 + } 608 + 609 + drawX += image.width; 610 + var7 = 0; 611 + } catch (Exception var18) { 612 + } 613 + } else { 614 + parseStringForEffects(symbol); 615 + } 616 + continue; 617 + } 618 + 619 + character = 174; 620 + } 621 + } 622 + if (character == '@' && character + 4 < string.length() && string.charAt(character + 4) == '@') { 623 + int stringColour = getColour(string.substring(character + 1, character + 4)); 624 + if (stringColour != -1) 625 + textColor = stringColour; 626 + pos += 4; 627 + continue; 628 + } 629 + 630 + if (effect == -1) { 631 + int cWidth = characterWidths[character]; 632 + xOff = characterHeights[character]; 633 + if (xmodifiers != null) { 634 + yOffset = xmodifiers[modifier]; 635 + } else { 636 + yOffset = 0; 637 + } 390 638 391 - } 639 + if (ymodifiers != null) { 640 + symbolWidth = ymodifiers[modifier]; 641 + } else { 642 + symbolWidth = 0; 643 + } 644 + 645 + ++modifier; 646 + if (character != 32) { 647 + if (opacity == 256) { 648 + if (shadowColor != -1) { 649 + drawCharacter(character, drawX + characterXOffsets[character] + 1 + yOffset, drawY + characterYOffsets[character] + 1 + symbolWidth, cWidth, xOff, shadowColor); 650 + } 651 + 652 + drawCharacter(character, drawX + characterXOffsets[character] + yOffset, drawY + characterYOffsets[character] + symbolWidth, cWidth, xOff, textColor); 653 + } else { 654 + if (shadowColor != -1) { 655 + drawCharacterAlpha(character, drawX + characterXOffsets[character] + 1 + yOffset, drawY + characterYOffsets[character] + 1 + symbolWidth, cWidth, xOff, shadowColor, opacity); 656 + } 657 + 658 + drawCharacterAlpha(character, drawX + characterXOffsets[character] + yOffset, drawY + characterYOffsets[character] + symbolWidth, cWidth, xOff, textColor, opacity); 659 + } 660 + } else if (whiteSpace > 0) { 661 + anInt3748 += whiteSpace; 662 + drawX += anInt3748 >> 8; 663 + anInt3748 &= 255; 664 + } 665 + 666 + int charWidth = characterScreenWidths[character]; 667 + if (strikethroughColor != -1) { 668 + if (opacity > 255) { 669 + Rasterizer.drawHorizontalLine(drawX, drawY + (int) ((double) characterDefaultHeight * 0.7D), charWidth, strikethroughColor); 670 + } else { 671 + Rasterizer.drawHorizontalLineAlpha(drawX, drawY + (int) ((double) characterDefaultHeight * 0.7D), charWidth, strikethroughColor, opacity); 672 + 673 + } 674 + } 675 + 676 + if (underlineColor != -1) { 677 + if (opacity > 255) { 678 + Rasterizer.drawHorizontalLine(drawX, drawY + characterDefaultHeight, charWidth, underlineColor); 679 + 680 + } else { 681 + 682 + Rasterizer.drawHorizontalLineAlpha(drawX, drawY + characterDefaultHeight, charWidth, underlineColor, opacity); 683 + } 684 + } 685 + 686 + drawX += charWidth; 687 + var7 = character; 688 + } 689 + } 690 + } 691 + 692 + } 693 + 694 + public void drawString(String string, int x, int y, int color, int shadow) { 695 + if (string != null) { 696 + setEffects(color, shadow); 697 + drawBasicString(string, x, y); 698 + } 699 + } 700 + 701 + 702 + public void drawStringAlignedLeft(String string, int x, int y, int color, int shadow) { 703 + if (string != null) { 704 + setEffects(color, shadow); 705 + drawBasicString(string, x - getDisplayedWidth(string), y); 706 + } 707 + } 708 + 709 + public void drawStringWave(String string, int x, int y, int color, int shadow, int var6) { 710 + if (string != null) { 711 + setEffects(color, shadow); 712 + int length = string.length(); 713 + int[] var8 = new int[length]; 714 + int[] var9 = new int[length]; 715 + 716 + for (int pos = 0; pos < length; ++pos) { 717 + var8[pos] = (int) (Math.sin((double) pos / 5.0D + (double) var6 / 5.0D) * 5.0D); 718 + var9[pos] = (int) (Math.sin((double) pos / 3.0D + (double) var6 / 5.0D) * 5.0D); 719 + } 720 + 721 + drawBasicStringXYMods(string, x - getDisplayedWidth(string) / 2, y, var8, var9); 722 + } 723 + } 724 + 725 + public void drawStringWaveY(String string, int x, int y, int color, int shadow, int tick) { 726 + if (string != null) { 727 + setEffects(color, shadow); 728 + int var7 = string.length(); 729 + int[] vertWaveOffset = new int[var7]; 730 + 731 + for (int whichChar = 0; whichChar < var7; ++whichChar) { 732 + vertWaveOffset[whichChar] = (int) (Math.sin((double) whichChar / 2.0D + (double) tick / 5.0D) * 5.0D); 733 + } 734 + 735 + drawBasicStringXYMods(string, x - getDisplayedWidth(string) / 2, y, (int[]) null, vertWaveOffset); 736 + } 737 + } 738 + 739 + 740 + public void drawCenteredStringXMod(String var1, int var2, int var3, int var4, int var5, int var6, int var7) { 741 + if (var1 != null) { 742 + setEffects(var4, var5); 743 + double amplitude = 7.0D - (double) var7 / 8.0D; 744 + if (amplitude < 0.0D) { 745 + amplitude = 0.0D; 746 + } 747 + 748 + int length = var1.length(); 749 + int[] xmod = new int[length]; 750 + 751 + for (int pos = 0; pos < length; ++pos) { 752 + xmod[pos] = (int) (Math.sin((double) pos / 1.5D + (double) var6 / 1.0D) * amplitude); 753 + } 754 + 755 + drawBasicStringXYMods(var1, var2 - getDisplayedWidth(var1) / 2, var3, (int[]) null, xmod); 756 + } 757 + } 758 + 759 + 760 + private void setEffects(int color, int shadow) { 761 + strikethroughColor = -1; 762 + underlineColor = -1; 763 + defaultShadowColor = shadow; 764 + shadowColor = shadow; 765 + defaultTextColor = color; 766 + textColor = color; 767 + defaultOpacity = 256; 768 + opacity = 256; 769 + whiteSpace = 0; 770 + anInt3748 = 0; 771 + } 392 772 773 + public void drawBasicString(String string, int x, int y) { 774 + y -= characterDefaultHeight; 775 + int effectIndex = -1; 776 + int var5 = 0; 777 + int textLength = string.length(); 778 + 779 + for (int character = 0; character < textLength; ++character) { 780 + int c = string.charAt(character); 781 + if (c > 255) { 782 + c = 32; 783 + } 784 + if (c == 60) { 785 + effectIndex = character; 786 + 787 + } else { 788 + if (c == 62 && effectIndex != -1) { 789 + 790 + String effectString = string.substring(effectIndex + 1, character); 791 + effectIndex = -1; 792 + if (effectString.equals(lessThan)) { 793 + c = 60; 794 + } else if (effectString.equals(greaterThan)) { 795 + c = 62; 796 + } else if (effectString.equals(nonBreakingSpace)) { 797 + c = 160; 798 + } else if (effectString.equals(softHyphen)) { 799 + c = 173; 800 + } else if (effectString.equals(multiplicationSymbol)) { 801 + c = 215; 802 + } else if (effectString.equals(euroSymbol)) { 803 + c = 128; 804 + } else if (effectString.equals(copyright)) { 805 + c = 169; 806 + } else { 807 + if (!effectString.equals(registeredTrademark)) { 808 + if (effectString.startsWith(image, 0)) { 809 + try { 810 + int icon = Integer.valueOf(effectString.substring(4)); 811 + ImageRGB nameIcon = moderatorIcon[icon]; 812 + int imageHeight = imageWidths != null ? imageWidths[icon] : nameIcon.maxHeight; 813 + if (opacity == 256) { 814 + nameIcon.drawImage(x, y + characterDefaultHeight - imageHeight); 815 + } else { 816 + nameIcon.drawImageAlpha(x, y + characterDefaultHeight - imageHeight, opacity); 817 + } 818 + 819 + x += nameIcon.maxWidth; 820 + var5 = 0; 821 + } catch (Exception e) { 822 + 823 + } 824 + } else { 825 + parseStringForEffects(effectString); 826 + } 827 + continue; 828 + } 829 + c = 174; 830 + } 831 + } 832 + if (c == '@' && character + 4 < string.length() && string.charAt(character + 4) == '@') { 833 + int stringColour = getColour(string.substring(character + 1, character + 4)); 834 + if (stringColour != -1) 835 + textColor = stringColour; 836 + character += 4; 837 + continue; 838 + } 839 + if (effectIndex == -1) { 840 + int width = characterWidths[c]; 841 + int height = characterHeights[c]; 842 + if (c != 32) { 843 + if (opacity == 256) { 844 + 845 + if (shadowColor != -1) { 846 + drawCharacter(c, x + characterXOffsets[c] + 1, y + characterYOffsets[c] + 1, width, height, shadowColor); 847 + } 848 + 849 + drawCharacter(c, x + characterXOffsets[c], y + characterYOffsets[c], width, height, textColor); 850 + } else { 851 + 852 + if (shadowColor != -1) { 853 + drawCharacterAlpha(c, x + characterXOffsets[c] + 1, y + characterYOffsets[c] + 1, width, height, shadowColor, opacity); 854 + 855 + } 856 + drawCharacterAlpha(c, x + characterXOffsets[c], y + characterYOffsets[c], width, height, textColor, opacity); 857 + } 858 + } else if (whiteSpace > 0) { 859 + anInt3748 += whiteSpace; 860 + x += anInt3748 >> 8; 861 + anInt3748 &= 255; 862 + } 863 + 864 + int charWidth = characterScreenWidths[c]; 865 + if (strikethroughColor != -1) { 866 + Rasterizer.drawHorizontalLine(x, y + (int) ((double) characterDefaultHeight * 0.7D), charWidth, strikethroughColor); 867 + } 868 + if (underlineColor != -1) { 869 + Rasterizer.drawHorizontalLine(x, y + characterDefaultHeight + 1, charWidth, underlineColor); 870 + } 871 + x += charWidth; 872 + var5 = c; 873 + } 874 + } 875 + } 876 + 877 + } 878 + 879 + public void drawCharacterAlpha(int character, int x, int y, int width, int height, 880 + int colour, int alpha) { 881 + this.drawAlphaCharacter(characterPixels[character], x, y, width, height, colour, alpha); 882 + } 883 + 884 + public void drawAlphaCharacter(byte[] characterPixels, int x, int y, int width, int height, int colour, 885 + int alpha) { 886 + int rasterizerPixel = x + y * Rasterizer.width; 887 + int rasterizerPixelOffset = Rasterizer.width - width; 888 + int characterPixelOffset = 0; 889 + int characterPixel = 0; 890 + if (y < Rasterizer.topY) { 891 + int yOffset = Rasterizer.topY - y; 892 + height -= yOffset; 893 + y = Rasterizer.topY; 894 + characterPixel += yOffset * width; 895 + rasterizerPixel += yOffset * Rasterizer.width; 896 + } 897 + if (y + height >= Rasterizer.bottomY) 898 + height -= ((y + height) - Rasterizer.bottomY) + 1; 899 + if (x < Rasterizer.topX) { 900 + int xOffset = Rasterizer.topX - x; 901 + width -= xOffset; 902 + x = Rasterizer.topX; 903 + characterPixel += xOffset; 904 + rasterizerPixel += xOffset; 905 + characterPixelOffset += xOffset; 906 + rasterizerPixelOffset += xOffset; 907 + } 908 + if (x + width >= Rasterizer.bottomX) { 909 + int widthoffset = ((x + width) - Rasterizer.bottomX) + 1; 910 + width -= widthoffset; 911 + characterPixelOffset += widthoffset; 912 + rasterizerPixelOffset += widthoffset; 913 + } 914 + if (width > 0 && height > 0) { 915 + drawCharacterPixelsAlpha(characterPixel, rasterizerPixelOffset, characterPixelOffset, rasterizerPixel, alpha, Rasterizer.pixels, colour, height, width, characterPixels); 916 + } 917 + } 918 + 919 + 920 + public void drawCharacterPixelsAlpha(int characterPixel, int rasterizerPixelOffset, int characterPixelOffset, 921 + int rasterizerPixel, int alpha, 922 + int[] rasterizerPixels, int colour, int height, int width, 923 + byte[] characterPixels) { 924 + colour = ((colour & 0xff00ff) * alpha & 0xff00ff00) + ((colour & 0xff00) * alpha & 0xff0000) >> 8; 925 + alpha = 256 - alpha; 926 + for (int heightCounter = -height; heightCounter < 0; heightCounter++) { 927 + for (int widthCounter = -width; widthCounter < 0; widthCounter++) 928 + if (characterPixels[characterPixel++] != 0) { 929 + int rasterizerPixelColor = rasterizerPixels[rasterizerPixel]; 930 + rasterizerPixels[rasterizerPixel++] = (((rasterizerPixelColor & 0xff00ff) * alpha & 0xff00ff00) + ((rasterizerPixelColor & 0xff00) * alpha & 0xff0000) >> 8) + colour; 931 + } else { 932 + rasterizerPixel++; 933 + } 934 + 935 + rasterizerPixel += rasterizerPixelOffset; 936 + characterPixel += characterPixelOffset; 937 + } 938 + 939 + } 940 + 941 + public void setNameIcons(ImageRGB[] images, int[] widths) { 942 + if (widths != null && widths.length != images.length) { 943 + throw new IllegalArgumentException(); 944 + } else { 945 + moderatorIcon = images; 946 + imageWidths = widths; 947 + } 948 + } 393 949 }
+469 -184
src/com/jagex/runescape/media/Rasterizer.java
··· 4 4 5 5 public class Rasterizer extends CacheableNode { 6 6 7 - public static int[] pixels; 8 - public static int width; 9 - public static int height; 10 - public static int topY; 11 - public static int bottomY; 12 - public static int topX; 13 - public static int bottomX; 14 - public static int virtualBottomX; 15 - public static int centerX; 16 - public static int centerY; 7 + public static int[] pixels; 8 + public static int width; 9 + public static int height; 10 + public static int topY; 11 + public static int bottomY; 12 + public static int topX; 13 + public static int bottomX; 14 + public static int virtualBottomX; 15 + public static int centerX; 16 + public static int centerY; 17 17 18 18 19 - public static void createRasterizer(int[] pixels, int width, int height) { 20 - Rasterizer.pixels = pixels; 21 - Rasterizer.width = width; 22 - Rasterizer.height = height; 23 - setCoordinates(0, 0, height, width); 24 - } 19 + public static void createRasterizer(int[] pixels, int width, int height) { 20 + Rasterizer.pixels = pixels; 21 + Rasterizer.width = width; 22 + Rasterizer.height = height; 23 + setCoordinates(0, 0, height, width); 24 + } 25 25 26 - public static void resetCoordinates() { 27 - topX = 0; 28 - topY = 0; 29 - bottomX = width; 30 - bottomY = height; 31 - virtualBottomX = bottomX - 1; 32 - centerX = bottomX / 2; 33 - } 26 + public static void resetCoordinates() { 27 + topX = 0; 28 + topY = 0; 29 + bottomX = width; 30 + bottomY = height; 31 + virtualBottomX = bottomX - 1; 32 + centerX = bottomX / 2; 33 + } 34 34 35 - public static void setCoordinates(int y, int x, int height, int width) { 36 - if (x < 0) 37 - x = 0; 38 - if (y < 0) 39 - y = 0; 40 - if (width > Rasterizer.width) 41 - width = Rasterizer.width; 42 - if (height > Rasterizer.height) 43 - height = Rasterizer.height; 44 - topX = x; 45 - topY = y; 46 - bottomX = width; 47 - bottomY = height; 48 - virtualBottomX = bottomX - 1; 49 - centerX = bottomX / 2; 50 - centerY = bottomY / 2; 35 + public static void resize(int topX, int topY, int bottomX, int bottomY) { 36 + if (Rasterizer.topX < topX) { 37 + Rasterizer.topX = topX; 38 + } 39 + if (Rasterizer.topY < topY) { 40 + Rasterizer.topY = topY; 41 + } 42 + if (Rasterizer.bottomX > bottomX) { 43 + Rasterizer.bottomX = bottomX; 44 + } 45 + if (Rasterizer.bottomY > bottomY) { 46 + Rasterizer.bottomY = bottomY; 47 + } 48 + } 49 + 50 + 51 + public static void setCoordinates(int y, int x, int height, int width) { 52 + if (x < 0) 53 + x = 0; 54 + if (y < 0) 55 + y = 0; 56 + if (width > Rasterizer.width) 57 + width = Rasterizer.width; 58 + if (height > Rasterizer.height) 59 + height = Rasterizer.height; 60 + topX = x; 61 + topY = y; 62 + bottomX = width; 63 + bottomY = height; 64 + virtualBottomX = bottomX - 1; 65 + centerX = bottomX / 2; 66 + centerY = bottomY / 2; 67 + 68 + } 69 + 70 + public static void resetPixels() { 71 + int pixelCount = width * height; 72 + for (int pixel = 0; pixel < pixelCount; pixel++) 73 + pixels[pixel] = 0; 74 + 75 + } 76 + 77 + public static void drawFilledRectangleAlhpa(int x, int y, int width, int height, int colour, int alpha) { 78 + if (x < topX) { 79 + width -= topX - x; 80 + x = topX; 81 + } 82 + if (y < topY) { 83 + height -= topY - y; 84 + y = topY; 85 + } 86 + if (x + width > bottomX) 87 + width = bottomX - x; 88 + if (y + height > bottomY) 89 + height = bottomY - y; 90 + int a = 256 - alpha; 91 + int r = (colour >> 16 & 0xff) * alpha; 92 + int g = (colour >> 8 & 0xff) * alpha; 93 + int b = (colour & 0xff) * alpha; 94 + int widthOffset = Rasterizer.width - width; 95 + int pixel = x + y * Rasterizer.width; 96 + for (int heightCounter = 0; heightCounter < height; heightCounter++) { 97 + for (int widthCounter = -width; widthCounter < 0; widthCounter++) { 98 + int red = (pixels[pixel] >> 16 & 0xff) * a; 99 + int green = (pixels[pixel] >> 8 & 0xff) * a; 100 + int blue = (pixels[pixel] & 0xff) * a; 101 + int rgba = ((r + red >> 8) << 16) + ((g + green >> 8) << 8) + (b + blue >> 8); 102 + pixels[pixel++] = rgba; 103 + } 104 + 105 + pixel += widthOffset; 106 + } 107 + 108 + } 109 + 110 + public static void drawFilledRectangle(int x, int y, int width, int height, int colour) { 111 + if (x < topX) { 112 + width -= topX - x; 113 + x = topX; 114 + } 115 + if (y < topY) { 116 + height -= topY - y; 117 + y = topY; 118 + } 119 + if (x + width > bottomX) 120 + width = bottomX - x; 121 + if (y + height > bottomY) 122 + height = bottomY - y; 123 + int pixelOffset = Rasterizer.width - width; 124 + int pixel = x + y * Rasterizer.width; 125 + for (int heightCounter = -height; heightCounter < 0; heightCounter++) { 126 + for (int widthCounter = -width; widthCounter < 0; widthCounter++) 127 + pixels[pixel++] = colour; 128 + 129 + pixel += pixelOffset; 130 + } 131 + } 132 + 133 + public static void drawUnfilledRectangle(int x, int y, int width, int height, int color) { 134 + drawHorizontalLine(x, y, width, color); 135 + drawHorizontalLine(x, (y + height) - 1, width, color); 136 + drawVerticalLine(x, y, height, color); 137 + drawVerticalLine((x + width) - 1, y, height, color); 138 + } 51 139 52 - } 140 + public static void drawUnfilledRectangleAlpha(int x, int y, int width, int height, int colour, int alpha) { 141 + drawHorizontalLineAlpha(x, y, width, colour, alpha); 142 + drawHorizontalLineAlpha(x, (y + height) - 1, width, colour, alpha); 143 + if (height >= 3) { 144 + drawVerticalLineAlpha(x, y + 1, height - 2, colour, alpha); 145 + drawVerticalLineAlpha((x + width) - 1, y + 1, height - 2, colour, alpha); 146 + } 147 + } 53 148 54 - public static void resetPixels() { 55 - int pixelCount = width * height; 56 - for (int pixel = 0; pixel < pixelCount; pixel++) 57 - pixels[pixel] = 0; 149 + public static void drawHorizontalLine(int x, int y, int lenght, int colour) { 150 + if (y < topY || y >= bottomY) 151 + return; 152 + if (x < topX) { 153 + lenght -= topX - x; 154 + x = topX; 155 + } 156 + if (x + lenght > bottomX) 157 + lenght = bottomX - x; 158 + int pixelOffset = x + y * width; 159 + for (int pixel = 0; pixel < lenght; pixel++) 160 + pixels[pixelOffset + pixel] = colour; 58 161 59 - } 162 + } 60 163 61 - public static void drawFilledRectangleAlhpa(int x, int y, int width, int height, int colour, int alpha) { 62 - if (x < topX) { 63 - width -= topX - x; 64 - x = topX; 65 - } 66 - if (y < topY) { 67 - height -= topY - y; 68 - y = topY; 69 - } 70 - if (x + width > bottomX) 71 - width = bottomX - x; 72 - if (y + height > bottomY) 73 - height = bottomY - y; 74 - int a = 256 - alpha; 75 - int r = (colour >> 16 & 0xff) * alpha; 76 - int g = (colour >> 8 & 0xff) * alpha; 77 - int b = (colour & 0xff) * alpha; 78 - int widthOffset = Rasterizer.width - width; 79 - int pixel = x + y * Rasterizer.width; 80 - for (int heightCounter = 0; heightCounter < height; heightCounter++) { 81 - for (int widthCounter = -width; widthCounter < 0; widthCounter++) { 82 - int red = (pixels[pixel] >> 16 & 0xff) * a; 83 - int green = (pixels[pixel] >> 8 & 0xff) * a; 84 - int blue = (pixels[pixel] & 0xff) * a; 85 - int rgba = ((r + red >> 8) << 16) + ((g + green >> 8) << 8) + (b + blue >> 8); 86 - pixels[pixel++] = rgba; 87 - } 164 + public static void drawHorizontalLineAlpha(int x, int y, int length, int colour, int alpha) { 165 + if (y < topY || y >= bottomY) 166 + return; 167 + if (x < topX) { 168 + length -= topX - x; 169 + x = topX; 170 + } 171 + if (x + length > bottomX) 172 + length = bottomX - x; 173 + int a = 256 - alpha; 174 + int r = (colour >> 16 & 0xff) * alpha; 175 + int g = (colour >> 8 & 0xff) * alpha; 176 + int b = (colour & 0xff) * alpha; 177 + int pixelOffset = x + y * width; 178 + for (int lengthCounter = 0; lengthCounter < length; lengthCounter++) { 179 + int red = (pixels[pixelOffset] >> 16 & 0xff) * a; 180 + int green = (pixels[pixelOffset] >> 8 & 0xff) * a; 181 + int blue = (pixels[pixelOffset] & 0xff) * a; 182 + int rgba = ((r + red >> 8) << 16) + ((g + green >> 8) << 8) + (b + blue >> 8); 183 + pixels[pixelOffset++] = rgba; 184 + } 185 + } 88 186 89 - pixel += widthOffset; 90 - } 187 + public static void drawVerticalLine(int x, int y, int lenght, int colour) { 188 + if (x < topX || x >= bottomX) 189 + return; 190 + if (y < topY) { 191 + lenght -= topY - y; 192 + y = topY; 193 + } 194 + if (y + lenght > bottomY) 195 + lenght = bottomY - y; 196 + int pixelOffset = x + y * width; 197 + for (int pixel = 0; pixel < lenght; pixel++) 198 + pixels[pixelOffset + pixel * width] = colour; 91 199 92 - } 200 + } 93 201 94 - public static void drawFilledRectangle(int x, int y, int width, int height, int colour) { 95 - if (x < topX) { 96 - width -= topX - x; 97 - x = topX; 98 - } 99 - if (y < topY) { 100 - height -= topY - y; 101 - y = topY; 102 - } 103 - if (x + width > bottomX) 104 - width = bottomX - x; 105 - if (y + height > bottomY) 106 - height = bottomY - y; 107 - int pixelOffset = Rasterizer.width - width; 108 - int pixel = x + y * Rasterizer.width; 109 - for (int heightCounter = -height; heightCounter < 0; heightCounter++) { 110 - for (int widthCounter = -width; widthCounter < 0; widthCounter++) 111 - pixels[pixel++] = colour; 202 + public static void drawVerticalLineAlpha(int x, int y, int lenght, int colour, int alpha) { 203 + if (x < topX || x >= bottomX) 204 + return; 205 + if (y < topY) { 206 + lenght -= topY - y; 207 + y = topY; 208 + } 209 + if (y + lenght > bottomY) 210 + lenght = bottomY - y; 211 + int a = 256 - alpha; 212 + int r = (colour >> 16 & 0xff) * alpha; 213 + int g = (colour >> 8 & 0xff) * alpha; 214 + int b = (colour & 0xff) * alpha; 215 + int pixel = x + y * width; 216 + for (int lengthCounter = 0; lengthCounter < lenght; lengthCounter++) { 217 + int red = (pixels[pixel] >> 16 & 0xff) * a; 218 + int blue = (pixels[pixel] >> 8 & 0xff) * a; 219 + int green = (pixels[pixel] & 0xff) * a; 220 + int rgba = ((r + red >> 8) << 16) + ((g + blue >> 8) << 8) + (b + green >> 8); 221 + pixels[pixel] = rgba; 222 + pixel += width; 223 + } 112 224 113 - pixel += pixelOffset; 114 - } 115 - } 225 + } 116 226 117 - public static void drawUnfilledRectangle(int x, int y, int width, int height, int color) { 118 - drawHorizontalLine(x, y, width, color); 119 - drawHorizontalLine(x, (y + height) - 1, width, color); 120 - drawVerticalLine(x, y, height, color); 121 - drawVerticalLine((x + width) - 1, y, height, color); 122 - } 123 227 124 - public static void drawUnfilledRectangleAlpha(int x, int y, int width, int height, int colour, int alpha) { 125 - drawHorizontalLineAlpha(x, y, width, colour, alpha); 126 - drawHorizontalLineAlpha(x, (y + height) - 1, width, colour, alpha); 127 - if (height >= 3) { 128 - drawVerticalLineAlpha(x, y + 1, height - 2, colour, alpha); 129 - drawVerticalLineAlpha((x + width) - 1, y + 1, height - 2, colour, alpha); 130 - } 131 - } 228 + static final void drawDiagonalLine(int x, int y, int DestX, int destY, int linecolor) { 229 + DestX -= x; 230 + destY -= y; 231 + if (destY == 0) { 232 + if (DestX >= 0) { 233 + drawHorizontalLine(x, y, DestX + 1, linecolor); 234 + } else { 235 + drawHorizontalLine(x + DestX, y, -DestX + 1, linecolor); 236 + } 237 + } else if (DestX == 0) { 238 + if (destY >= 0) { 239 + drawVerticalLine(x, y, destY + 1, linecolor); 240 + } else { 241 + drawVerticalLine(x, y + destY, -destY + 1, linecolor); 242 + } 243 + } else { 244 + if (DestX + destY < 0) { 245 + x += DestX; 246 + DestX = -DestX; 247 + y += destY; 248 + destY = -destY; 249 + } 250 + int var5; 251 + int var6; 252 + if (DestX > destY) { 253 + y <<= 16; 254 + y += '\u8000'; 255 + destY <<= 16; 256 + var5 = (int) Math.floor((double) destY / (double) DestX + 0.5D); 257 + DestX += x; 258 + if (x < topX) { 259 + y += var5 * (topX - x); 260 + x = topX; 261 + } 262 + if (DestX >= bottomX) { 263 + DestX = bottomX - 1; 264 + } 265 + while (x <= DestX) { 266 + var6 = y >> 16; 267 + if (var6 >= topY && var6 < bottomY) { 268 + pixels[x + var6 * width] = linecolor; 269 + } 270 + y += var5; 271 + ++x; 272 + } 273 + } else { 274 + x <<= 16; 275 + x += '\u8000'; 276 + DestX <<= 16; 277 + var5 = (int) Math.floor((double) DestX / (double) destY + 0.5D); 278 + destY += y; 279 + if (y < topY) { 280 + x += var5 * (topY - y); 281 + y = topY; 282 + } 283 + if (destY >= bottomY) { 284 + destY = bottomY - 1; 285 + } 286 + while (y <= destY) { 287 + var6 = x >> 16; 288 + if (var6 >= topX && var6 < bottomX) { 289 + pixels[var6 + y * width] = linecolor; 290 + } 291 + x += var5; 292 + ++y; 293 + } 294 + } 295 + } 296 + } 132 297 133 - public static void drawHorizontalLine(int x, int y, int lenght, int colour) { 134 - if (y < topY || y >= bottomY) 135 - return; 136 - if (x < topX) { 137 - lenght -= topX - x; 138 - x = topX; 139 - } 140 - if (x + lenght > bottomX) 141 - lenght = bottomX - x; 142 - int pixelOffset = x + y * width; 143 - for (int pixel = 0; pixel < lenght; pixel++) 144 - pixels[pixelOffset + pixel] = colour; 145 298 146 - } 299 + public static void drawCircle(int x, int y, int radius, int color) { 300 + if (radius == 0) { 301 + drawPixel(x, y, color); 302 + } else { 303 + if (radius < 0) { 304 + radius = -radius; 305 + } 306 + int var4 = y - radius; 307 + if (var4 < topY) { 308 + var4 = topY; 309 + } 310 + int var5 = y + radius + 1; 311 + if (var5 > bottomY) { 312 + var5 = bottomY; 313 + } 314 + int var6 = var4; 315 + int var7 = radius * radius; 316 + int var8 = 0; 317 + int var9 = y - var4; 318 + int var10 = var9 * var9; 319 + int var11 = var10 - var9; 320 + if (y > var5) { 321 + y = var5; 322 + } 323 + int var12; 324 + int var13; 325 + int var14; 326 + int var15; 327 + while (var6 < y) { 328 + while (var11 <= var7 || var10 <= var7) { 329 + var10 += var8 + var8; 330 + var11 += var8++ + var8; 331 + } 332 + var12 = x - var8 + 1; 333 + if (var12 < topX) { 334 + var12 = topX; 335 + } 336 + var13 = x + var8; 337 + if (var13 > bottomX) { 338 + var13 = bottomX; 339 + } 340 + var14 = var12 + var6 * width; 341 + for (var15 = var12; var15 < var13; ++var15) { 342 + pixels[var14++] = color; 343 + } 344 + ++var6; 345 + var10 -= var9-- + var9; 346 + var11 -= var9 + var9; 347 + } 348 + var8 = radius; 349 + var9 = var6 - y; 350 + var11 = var9 * var9 + var7; 351 + var10 = var11 - radius; 352 + for (var11 -= var9; var6 < var5; var10 += var9++ + var9) { 353 + while (var11 > var7 && var10 > var7) { 354 + var11 -= var8-- + var8; 355 + var10 -= var8 + var8; 356 + } 357 + var12 = x - var8; 358 + if (var12 < topX) { 359 + var12 = topX; 360 + } 361 + var13 = x + var8; 362 + if (var13 > bottomX - 1) { 363 + var13 = bottomX - 1; 364 + } 365 + var14 = var12 + var6 * width; 366 + for (var15 = var12; var15 <= var13; ++var15) { 367 + pixels[var14++] = color; 368 + } 369 + ++var6; 370 + var11 += var9 + var9; 371 + } 372 + } 373 + } 147 374 148 - public static void drawHorizontalLineAlpha(int x, int y, int length, int colour, int alpha) { 149 - if (y < topY || y >= bottomY) 150 - return; 151 - if (x < topX) { 152 - length -= topX - x; 153 - x = topX; 154 - } 155 - if (x + length > bottomX) 156 - length = bottomX - x; 157 - int a = 256 - alpha; 158 - int r = (colour >> 16 & 0xff) * alpha; 159 - int g = (colour >> 8 & 0xff) * alpha; 160 - int b = (colour & 0xff) * alpha; 161 - int pixelOffset = x + y * width; 162 - for (int lengthCounter = 0; lengthCounter < length; lengthCounter++) { 163 - int red = (pixels[pixelOffset] >> 16 & 0xff) * a; 164 - int green = (pixels[pixelOffset] >> 8 & 0xff) * a; 165 - int blue = (pixels[pixelOffset] & 0xff) * a; 166 - int rgba = ((r + red >> 8) << 16) + ((g + green >> 8) << 8) + (b + blue >> 8); 167 - pixels[pixelOffset++] = rgba; 168 - } 169 - } 375 + public static void drawCircleAlpha(int x, int y, int radius, int color, int alpha) { 376 + if (alpha != 0) { 377 + if (alpha == 256) { 378 + drawCircle(x, y, radius, color); 379 + } else { 380 + if (radius < 0) { 381 + radius = -radius; 382 + } 383 + int a = 256 - alpha; 384 + int r = (color >> 16 & 255) * alpha; 385 + int g = (color >> 8 & 255) * alpha; 386 + int b = (color & 255) * alpha; 387 + int topY = y - radius; 388 + if (topY < Rasterizer.topY) { 389 + topY = Rasterizer.topY; 390 + } 391 + int bottomY = y + radius + 1; 392 + if (bottomY > Rasterizer.bottomY) { 393 + bottomY = Rasterizer.bottomY; 394 + } 395 + int var14 = topY; 396 + int var15 = radius * radius; 397 + int var16 = 0; 398 + int var17 = y - topY; 399 + int var18 = var17 * var17; 400 + int var19 = var18 - var17; 401 + if (y > bottomY) { 402 + y = bottomY; 403 + } 404 + int var9; 405 + int var10; 406 + int var11; 407 + int var21; 408 + int var20; 409 + int var23; 410 + int var22; 411 + int var24; 412 + while (var14 < y) { 413 + while (var19 <= var15 || var18 <= var15) { 414 + var18 += var16 + var16; 415 + var19 += var16++ + var16; 416 + } 417 + var20 = x - var16 + 1; 418 + if (var20 < topX) { 419 + var20 = topX; 420 + } 421 + var21 = x + var16; 422 + if (var21 > bottomX) { 423 + var21 = bottomX; 424 + } 425 + var22 = var20 + var14 * width; 426 + for (var23 = var20; var23 < var21; ++var23) { 427 + var9 = (pixels[var22] >> 16 & 255) * a; 428 + var10 = (pixels[var22] >> 8 & 255) * a; 429 + var11 = (pixels[var22] & 255) * a; 430 + var24 = (r + var9 >> 8 << 16) + (g + var10 >> 8 << 8) + (b + var11 >> 8); 431 + pixels[var22++] = var24; 432 + } 433 + ++var14; 434 + var18 -= var17-- + var17; 435 + var19 -= var17 + var17; 436 + } 437 + var16 = radius; 438 + var17 = -var17; 439 + var19 = var17 * var17 + var15; 440 + var18 = var19 - radius; 441 + for (var19 -= var17; var14 < bottomY; var18 += var17++ + var17) { 442 + while (var19 > var15 && var18 > var15) { 443 + var19 -= var16-- + var16; 444 + var18 -= var16 + var16; 445 + } 446 + var20 = x - var16; 447 + if (var20 < topX) { 448 + var20 = topX; 449 + } 450 + var21 = x + var16; 451 + if (var21 > bottomX - 1) { 452 + var21 = bottomX - 1; 453 + } 454 + var22 = var20 + var14 * width; 455 + for (var23 = var20; var23 <= var21; ++var23) { 456 + var9 = (pixels[var22] >> 16 & 255) * a; 457 + var10 = (pixels[var22] >> 8 & 255) * a; 458 + var11 = (pixels[var22] & 255) * a; 459 + var24 = (r + var9 >> 8 << 16) + (g + var10 >> 8 << 8) + (b + var11 >> 8); 460 + pixels[var22++] = var24; 461 + } 462 + ++var14; 463 + var19 += var17 + var17; 464 + } 465 + } 466 + } 467 + } 170 468 171 - public static void drawVerticalLine(int x, int y, int lenght, int colour) { 172 - if (x < topX || x >= bottomX) 173 - return; 174 - if (y < topY) { 175 - lenght -= topY - y; 176 - y = topY; 177 - } 178 - if (y + lenght > bottomY) 179 - lenght = bottomY - y; 180 - int pixelOffset = x + y * width; 181 - for (int pixel = 0; pixel < lenght; pixel++) 182 - pixels[pixelOffset + pixel * width] = colour; 183 469 184 - } 470 + private static void drawPixel(int x, int y, int color) { 471 + if (x >= topX && y >= topY && x < bottomX && y < bottomY) { 472 + pixels[x + y * width] = color; 473 + } 474 + } 185 475 186 - public static void drawVerticalLineAlpha(int x, int y, int lenght, int colour, int alpha) { 187 - if (x < topX || x >= bottomX) 188 - return; 189 - if (y < topY) { 190 - lenght -= topY - y; 191 - y = topY; 192 - } 193 - if (y + lenght > bottomY) 194 - lenght = bottomY - y; 195 - int a = 256 - alpha; 196 - int r = (colour >> 16 & 0xff) * alpha; 197 - int g = (colour >> 8 & 0xff) * alpha; 198 - int b = (colour & 0xff) * alpha; 199 - int pixel = x + y * width; 200 - for (int lengthCounter = 0; lengthCounter < lenght; lengthCounter++) { 201 - int red = (pixels[pixel] >> 16 & 0xff) * a; 202 - int blue = (pixels[pixel] >> 8 & 0xff) * a; 203 - int green = (pixels[pixel] & 0xff) * a; 204 - int rgba = ((r + red >> 8) << 16) + ((g + blue >> 8) << 8) + (b + green >> 8); 205 - pixels[pixel] = rgba; 206 - pixel += width; 207 - } 476 + public static void clearPixels() { 477 + int i = 0; 478 + int pixeltoclear; 479 + for (pixeltoclear = width * height - 7; i < pixeltoclear; pixels[i++] = 0) { 480 + pixels[i++] = 0; 481 + pixels[i++] = 0; 482 + pixels[i++] = 0; 483 + pixels[i++] = 0; 484 + pixels[i++] = 0; 485 + pixels[i++] = 0; 486 + pixels[i++] = 0; 487 + } 488 + for (pixeltoclear += 7; i < pixeltoclear; pixels[i++] = 0) { 489 + } 490 + } 208 491 209 - } 492 + public static void destroy() { 493 + pixels = null; 494 + } 210 495 211 - public Rasterizer() { 212 - } 213 496 497 + public Rasterizer() { 498 + } 214 499 215 500 216 501 }