📄 scharacterparser.java
字号:
package org.jflashme;/* This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License, version 2, as * published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License (the accompanying file named LGPL.txt) * for more details. */final class SCharacterParser extends SParser{ static final int fillSolid = 0; static final int fillGradient = 16; static final int fillLinearGradient = 16; static final int fillRadialGradient = 18; static final int fillMaxGradientColors = 8; static final int fillBits = 64; static final int fillBitsClip = 65; static final int fillBitsNoSmooth = 66; DisplayList display; ScriptPlayer player; ColorTransform cx; Matrix mat; int layer; int nLines; int nFills; RColor fillIndex[]; RColor lineIndexColor[]; int lineIndexThick[]; int nFillBits; int nLineBits; int line; int fill0; int fill1; Point curPt; Point curPtX; Point curPtXc; Point curPtX2; public final int eflagsMoveTo = 1; public final int eflagsFill0 = 2; public final int eflagsFill1 = 4; public final int eflagsLine = 8; public final int eflagsNewStyles = 16; public final int eflagsEnd = 128; boolean useWinding; int depth; SObject obj; int fillRule; RColor color1; RColor color2; RColor strokeColor; boolean isThick; int lineThickness; boolean strokeInited; int strokeDepth; Point lStartPt; Point startOrigin; Point rStartPt; Point lCurPt; Point curOrigin; Point rCurPt; Point sCurPt; SCharacterParser(ScriptPlayer scriptplayer, int i, Matrix matrix, ColorTransform colortransform) { curPt = new Point(0, 0); curPtX = new Point(0, 0); curPtXc = new Point(0, 0); curPtX2 = new Point(0, 0); useWinding = false; lStartPt = new Point(0, 0); startOrigin = new Point(0, 0); rStartPt = new Point(0, 0); lCurPt = new Point(0, 0); curOrigin = new Point(0, 0); rCurPt = new Point(0, 0); sCurPt = new Point(0, 0); mat = matrix; cx = colortransform; layer = 0; nLines = nFills = 0; line = fill0 = fill1 = 0; curPt.x = curPt.y = 0; mat.transform(curPt, curPtX); player = scriptplayer; display = scriptplayer.display; byte abyte0[] = ((SParser) (player)).script; super.script = abyte0; super.pos = i; } private void buildCache(RColor rcolor) { if(rcolor.cacheValid) return; switch(rcolor.fillType) { case 64: // '@' case 65: // 'A' case 66: // 'B' if(rcolor.bitmap == null) { rcolor.fillType = 0; return; } rcolor.bmFast = true; rcolor.bmDx = rcolor.bmInvMat.a; rcolor.bmDy = rcolor.bmInvMat.b; if(cx != null) { cx.BuildMapChannels(); rcolor.cx = cx; rcolor.bmFast = false; return; } break; } } boolean GetStyles() { nFills = super.script[super.pos++] & 0xff; if(nFills == 255) nFills = GetWord(); if((fillIndex = new RColor[nFills + 1]) == null) return false; for(int i = 1; i <= nFills; i++) { RColor rcolor = null; int k = super.script[super.pos++] & 0xff; if((k & 0x10) != 0) { Matrix matrix = GetMatrix(); int i1 = super.script[super.pos++] & 0xff; int ai[] = new int[i1]; int ai1[] = new int[i1]; for(int j1 = 0; j1 < i1; j1++) { ai1[j1] = super.script[super.pos++] & 0xff; ai[j1] = GetColor(); } rcolor = new RColor(display, k, i1, ai, ai1, matrix, mat); if(cx != null) cx.ApplyGradient(rcolor); } else if((k & 0x40) != 0) { int l = GetWord(); Matrix matrix1 = GetMatrix(); rcolor = new RColor(display, -65281); SCharacter scharacter = player.findCharacter(l); if(scharacter != null && scharacter.type == 1) { if(scharacter.object != null && (scharacter.object instanceof Bitmap)) { rcolor.bitmap = (Bitmap)scharacter.object; rcolor.fillType = k;/* if(display.model != null) { Matrix matrix2; if(display.antialias) { Matrix matrix3 = new Matrix(); matrix3.scale(16384, 16384); matrix2 = Matrix.concat(mat, matrix3); } else { matrix2 = new Matrix(mat); } matrix1.tx <<= 16; matrix1.ty <<= 16; matrix2.tx <<= 16; matrix2.ty <<= 16; matrix1 = Matrix.concat(matrix1, matrix2); rcolor.bmInvMat = matrix1.invert(); buildCache(rcolor); }*/ } } else { rcolor = new RColor(display, 0xffff0000); } } else { rcolor = new RColor(display, GetColor()); if(cx != null) cx.Apply(rcolor); } fillIndex[i] = rcolor; rcolor.order = layer + i; } nLines = super.script[super.pos++] & 0xff; if(nLines == 255) nLines = GetWord(); lineIndexColor = new RColor[nLines + 1]; lineIndexThick = new int[nLines + 1]; if(lineIndexColor == null || lineIndexThick == null) { lineIndexColor = null; lineIndexThick = null; return false; } for(int j = 1; j <= nLines; j++) { lineIndexThick[j] = mat.transform(GetWord()); RColor rcolor1 = new RColor(display, GetColor()); if(cx != null) cx.Apply(rcolor1); lineIndexColor[j] = rcolor1; rcolor1.order = layer | j + nFills; } super.bitPos = 0; super.bitBuf = 0; nFillBits = GetBits(4); nLineBits = GetBits(4); return true; } int GetEdge(Curve curve) { boolean flag = GetBits(1) != 0; if(!flag) { int i = GetBits(5); if(i == 0) return 128; if((i & 1) != 0) { int l = GetBits(5); curPt.x = GetSBits(l); curPt.y = GetSBits(l); mat.transform(curPt, curPtX); } if((i & 2) != 0) fill0 = GetBits(nFillBits); if((i & 4) != 0) fill1 = GetBits(nFillBits); if((i & 8) != 0) line = GetBits(nLineBits); if((i & 0x10) != 0) { layer += nFills + nLines; GetStyles(); } return i; } curve.isLine = GetBits(1) != 0; if(curve.isLine) { int j = GetBits(4) + 2; boolean flag1 = GetBits(1) != 0; if(flag1) { curPt.x += GetSBits(j); curPt.y += GetSBits(j); } else { boolean flag2 = GetBits(1) != 0; if(flag2) curPt.y += GetSBits(j); else curPt.x += GetSBits(j); } mat.transform(curPt, curPtX2); curve.set(curPtX, curPtX2); } else { int k = GetBits(4) + 2; curPt.x += GetSBits(k); curPt.y += GetSBits(k); mat.transform(curPt, curPtXc); curPt.x += GetSBits(k); curPt.y += GetSBits(k); mat.transform(curPt, curPtX2); curve.set(curPtX, curPtXc, curPtX2); } curPtX.x = curPtX2.x; curPtX.y = curPtX2.y; return 0; } void AddCurve(Curve curve, boolean flag) { REdge redge = new REdge(); if(curve.anchor1y <= curve.anchor2y) { redge.anchor1x = curve.anchor1x; redge.anchor1y = curve.anchor1y; redge.anchor2x = curve.anchor2x; redge.anchor2y = curve.anchor2y; redge.dir = 1; } else { redge.anchor1x = curve.anchor2x; redge.anchor1y = curve.anchor2y; redge.anchor2x = curve.anchor1x; redge.anchor2y = curve.anchor1y; redge.dir = -1; } redge.isLine = curve.isLine; redge.controlx = curve.controlx; redge.controly = curve.controly; if(!((Curve) (redge)).isLine) { if(((Curve) (redge)).controly < ((Curve) (redge)).anchor1y || ((Curve) (redge)).controly > ((Curve) (redge)).anchor2y) if(((Curve) (redge)).controly < ((Curve) (redge)).anchor1y && ((Curve) (redge)).anchor1y - ((Curve) (redge)).controly < 3) redge.controly = ((Curve) (redge)).anchor1y; else if(curve.controly > ((Curve) (redge)).anchor2y && curve.controly - ((Curve) (redge)).anchor2y < 3) { redge.controly = ((Curve) (redge)).anchor2y; } else { int i = (curve.anchor1y - 2 * curve.controly) + curve.anchor2y; int j = curve.anchor1y - curve.controly; if(++depth > 16) { return; } else { Curve curve3 = new Curve(curve); Curve curve4 = curve3.divide((int)(((long)j << 16) /i)); AddCurve(curve3, flag); AddCurve(curve4, flag); depth--; return; } } if(((Curve) (redge)).anchor2y - ((Curve) (redge)).anchor1y > 256) if(++depth > 16) { return; } else { Curve curve1 = new Curve(curve); Curve curve2 = curve1.divide(32768); AddCurve(curve1, flag); AddCurve(curve2, flag);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -