@wcardinal/wcardinal-ui 0.469.0-beta.0 → 0.469.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,7 +38,7 @@ export declare class EShapeFanTriangulatedImpl implements EShapeFanTriangulated
38
38
  /** P: the points on the arc */
39
39
  protected static readonly WORK_ARC_X: number[];
40
40
  protected static readonly WORK_ARC_Y: number[];
41
- /** The arc lengths measured from P[0] */
41
+ /** The lengths of the polyline P[0], ..., P[k] */
42
42
  protected static readonly WORK_ARC_L: number[];
43
43
  /** The unit inward normals of the arc */
44
44
  protected static readonly WORK_NORMAL_X: number[];
@@ -50,10 +50,9 @@ export declare class EShapeFanTriangulatedImpl implements EShapeFanTriangulated
50
50
  protected static readonly WORK_MEDIAL_Y: number[];
51
51
  /** The distances from P to Q */
52
52
  protected static readonly WORK_MEDIAL_D: number[];
53
- /** R: the points on the arc shifted outward, and their lengths */
53
+ /** R: the points on the arc shifted outward */
54
54
  protected static readonly WORK_RIM_X: number[];
55
55
  protected static readonly WORK_RIM_Y: number[];
56
- protected static readonly WORK_RIM_L: number[];
57
56
  protected _id: number;
58
57
  protected _parent: EShape;
59
58
  protected _width: number;
@@ -101,12 +100,12 @@ export declare class EShapeFanTriangulatedImpl implements EShapeFanTriangulated
101
100
  */
102
101
  protected computeArcPoints(w: number, h: number, n: number, ea: number, sea: number, cea: number): void;
103
102
  /**
104
- * Computes the unit inward normals of the arc, the speeds of the arc, and the arc lengths at P[k].
103
+ * Computes the unit inward normals of the arc, the speeds of the arc, and the lengths of the polyline at P[k].
105
104
  *
106
105
  * The normal at P is Np = (-h x / w, -w y / h), whose magnitude is the speed of the arc.
107
- * The speed is used to approximate the arc length without extra square roots.
106
+ * The lengths are the ones of the polyline, which is the actual outline, so that they are exact at clipping = 1.
108
107
  */
109
- protected computeArcNormals(w: number, h: number, n: number, ea: number): void;
108
+ protected computeArcNormals(w: number, h: number, n: number): void;
110
109
  /**
111
110
  * Computes Q[k], the points on the normals, and their distances from P[k], and returns the maximum distance.
112
111
  *
@@ -120,13 +119,16 @@ export declare class EShapeFanTriangulatedImpl implements EShapeFanTriangulated
120
119
  */
121
120
  protected computeMedialPoints(w: number, h: number, n: number, st: number, ct: number, chained: boolean): number;
122
121
  /**
123
- * Computes R[k], the points on the arc shifted outward by fs, and their lengths.
122
+ * Computes R[k], the points on the arc shifted outward by fs.
124
123
  * If the straight sides are the outline, the end points are shifted
125
124
  * to the intersections of the shifted arc and the shifted straight sides.
126
125
  */
127
- protected computeRimPoints(w: number, h: number, n: number, fs: number, st: number, ct: number, sea: number, cea: number, sided: boolean): void;
126
+ protected computeRimPoints(n: number, fs: number, st: number, ct: number, sided: boolean): void;
128
127
  /**
129
- * Writes the strip P[k], P[k + 1], Q[k + 1], Q[k] with the vertices R[k] and Q[k].
128
+ * Writes the strip P[k], P[k + 1], Q[k + 1], Q[k] with the vertices R[k], Q[k], R[k + 1] and Q[k + 1].
129
+ *
130
+ * Each quad owns its vertices. The length in a quad is the length at P[k] plus the projection
131
+ * to the chord P[k]P[k + 1], which is exact at clipping = 1 where the chord is the outline.
130
132
  */
131
133
  protected writeStrip(m: number, fd: number, fx: number, fy: number, gx: number, gy: number): void;
132
134
  /**
@@ -8,7 +8,7 @@ import { DynamicAtlasItemImage } from "../util/dynamic-atlas-item-image";
8
8
  import { EShapeBuffer } from "./e-shape-buffer";
9
9
  import { EShapeRendererIterator } from "./e-shape-renderer-iterator";
10
10
  var VERTEX_SHADER = "\nattribute highp vec2 aPosition;\nattribute highp vec2 aStepA;\nattribute highp vec4 aStepB;\nattribute highp vec3 aColor;\nattribute highp vec2 aUv;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mediump float shapeScale;\nuniform mediump float antialiasWeight;\n\nvarying mediump float vType;\nvarying mediump vec2 vStepA;\nvarying mediump vec4 vStepB;\nvarying mediump vec4 vLength;\nvarying mediump vec4 vColorFill;\nvarying mediump vec4 vColorStroke;\nvarying mediump vec2 vUv;\n\nvec2 toInverse(in vec2 v) {\n\treturn vec2(-v.y, v.x);\n}\n\nvec4 toGeneral(in float v) {\n\tvec4 c = vec4(1.0, 1.0/64.0, 1.0/64.0/64.0, 1.0/64.0/64.0/64.0) * v;\n\tc -= fract(c);\n\tc -= c.yzwx * vec4(64.0, 64.0, 64.0, 0.0);\n\treturn c;\n}\n\nfloat toStrokeWidthScale(in float scale) {\n\treturn (\n\t\tscale == 3.0 || scale == 7.0 ?\n\t\tshapeScale : (\n\t\t\tscale == 1.0 || scale == 5.0 ?\n\t\t\tmin(1.0, shapeScale) : (\n\t\t\t\tscale == 2.0 || scale == 6.0 ?\n\t\t\t\tmax(1.0, shapeScale) : 1.0\n\t\t\t)\n\t\t)\n\t);\n}\n\nvec2 toUnpackedClippings(in float v) {\n\tvec2 c = vec2(1.0, 1.0/1024.0) * v;\n\tc -= fract(c);\n\tc -= c.yx * vec2(1024.0, 0.0);\n\tc /= vec2(852.5, 852.5);\n\tc -= vec2(0.1, 0.1);\n\treturn c;\n}\n\nvec2 toUnpackedAlphas(in float v) {\n\tvec2 c = vec2(1.0, 1.0/1024.0) * v;\n\tc -= fract(c);\n\tc -= c.yx * vec2(1024.0, 0.0);\n\tc /= vec2(1023.0, 1023.0);\n\treturn c;\n}\n\nvec3 toUnpackedF3x256(in float v) {\n\tvec3 c = vec3(1.0, 1.0/256.0, 1.0/256.0/256.0) * v;\n\tc -= fract(c);\n\tc -= c.yzx * vec3(256.0, 256.0, 0.0);\n\tc /= 255.0;\n\treturn c;\n}\n\nvec2 toPosition012(in vec2 v) {\n\treturn (projectionMatrix * translationMatrix * vec3(v, 1.0)).xy;\n}\n\nvec4 toStepB01(in vec4 sb) {\n\treturn vec4(sb.xy, toUnpackedClippings(sb.z));\n}\n\nvec4 toStepB2(in vec4 sb, in float strokeWidth) {\n\tfloat x = min(0.4, 0.4 / 12.0 * sb.x * antialiasWeight);\n\tfloat w = clamp(strokeWidth, 0.0, 1.0) * 0.4;\n\tfloat p = w * sb.y + sb.z;\n\tfloat y = 0.5 - p;\n\tfloat z = 0.5 - p - w;\n\treturn vec4(y, z, y - max(0.01, y - x), z - max(0.01, z - x));\n}\n\nvec2 toPosition3(in float type, in vec2 p, in float npacked, in float length, in float strokeWidth, out float shift) {\n\tvec3 t = vec3(1.0, 1.0/1024.0, 1.0/1024.0/1024.0) * npacked;\n\tt -= fract(t);\n\tt -= t.yzx * vec3(1024.0, 1024.0, 0.0);\n\tt *= vec3(1.0/511.5, 1.0/511.5, 1.0);\n\tt -= vec3(1.0, 1.0, 0.0);\n\tvec2 n0 = vec2(t.x, ((0.5 < t.z && t.z < 1.5) || 2.5 < t.z ? +1.0 : -1.0) * sqrt(max(0.0, 1.0 - t.x * t.x)));\n\tvec2 n1 = vec2(t.y, (1.5 < t.z ? +1.0 : -1.0) * sqrt(max(0.0, 1.0 - t.y * t.y)));\n\n\tvec2 n0i = toInverse(n0);\n\tvec2 n1i = toInverse(n1);\n\tfloat direction = sign(4.5 - type);\n\n\t// Offset\n\tfloat cross = dot(n0i, n1);\n\tbool bcross = 0.00001 < abs(cross);\n\tfloat crossi = (bcross ? 1.0 / cross : 0.0);\n\tfloat b = dot(n1 - n0, n0) * crossi;\n\tfloat offsetSize = direction * strokeWidth * 0.5;\n\tvec2 offset = n1 + n1i * b;\n\n\t// Miter\n\tvec2 pmiter = p + offsetSize * offset;\n\tfloat miterAngle0 = dot( n0i, offsetSize * offset - length * n0i );\n\tfloat miterAngle1 = dot( n1i, offsetSize * offset + length * n1i );\n\tfloat miterLength = dot( offset, offset );\n\tfloat miterSide = direction * cross;\n\n\t// Bevel\n\tvec2 n = (type == 4.0 || type == 6.0 ? n1 : n0);\n\tvec2 pbevel = p + offsetSize * n;\n\n\t//\n\tvec2 presult = (\n\t\t0.0 <= miterSide ?\n\t\t(miterAngle0 < 0.0 && 0.0 <= miterAngle1 && bcross ? pmiter : pbevel) :\n\t\t(miterLength < 6.0 && bcross ? pmiter : pbevel)\n\t);\n\tvec2 ni = (type == 4.0 || type == 6.0 ? n1i : n0i);\n\tshift = dot(ni, p - presult);\n\treturn toPosition012(presult);\n}\n\nvec2 toStepA3(in float type, in float strokeWidth) {\n\treturn vec2(type < 4.5 ? 1.0 : 0.0, strokeWidth);\n}\n\nfloat toDotWidth(in float strokeScaling, in float strokeWidthScale) {\n\treturn aStepA.x * (\n\t\tstrokeScaling == 4.0 || strokeScaling == 5.0 ||\n\t\tstrokeScaling == 6.0 || strokeScaling == 7.0 ?\n\t\tstrokeWidthScale : 1.0\n\t);\n}\n\nvec2 toDotPattern(in float dash) {\n\treturn (dash < 0.5 ?\n\t\tvec2(1.0, 0.0) :\n\t\t(dash < 3.5 ?\n\t\t\t(dash < 1.5 ?\n\t\t\t\tvec2(1.0, 1.0) :\n\t\t\t\t(2.5 < dash ?\n\t\t\t\t\tvec2(1.0, 2.0) :\n\t\t\t\t\tvec2(1.0, 0.5)\n\t\t\t\t)\n\t\t\t) :\n\t\t\t(dash < 4.5 ?\n\t\t\t\tvec2(2.0, 1.0) :\n\t\t\t\t(5.5 < dash ?\n\t\t\t\t\tvec2(2.0, 2.0) :\n\t\t\t\t\tvec2(2.0, 0.5)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t);\n}\n\nvec4 toLength3(in float shift, in float dash, in float strokeScaling, in float strokeWidthScale) {\n\tfloat width = toDotWidth(strokeScaling, strokeWidthScale);\n\tvec2 pattern = toDotPattern(dash);\n\treturn vec4(aStepB.y + shift, pattern.x * width, pattern.y * width, aStepB.z);\n}\n\nvec4 toLength7(in float type, in float strokeScaling, in float strokeWidthScale) {\n\tfloat width = toDotWidth(strokeScaling, strokeWidthScale);\n\tvec2 pattern = toDotPattern(type - 7.0);\n\treturn vec4(aStepB.w, pattern.x * width, pattern.y * width, -1.0);\n}\n\nvoid toColors(in vec3 source, out vec4 fillColor, out vec4 strokeColor) {\n\tvec2 a = toUnpackedAlphas(source.z);\n\tfillColor.xyz = toUnpackedF3x256(source.x).zyx * a.x;\n\tfillColor.w = a.x;\n\tstrokeColor.xyz = toUnpackedF3x256(source.y).zyx * a.y;\n\tstrokeColor.w = a.y;\n}\n\nvoid main(void) {\n\tvec4 general = toGeneral(aStepA.y);\n\tfloat type = general.x;\n\tfloat strokeScaling = general.y;\n\tfloat strokeWidthScale = toStrokeWidthScale(strokeScaling);\n\tfloat strokeWidth = strokeWidthScale * aStepA.x;\n\n\tvType = type;\n\tif (type < 2.5 || 6.5 < type) {\n\t\tgl_Position = vec4(toPosition012(aPosition), 0.0, 1.0);\n\t\tvStepA = strokeWidth * general.zw;\n\t\tif (type < 1.5) {\n\t\t\tvStepB = toStepB01(aStepB);\n\t\t\tvLength = vec4(-1.0, 0.0, 0.0, -1.0);\n\t\t} else if (type < 2.5) {\n\t\t\tvStepB = toStepB2(aStepB, strokeWidth);\n\t\t\tvLength = vec4(-1.0, 0.0, 0.0, -1.0);\n\t\t} else {\n\t\t\tvStepB = toStepB01(aStepB);\n\t\t\tvLength = toLength7(type, strokeScaling, strokeWidthScale);\n\t\t}\n\t} else {\n\t\tfloat shift3 = 0.0;\n\t\tgl_Position = vec4(toPosition3(type, aPosition, aStepB.x, aStepB.w, strokeWidth, shift3), 0.0, 1.0);\n\t\tvStepA = toStepA3(type, strokeWidth);\n\t\tvStepB = vec4(0.0);\n\t\tvLength = toLength3(shift3, general.z, strokeScaling, strokeWidthScale);\n\t}\n\ttoColors(aColor, vColorFill, vColorStroke);\n\tvUv = aUv;\n}";
11
- var FRAGMENT_SHADER = "\nvarying mediump float vType;\nvarying mediump vec2 vStepA;\nvarying mediump vec4 vStepB;\nvarying mediump vec4 vLength;\nvarying mediump vec4 vColorFill;\nvarying mediump vec4 vColorStroke;\nvarying mediump vec2 vUv;\n\nuniform sampler2D sampler;\nuniform mediump float antialiasWeight;\n\nvec4 toColor0(in vec4 texture) {\n\tvec2 f = vec2(1.0) / vStepB.xy;\n\tvec2 c = vStepB.zw;\n\tvec2 awd = 0.5 * antialiasWeight * f;\n\tvec2 swd = vStepA * f;\n\tvec2 one = vec2(1.0);\n\tvec2 s0 = smoothstep(one - awd, one + awd, c);\n\tvec2 s1 = smoothstep(one - swd - awd, one - swd + awd, c);\n\tfloat s2 = max(s0.x, s0.y);\n\tfloat s3 = max(s1.x, s1.y);\n\n\treturn texture * (\n\t\tvColorStroke * (s3 - s2) +\n\t\tvColorFill * (1.0 - s3)\n\t);\n}\n\nvec4 toColor1(in vec4 texture) {\n\tvec2 d = vStepB.xy;\n\tvec2 c = vStepB.zw;\n\tvec2 awd = 0.5 * antialiasWeight / d;\n\tvec2 swd = vStepA / d;\n\tvec2 one = vec2(1.0);\n\tvec2 zero = vec2(0.0);\n\tfloat s0 = smoothstep(length(c/clamp(one + awd, zero, one)), length(c/clamp(one - awd, zero, one)), 1.0);\n\tfloat s1 = smoothstep(length(c/clamp(one - swd + awd, zero, one)), length(c/clamp(one - swd - awd, zero, one)), 1.0);\n\treturn texture * (\n\t\tvColorStroke * (s0 - s1) +\n\t\tvColorFill * s1\n\t);\n}\n\nvec4 toColor2(in vec4 texture) {\n\tvec2 p0 = vStepB.xy;\n\tvec2 p1 = vStepB.zw;\n\tvec2 d = vec2(dot(texture, vec4(1.0, 1.0/255.0, 1.0/255.0/255.0, 0.0)));\n\tvec2 s = smoothstep(p0 - p1, p0 + p1, d);\n\treturn vColorStroke * (s.y - s.x) + vColorFill * s.x;\n}\n\nfloat toLineStep(in vec4 parameters) {\n\tfloat l = parameters.x;\n\tfloat lp0 = parameters.y;\n\tfloat lp1 = parameters.z;\n\tfloat lt = parameters.w;\n\tfloat ld = 0.5 * antialiasWeight;\n\tfloat lm = mod(l, lp0 + lp1);\n\tfloat s0 = (0.0 < lp1 ? smoothstep(-ld, ld, lm) - smoothstep(lp0 - ld, lp0 + ld, lm) : 1.0);\n\tfloat s1 = (0.0 <= lt ? smoothstep(-ld, ld, l) - smoothstep(lt - ld, lt + ld, l) : 1.0);\n\treturn s0 * s1;\n}\n\nvec4 toColor3(in vec4 texture) {\n\tfloat c = vStepA.x;\n\tfloat awd = 0.5 * antialiasWeight / vStepA.y;\n\tfloat s0 = smoothstep(-awd, awd, c);\n\tfloat s1 = smoothstep(1.0 - awd, 1.0 + awd, c);\n\treturn texture * vColorStroke * (s0 - s1) * toLineStep(vLength);\n}\n\nvec4 toColor7(in vec4 texture) {\n\tfloat aw = 0.5 * antialiasWeight;\n\tfloat awd = aw * vStepB.x;\n\tfloat swd = vStepA.x * vStepB.x;\n\tfloat s0 = smoothstep(1.0 - awd, 1.0 + awd, vStepB.z);\n\tfloat s1 = smoothstep(1.0 - swd - awd, 1.0 - swd + awd, vStepB.z) * toLineStep(vLength);\n\tfloat s2 = smoothstep(-aw, +aw, vStepB.y);\n\tfloat s3 = smoothstep(-awd, 0.0, vStepB.z);\n\treturn texture * (\n\t\tvColorStroke * (s1 - s0) +\n\t\tvColorFill * (1.0 - s1) * s2 * s3\n\t);\n}\n\nvoid main(void) {\n\tvec4 texture = texture2D(sampler, vUv);\n\tif (vType < 0.5) {\n\t\tgl_FragColor = toColor0(texture);\n\t} else if (vType < 1.5) {\n\t\tgl_FragColor = toColor1(texture);\n\t} else if (vType < 2.5) {\n\t\tgl_FragColor = toColor2(texture);\n\t} else if (vType < 6.5) {\n\t\tgl_FragColor = toColor3(texture);\n\t} else {\n\t\tgl_FragColor = toColor7(texture);\n\t}\n}";
11
+ var FRAGMENT_SHADER = "\nvarying mediump float vType;\nvarying mediump vec2 vStepA;\nvarying mediump vec4 vStepB;\nvarying mediump vec4 vLength;\nvarying mediump vec4 vColorFill;\nvarying mediump vec4 vColorStroke;\nvarying mediump vec2 vUv;\n\nuniform sampler2D sampler;\nuniform mediump float antialiasWeight;\n\nvec4 toColor0(in vec4 texture) {\n\tvec2 f = vec2(1.0) / vStepB.xy;\n\tvec2 c = vStepB.zw;\n\tvec2 awd = 0.5 * antialiasWeight * f;\n\tvec2 swd = vStepA * f;\n\tvec2 one = vec2(1.0);\n\tvec2 s0 = smoothstep(one - awd, one + awd, c);\n\tvec2 s1 = smoothstep(one - swd - awd, one - swd + awd, c);\n\tfloat s2 = max(s0.x, s0.y);\n\tfloat s3 = max(s1.x, s1.y);\n\n\treturn texture * (\n\t\tvColorStroke * (s3 - s2) +\n\t\tvColorFill * (1.0 - s3)\n\t);\n}\n\nvec4 toColor1(in vec4 texture) {\n\tvec2 d = vStepB.xy;\n\tvec2 c = vStepB.zw;\n\tvec2 awd = 0.5 * antialiasWeight / d;\n\tvec2 swd = vStepA / d;\n\tvec2 one = vec2(1.0);\n\tvec2 zero = vec2(0.0);\n\tfloat s0 = smoothstep(length(c/clamp(one + awd, zero, one)), length(c/clamp(one - awd, zero, one)), 1.0);\n\tfloat s1 = smoothstep(length(c/clamp(one - swd + awd, zero, one)), length(c/clamp(one - swd - awd, zero, one)), 1.0);\n\treturn texture * (\n\t\tvColorStroke * (s0 - s1) +\n\t\tvColorFill * s1\n\t);\n}\n\nvec4 toColor2(in vec4 texture) {\n\tvec2 p0 = vStepB.xy;\n\tvec2 p1 = vStepB.zw;\n\tvec2 d = vec2(dot(texture, vec4(1.0, 1.0/255.0, 1.0/255.0/255.0, 0.0)));\n\tvec2 s = smoothstep(p0 - p1, p0 + p1, d);\n\treturn vColorStroke * (s.y - s.x) + vColorFill * s.x;\n}\n\nfloat toLineStep(in vec4 parameters) {\n\tfloat l = parameters.x;\n\tfloat lp0 = parameters.y;\n\tfloat lp1 = parameters.z;\n\tfloat lt = parameters.w;\n\tfloat ld = 0.5 * antialiasWeight;\n\tfloat lm = mod(l, lp0 + lp1);\n\tfloat s0 = (0.0 < lp1 ? smoothstep(-ld, ld, lm) - smoothstep(lp0 - ld, lp0 + ld, lm) : 1.0);\n\tfloat s1 = (0.0 <= lt ? smoothstep(-ld, ld, l) - smoothstep(lt - ld, lt + ld, l) : 1.0);\n\treturn s0 * s1;\n}\n\nvec4 toColor3(in vec4 texture) {\n\tfloat c = vStepA.x;\n\tfloat awd = 0.5 * antialiasWeight / vStepA.y;\n\tfloat s0 = smoothstep(-awd, awd, c);\n\tfloat s1 = smoothstep(1.0 - awd, 1.0 + awd, c);\n\treturn texture * vColorStroke * (s0 - s1) * toLineStep(vLength);\n}\n\nvec4 toColor7(in vec4 texture) {\n\tfloat aw = 0.5 * antialiasWeight;\n\tfloat awd = aw * vStepB.x;\n\tfloat swd = vStepA.x * vStepB.x;\n\tfloat s0 = smoothstep(1.0 - awd, 1.0 + awd, vStepB.z);\n\tfloat s1 = smoothstep(1.0 - swd - awd, 1.0 - swd + awd, vStepB.z) * toLineStep(vLength);\n\tfloat s2 = smoothstep(-aw, +aw, vStepB.y);\n\tfloat s3 = smoothstep(-awd, 0.0, vStepB.z);\n\treturn texture * (\n\t\tvColorStroke * (s1 - s0) +\n\t\tvColorFill * (1.0 - s1) * (1.0 - s0) * s2 * s3\n\t);\n}\n\nvoid main(void) {\n\tvec4 texture = texture2D(sampler, vUv);\n\tif (vType < 0.5) {\n\t\tgl_FragColor = toColor0(texture);\n\t} else if (vType < 1.5) {\n\t\tgl_FragColor = toColor1(texture);\n\t} else if (vType < 2.5) {\n\t\tgl_FragColor = toColor2(texture);\n\t} else if (vType < 6.5) {\n\t\tgl_FragColor = toColor3(texture);\n\t} else {\n\t\tgl_FragColor = toColor7(texture);\n\t}\n}";
12
12
  var EShapeRenderer = /** @class */ (function (_super) {
13
13
  __extends(EShapeRenderer, _super);
14
14
  function EShapeRenderer(renderer) {
@@ -1 +1 @@
1
- {"version":3,"file":"e-shape-renderer.js","sourceRoot":"","sources":["../../../../src/main/typescript/wcardinal/ui/shape/e-shape-renderer.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAEN,WAAW,EACX,cAAc,EAEd,MAAM,EAEN,KAAK,EACL,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA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C,CAAC;gBACpD,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACrB,aAAa,GAAG,KAAK,CAAC;YACvB,CAAC;YACD,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,eAAe,EAAE,aAAa,CAAC,EAAE,CAAC;gBAC7D,UAAU,GAAG,CAAC,CAAC;gBACf,EAAE,IAAI,CAAC,CAAC;YACT,CAAC;iBAAM,CAAC;gBACP,UAAU,GAAG,MAAM,CAAC,mBAAmB,CAAC;gBACxC,IAAI,UAAU,IAAI,aAAa,EAAE,CAAC;oBACjC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,cAAc,CAAC,GAAG,cAAc,CAAC;oBACrE,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;gBAClD,CAAC;qBAAM,CAAC;oBACP,mBAAmB;oBACnB,MAAM;gBACP,CAAC;YACF,CAAC;QACF,CAAC;QAED,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YACzB,KAAK,IAAI,EAAE,GAAG,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC;gBAC5D,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;YACvB,CAAC;YACD,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC;QACrB,CAAC;IACF,CAAC;IAhOM,qBAAM,GAAkB,IAAI,CAAC;IAiOrC,qBAAC;CAAA,AAlOD,CAAoC,cAAc,GAkOjD;SAlOY,cAAc","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n\tBaseTexture,\n\tBLEND_MODES,\n\tObjectRenderer,\n\tRenderer,\n\tShader,\n\tTexture,\n\tutils\n} from \"pixi.js\";\nimport { DynamicAtlas } from \"../util/dynamic-atlas\";\nimport { DynamicAtlasItemImage } from \"../util/dynamic-atlas-item-image\";\nimport { DynamicSDFFontAtlases } from \"../util/dynamic-sdf-font-atlases\";\nimport { EShape } from \"./e-shape\";\nimport { EShapeBuffer } from \"./e-shape-buffer\";\nimport { EShapeContainer } from \"./e-shape-container\";\nimport { EShapeRendererIterator } from \"./e-shape-renderer-iterator\";\n\nconst VERTEX_SHADER = `\nattribute highp vec2 aPosition;\nattribute highp vec2 aStepA;\nattribute highp vec4 aStepB;\nattribute highp vec3 aColor;\nattribute highp vec2 aUv;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mediump float shapeScale;\nuniform mediump float antialiasWeight;\n\nvarying mediump float vType;\nvarying mediump vec2 vStepA;\nvarying mediump vec4 vStepB;\nvarying mediump vec4 vLength;\nvarying mediump vec4 vColorFill;\nvarying mediump vec4 vColorStroke;\nvarying mediump vec2 vUv;\n\nvec2 toInverse(in vec2 v) {\n\treturn vec2(-v.y, v.x);\n}\n\nvec4 toGeneral(in float v) {\n\tvec4 c = vec4(1.0, 1.0/64.0, 1.0/64.0/64.0, 1.0/64.0/64.0/64.0) * v;\n\tc -= fract(c);\n\tc -= c.yzwx * vec4(64.0, 64.0, 64.0, 0.0);\n\treturn c;\n}\n\nfloat toStrokeWidthScale(in float scale) {\n\treturn (\n\t\tscale == 3.0 || scale == 7.0 ?\n\t\tshapeScale : (\n\t\t\tscale == 1.0 || scale == 5.0 ?\n\t\t\tmin(1.0, shapeScale) : (\n\t\t\t\tscale == 2.0 || scale == 6.0 ?\n\t\t\t\tmax(1.0, shapeScale) : 1.0\n\t\t\t)\n\t\t)\n\t);\n}\n\nvec2 toUnpackedClippings(in float v) {\n\tvec2 c = vec2(1.0, 1.0/1024.0) * v;\n\tc -= fract(c);\n\tc -= c.yx * vec2(1024.0, 0.0);\n\tc /= vec2(852.5, 852.5);\n\tc -= vec2(0.1, 0.1);\n\treturn c;\n}\n\nvec2 toUnpackedAlphas(in float v) {\n\tvec2 c = vec2(1.0, 1.0/1024.0) * v;\n\tc -= fract(c);\n\tc -= c.yx * vec2(1024.0, 0.0);\n\tc /= vec2(1023.0, 1023.0);\n\treturn c;\n}\n\nvec3 toUnpackedF3x256(in float v) {\n\tvec3 c = vec3(1.0, 1.0/256.0, 1.0/256.0/256.0) * v;\n\tc -= fract(c);\n\tc -= c.yzx * vec3(256.0, 256.0, 0.0);\n\tc /= 255.0;\n\treturn c;\n}\n\nvec2 toPosition012(in vec2 v) {\n\treturn (projectionMatrix * translationMatrix * vec3(v, 1.0)).xy;\n}\n\nvec4 toStepB01(in vec4 sb) {\n\treturn vec4(sb.xy, toUnpackedClippings(sb.z));\n}\n\nvec4 toStepB2(in vec4 sb, in float strokeWidth) {\n\tfloat x = min(0.4, 0.4 / 12.0 * sb.x * antialiasWeight);\n\tfloat w = clamp(strokeWidth, 0.0, 1.0) * 0.4;\n\tfloat p = w * sb.y + sb.z;\n\tfloat y = 0.5 - p;\n\tfloat z = 0.5 - p - w;\n\treturn vec4(y, z, y - max(0.01, y - x), z - max(0.01, z - x));\n}\n\nvec2 toPosition3(in float type, in vec2 p, in float npacked, in float length, in float strokeWidth, out float shift) {\n\tvec3 t = vec3(1.0, 1.0/1024.0, 1.0/1024.0/1024.0) * npacked;\n\tt -= fract(t);\n\tt -= t.yzx * vec3(1024.0, 1024.0, 0.0);\n\tt *= vec3(1.0/511.5, 1.0/511.5, 1.0);\n\tt -= vec3(1.0, 1.0, 0.0);\n\tvec2 n0 = vec2(t.x, ((0.5 < t.z && t.z < 1.5) || 2.5 < t.z ? +1.0 : -1.0) * sqrt(max(0.0, 1.0 - t.x * t.x)));\n\tvec2 n1 = vec2(t.y, (1.5 < t.z ? +1.0 : -1.0) * sqrt(max(0.0, 1.0 - t.y * t.y)));\n\n\tvec2 n0i = toInverse(n0);\n\tvec2 n1i = toInverse(n1);\n\tfloat direction = sign(4.5 - type);\n\n\t// Offset\n\tfloat cross = dot(n0i, n1);\n\tbool bcross = 0.00001 < abs(cross);\n\tfloat crossi = (bcross ? 1.0 / cross : 0.0);\n\tfloat b = dot(n1 - n0, n0) * crossi;\n\tfloat offsetSize = direction * strokeWidth * 0.5;\n\tvec2 offset = n1 + n1i * b;\n\n\t// Miter\n\tvec2 pmiter = p + offsetSize * offset;\n\tfloat miterAngle0 = dot( n0i, offsetSize * offset - length * n0i );\n\tfloat miterAngle1 = dot( n1i, offsetSize * offset + length * n1i );\n\tfloat miterLength = dot( offset, offset );\n\tfloat miterSide = direction * cross;\n\n\t// Bevel\n\tvec2 n = (type == 4.0 || type == 6.0 ? n1 : n0);\n\tvec2 pbevel = p + offsetSize * n;\n\n\t//\n\tvec2 presult = (\n\t\t0.0 <= miterSide ?\n\t\t(miterAngle0 < 0.0 && 0.0 <= miterAngle1 && bcross ? pmiter : pbevel) :\n\t\t(miterLength < 6.0 && bcross ? pmiter : pbevel)\n\t);\n\tvec2 ni = (type == 4.0 || type == 6.0 ? n1i : n0i);\n\tshift = dot(ni, p - presult);\n\treturn toPosition012(presult);\n}\n\nvec2 toStepA3(in float type, in float strokeWidth) {\n\treturn vec2(type < 4.5 ? 1.0 : 0.0, strokeWidth);\n}\n\nfloat toDotWidth(in float strokeScaling, in float strokeWidthScale) {\n\treturn aStepA.x * (\n\t\tstrokeScaling == 4.0 || strokeScaling == 5.0 ||\n\t\tstrokeScaling == 6.0 || strokeScaling == 7.0 ?\n\t\tstrokeWidthScale : 1.0\n\t);\n}\n\nvec2 toDotPattern(in float dash) {\n\treturn (dash < 0.5 ?\n\t\tvec2(1.0, 0.0) :\n\t\t(dash < 3.5 ?\n\t\t\t(dash < 1.5 ?\n\t\t\t\tvec2(1.0, 1.0) :\n\t\t\t\t(2.5 < dash ?\n\t\t\t\t\tvec2(1.0, 2.0) :\n\t\t\t\t\tvec2(1.0, 0.5)\n\t\t\t\t)\n\t\t\t) :\n\t\t\t(dash < 4.5 ?\n\t\t\t\tvec2(2.0, 1.0) :\n\t\t\t\t(5.5 < dash ?\n\t\t\t\t\tvec2(2.0, 2.0) :\n\t\t\t\t\tvec2(2.0, 0.5)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t);\n}\n\nvec4 toLength3(in float shift, in float dash, in float strokeScaling, in float strokeWidthScale) {\n\tfloat width = toDotWidth(strokeScaling, strokeWidthScale);\n\tvec2 pattern = toDotPattern(dash);\n\treturn vec4(aStepB.y + shift, pattern.x * width, pattern.y * width, aStepB.z);\n}\n\nvec4 toLength7(in float type, in float strokeScaling, in float strokeWidthScale) {\n\tfloat width = toDotWidth(strokeScaling, strokeWidthScale);\n\tvec2 pattern = toDotPattern(type - 7.0);\n\treturn vec4(aStepB.w, pattern.x * width, pattern.y * width, -1.0);\n}\n\nvoid toColors(in vec3 source, out vec4 fillColor, out vec4 strokeColor) {\n\tvec2 a = toUnpackedAlphas(source.z);\n\tfillColor.xyz = toUnpackedF3x256(source.x).zyx * a.x;\n\tfillColor.w = a.x;\n\tstrokeColor.xyz = toUnpackedF3x256(source.y).zyx * a.y;\n\tstrokeColor.w = a.y;\n}\n\nvoid main(void) {\n\tvec4 general = toGeneral(aStepA.y);\n\tfloat type = general.x;\n\tfloat strokeScaling = general.y;\n\tfloat strokeWidthScale = toStrokeWidthScale(strokeScaling);\n\tfloat strokeWidth = strokeWidthScale * aStepA.x;\n\n\tvType = type;\n\tif (type < 2.5 || 6.5 < type) {\n\t\tgl_Position = vec4(toPosition012(aPosition), 0.0, 1.0);\n\t\tvStepA = strokeWidth * general.zw;\n\t\tif (type < 1.5) {\n\t\t\tvStepB = toStepB01(aStepB);\n\t\t\tvLength = vec4(-1.0, 0.0, 0.0, -1.0);\n\t\t} else if (type < 2.5) {\n\t\t\tvStepB = toStepB2(aStepB, strokeWidth);\n\t\t\tvLength = vec4(-1.0, 0.0, 0.0, -1.0);\n\t\t} else {\n\t\t\tvStepB = toStepB01(aStepB);\n\t\t\tvLength = toLength7(type, strokeScaling, strokeWidthScale);\n\t\t}\n\t} else {\n\t\tfloat shift3 = 0.0;\n\t\tgl_Position = vec4(toPosition3(type, aPosition, aStepB.x, aStepB.w, strokeWidth, shift3), 0.0, 1.0);\n\t\tvStepA = toStepA3(type, strokeWidth);\n\t\tvStepB = vec4(0.0);\n\t\tvLength = toLength3(shift3, general.z, strokeScaling, strokeWidthScale);\n\t}\n\ttoColors(aColor, vColorFill, vColorStroke);\n\tvUv = aUv;\n}`;\n\nconst FRAGMENT_SHADER = `\nvarying mediump float vType;\nvarying mediump vec2 vStepA;\nvarying mediump vec4 vStepB;\nvarying mediump vec4 vLength;\nvarying mediump vec4 vColorFill;\nvarying mediump vec4 vColorStroke;\nvarying mediump vec2 vUv;\n\nuniform sampler2D sampler;\nuniform mediump float antialiasWeight;\n\nvec4 toColor0(in vec4 texture) {\n\tvec2 f = vec2(1.0) / vStepB.xy;\n\tvec2 c = vStepB.zw;\n\tvec2 awd = 0.5 * antialiasWeight * f;\n\tvec2 swd = vStepA * f;\n\tvec2 one = vec2(1.0);\n\tvec2 s0 = smoothstep(one - awd, one + awd, c);\n\tvec2 s1 = smoothstep(one - swd - awd, one - swd + awd, c);\n\tfloat s2 = max(s0.x, s0.y);\n\tfloat s3 = max(s1.x, s1.y);\n\n\treturn texture * (\n\t\tvColorStroke * (s3 - s2) +\n\t\tvColorFill * (1.0 - s3)\n\t);\n}\n\nvec4 toColor1(in vec4 texture) {\n\tvec2 d = vStepB.xy;\n\tvec2 c = vStepB.zw;\n\tvec2 awd = 0.5 * antialiasWeight / d;\n\tvec2 swd = vStepA / d;\n\tvec2 one = vec2(1.0);\n\tvec2 zero = vec2(0.0);\n\tfloat s0 = smoothstep(length(c/clamp(one + awd, zero, one)), length(c/clamp(one - awd, zero, one)), 1.0);\n\tfloat s1 = smoothstep(length(c/clamp(one - swd + awd, zero, one)), length(c/clamp(one - swd - awd, zero, one)), 1.0);\n\treturn texture * (\n\t\tvColorStroke * (s0 - s1) +\n\t\tvColorFill * s1\n\t);\n}\n\nvec4 toColor2(in vec4 texture) {\n\tvec2 p0 = vStepB.xy;\n\tvec2 p1 = vStepB.zw;\n\tvec2 d = vec2(dot(texture, vec4(1.0, 1.0/255.0, 1.0/255.0/255.0, 0.0)));\n\tvec2 s = smoothstep(p0 - p1, p0 + p1, d);\n\treturn vColorStroke * (s.y - s.x) + vColorFill * s.x;\n}\n\nfloat toLineStep(in vec4 parameters) {\n\tfloat l = parameters.x;\n\tfloat lp0 = parameters.y;\n\tfloat lp1 = parameters.z;\n\tfloat lt = parameters.w;\n\tfloat ld = 0.5 * antialiasWeight;\n\tfloat lm = mod(l, lp0 + lp1);\n\tfloat s0 = (0.0 < lp1 ? smoothstep(-ld, ld, lm) - smoothstep(lp0 - ld, lp0 + ld, lm) : 1.0);\n\tfloat s1 = (0.0 <= lt ? smoothstep(-ld, ld, l) - smoothstep(lt - ld, lt + ld, l) : 1.0);\n\treturn s0 * s1;\n}\n\nvec4 toColor3(in vec4 texture) {\n\tfloat c = vStepA.x;\n\tfloat awd = 0.5 * antialiasWeight / vStepA.y;\n\tfloat s0 = smoothstep(-awd, awd, c);\n\tfloat s1 = smoothstep(1.0 - awd, 1.0 + awd, c);\n\treturn texture * vColorStroke * (s0 - s1) * toLineStep(vLength);\n}\n\nvec4 toColor7(in vec4 texture) {\n\tfloat aw = 0.5 * antialiasWeight;\n\tfloat awd = aw * vStepB.x;\n\tfloat swd = vStepA.x * vStepB.x;\n\tfloat s0 = smoothstep(1.0 - awd, 1.0 + awd, vStepB.z);\n\tfloat s1 = smoothstep(1.0 - swd - awd, 1.0 - swd + awd, vStepB.z) * toLineStep(vLength);\n\tfloat s2 = smoothstep(-aw, +aw, vStepB.y);\n\tfloat s3 = smoothstep(-awd, 0.0, vStepB.z);\n\treturn texture * (\n\t\tvColorStroke * (s1 - s0) +\n\t\tvColorFill * (1.0 - s1) * s2 * s3\n\t);\n}\n\nvoid main(void) {\n\tvec4 texture = texture2D(sampler, vUv);\n\tif (vType < 0.5) {\n\t\tgl_FragColor = toColor0(texture);\n\t} else if (vType < 1.5) {\n\t\tgl_FragColor = toColor1(texture);\n\t} else if (vType < 2.5) {\n\t\tgl_FragColor = toColor2(texture);\n\t} else if (vType < 6.5) {\n\t\tgl_FragColor = toColor3(texture);\n\t} else {\n\t\tgl_FragColor = toColor7(texture);\n\t}\n}`;\n\nexport class EShapeRenderer extends ObjectRenderer {\n\tstatic SHADER: Shader | null = null;\n\n\tprotected _shader: Shader | null;\n\tprotected _iterator: EShapeRendererIterator;\n\tprotected _bufferSizeMax: number;\n\n\tconstructor(renderer: Renderer) {\n\t\tsuper(renderer);\n\t\tEShapeRenderer.SHADER =\n\t\t\tEShapeRenderer.SHADER || Shader.from(VERTEX_SHADER, FRAGMENT_SHADER);\n\t\tthis._shader = EShapeRenderer.SHADER;\n\t\tthis._iterator = new EShapeRendererIterator();\n\t\tthis._bufferSizeMax = this.getBufferSizeMax(renderer);\n\t}\n\n\tprotected getBufferSizeMax(renderer: Renderer): number {\n\t\tconst context = renderer.context;\n\t\tconst extensions = context.extensions as any;\n\t\tif (1 < context.webGLVersion || !!extensions.uint32ElementIndex) {\n\t\t\treturn 1431655765; // 2^32 / 3\n\t\t}\n\t\treturn 21845; // 2^16 / 3\n\t}\n\n\tupdateAtlas(\n\t\tshape: EShape,\n\t\tatlas: DynamicAtlas,\n\t\tfontAtlases: DynamicSDFFontAtlases,\n\t\tdefaultTexture: Texture,\n\t\tbaseTexture: BaseTexture\n\t): void {\n\t\t// Texture\n\t\t// Do not access the shape.image.source here.\n\t\t// It slows down the rendering speed significantly.\n\t\tconst image = shape.image;\n\t\tif (image != null) {\n\t\t\tconst textureItem = atlas.get(image.url);\n\t\t\tif (textureItem != null) {\n\t\t\t\tshape.texture = textureItem.texture;\n\t\t\t} else {\n\t\t\t\tconst newTextureItem = new DynamicAtlasItemImage(\n\t\t\t\t\timage.url,\n\t\t\t\t\timage.width,\n\t\t\t\t\timage.height,\n\t\t\t\t\timage.source,\n\t\t\t\t\tbaseTexture\n\t\t\t\t);\n\t\t\t\tshape.texture = newTextureItem.texture;\n\t\t\t\tatlas.set(newTextureItem.id, newTextureItem);\n\t\t\t}\n\t\t} else {\n\t\t\tshape.texture = defaultTexture;\n\t\t}\n\n\t\t// Font texture atlas\n\t\tconst text = shape.text;\n\t\tconst textCharacters = text.characters;\n\t\tif (0 < textCharacters.length) {\n\t\t\tfontAtlases.add(text.family, textCharacters, text.nacharacters);\n\t\t}\n\t}\n\n\tupdateAtlases(\n\t\tshapes: EShape[],\n\t\tatlas: DynamicAtlas,\n\t\tfontAtlases: DynamicSDFFontAtlases,\n\t\tdefaultTexture: Texture,\n\t\tbaseTexture: BaseTexture\n\t): void {\n\t\tfor (let i = 0, imax = shapes.length; i < imax; ++i) {\n\t\t\tconst shape = shapes[i];\n\t\t\tthis.updateAtlas(shape, atlas, fontAtlases, defaultTexture, baseTexture);\n\t\t\tconst children = shape.children;\n\t\t\tfor (let j = 0, jmax = children.length; j < jmax; ++j) {\n\t\t\t\tconst child = children[j];\n\t\t\t\tthis.updateAtlas(child, atlas, fontAtlases, defaultTexture, baseTexture);\n\t\t\t\tthis.updateAtlases(child.children, atlas, fontAtlases, defaultTexture, baseTexture);\n\t\t\t}\n\t\t}\n\t}\n\n\tupdateFontAtlas(\n\t\tshape: EShape,\n\t\tatlas: DynamicAtlas,\n\t\tfontAtlases: DynamicSDFFontAtlases,\n\t\tdefaultTexture: Texture\n\t): void {\n\t\tconst text = shape.text;\n\t\tconst fontAtlas = fontAtlases.get(text.family);\n\t\tif (fontAtlas != null) {\n\t\t\tconst textureItem = atlas.get(fontAtlas.id);\n\t\t\tif (textureItem != null) {\n\t\t\t\ttext.atlas = fontAtlas;\n\t\t\t\ttext.texture = textureItem.texture;\n\t\t\t} else {\n\t\t\t\ttext.atlas = undefined;\n\t\t\t\ttext.texture = defaultTexture;\n\t\t\t}\n\t\t} else {\n\t\t\ttext.atlas = undefined;\n\t\t\ttext.texture = defaultTexture;\n\t\t}\n\t}\n\n\tupdateFontAtlases(\n\t\tshapes: EShape[],\n\t\tatlas: DynamicAtlas,\n\t\tfontAtlases: DynamicSDFFontAtlases,\n\t\tdefaultTexture: Texture\n\t): void {\n\t\tfor (let i = 0, imax = shapes.length; i < imax; ++i) {\n\t\t\tconst shape = shapes[i];\n\t\t\tthis.updateFontAtlas(shape, atlas, fontAtlases, defaultTexture);\n\t\t\tconst children = shape.children;\n\t\t\tfor (let j = 0, jmax = children.length; j < jmax; ++j) {\n\t\t\t\tconst child = children[j];\n\t\t\t\tthis.updateFontAtlas(child, atlas, fontAtlases, defaultTexture);\n\t\t\t\tthis.updateFontAtlases(child.children, atlas, fontAtlases, defaultTexture);\n\t\t\t}\n\t\t}\n\t}\n\n\trender_(\n\t\tcontainer: EShapeContainer,\n\t\tshape: EShape | null,\n\t\tshapes: EShape[],\n\t\tisDirty: boolean\n\t): void {\n\t\tconst renderer = this.renderer;\n\t\tconst shader = this._shader;\n\n\t\tif (shader != null && (shape != null || 0 < shapes.length)) {\n\t\t\tconst resolution = renderer.resolution;\n\t\t\tconst buffers = container.getBuffers();\n\t\t\tconst antialiasWeight = container.getAntialiasWeight();\n\n\t\t\t// Update textures\n\t\t\tif (isDirty) {\n\t\t\t\t// Atlases\n\t\t\t\tconst atlas = container.getAtlas(resolution);\n\t\t\t\tconst fontAtlases = container.getFontAtlases();\n\t\t\t\tatlas.begin();\n\t\t\t\tfontAtlases.begin();\n\t\t\t\tconst defaultTexture = atlas.getDefaultTexture();\n\t\t\t\tconst baseTexture: BaseTexture = atlas.getBaseTexture();\n\t\t\t\tthis.updateAtlases(shapes, atlas, fontAtlases, defaultTexture, baseTexture);\n\t\t\t\tfontAtlases.end();\n\t\t\t\tfontAtlases.update(atlas);\n\t\t\t\tthis.updateFontAtlases(shapes, atlas, fontAtlases, defaultTexture);\n\t\t\t\tatlas.end();\n\t\t\t\tatlas.repack();\n\n\t\t\t\t// Update buffers\n\t\t\t\tthis.updateBuffers(shape, shapes, buffers, renderer, antialiasWeight);\n\t\t\t}\n\n\t\t\t// Render buffers\n\t\t\tshader.uniforms.shapeScale = container.toShapeScale();\n\t\t\tshader.uniforms.antialiasWeight = container.toPixelScale(resolution) * antialiasWeight;\n\t\t\tshader.uniforms.translationMatrix = container.worldTransform.toArray(true);\n\t\t\trenderer.shader.bind(shader, false);\n\t\t\trenderer.state.setBlendMode(utils.correctBlendMode(BLEND_MODES.NORMAL, true));\n\t\t\tconst buffersLength = buffers.length;\n\t\t\tif (1 < buffersLength) {\n\t\t\t\tfor (let i = 0; i < buffersLength; ++i) {\n\t\t\t\t\tbuffers[i].upload();\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (let i = 0; i < buffersLength; ++i) {\n\t\t\t\tbuffers[i].render(shader);\n\t\t\t}\n\t\t}\n\t}\n\n\tupdateBuffers(\n\t\tshape: EShape | null,\n\t\tshapes: EShape[],\n\t\tbuffers: EShapeBuffer[],\n\t\trenderer: Renderer,\n\t\tantialiasWeight: number\n\t): void {\n\t\tconst iterator = this._iterator;\n\t\titerator.reset(shape, shapes);\n\n\t\tlet ib = 0;\n\t\tlet bufferSize = 0;\n\t\tconst bufferSizeBase = 5000;\n\t\tconst bufferSizeMax = this._bufferSizeMax;\n\t\twhile (iterator.get() != null) {\n\t\t\tlet buffer: EShapeBuffer | null = null;\n\t\t\tlet noMoreThanOne = false;\n\t\t\tif (0 < bufferSize) {\n\t\t\t\tbuffer = new EShapeBuffer(bufferSize, renderer);\n\t\t\t\tbuffers.splice(ib, 0, buffer);\n\t\t\t\tnoMoreThanOne = true;\n\t\t\t} else if (ib < buffers.length) {\n\t\t\t\tbuffer = buffers[ib];\n\t\t\t\tnoMoreThanOne = false;\n\t\t\t} else {\n\t\t\t\tbuffer = new EShapeBuffer(bufferSizeBase, renderer);\n\t\t\t\tbuffers.push(buffer);\n\t\t\t\tnoMoreThanOne = false;\n\t\t\t}\n\t\t\tif (buffer.update(iterator, antialiasWeight, noMoreThanOne)) {\n\t\t\t\tbufferSize = 0;\n\t\t\t\tib += 1;\n\t\t\t} else {\n\t\t\t\tbufferSize = buffer.indexCountRequested;\n\t\t\t\tif (bufferSize <= bufferSizeMax) {\n\t\t\t\t\tbufferSize = Math.ceil(bufferSize / bufferSizeBase) * bufferSizeBase;\n\t\t\t\t\tbufferSize = Math.min(bufferSize, bufferSizeMax);\n\t\t\t\t} else {\n\t\t\t\t\t// No way to render\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (ib < buffers.length) {\n\t\t\tfor (let jb = ib, ibmax = buffers.length; jb < ibmax; ++jb) {\n\t\t\t\tbuffers[jb].destroy();\n\t\t\t}\n\t\t\tbuffers.length = ib;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"e-shape-renderer.js","sourceRoot":"","sources":["../../../../src/main/typescript/wcardinal/ui/shape/e-shape-renderer.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAEN,WAAW,EACX,cAAc,EAEd,MAAM,EAEN,KAAK,EACL,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,IAAM,aAAa,GAAG,guMAqNpB,CAAC;AAEH,IAAM,eAAe,GAAG,yiGAmGtB,CAAC;AAEH;IAAoC,kCAAc;IAOjD,wBAAY,QAAkB;QAC7B,YAAA,MAAK,YAAC,QAAQ,CAAC,SAAC;QAChB,cAAc,CAAC,MAAM;YACpB,cAAc,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;QACtE,KAAI,CAAC,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC;QACrC,KAAI,CAAC,SAAS,GAAG,IAAI,sBAAsB,EAAE,CAAC;QAC9C,KAAI,CAAC,cAAc,GAAG,KAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;;IACvD,CAAC;IAES,yCAAgB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E,aAAa,CAAC,CAAC;gBAClD,CAAC;qBAAM,CAAC;oBACP,mBAAmB;oBACnB,MAAM;gBACP,CAAC;YACF,CAAC;QACF,CAAC;QAED,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;YACzB,KAAK,IAAI,EAAE,GAAG,EAAE,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,GAAG,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC;gBAC5D,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;YACvB,CAAC;YACD,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC;QACrB,CAAC;IACF,CAAC;IAhOM,qBAAM,GAAkB,IAAI,CAAC;IAiOrC,qBAAC;CAAA,AAlOD,CAAoC,cAAc,GAkOjD;SAlOY,cAAc","sourcesContent":["/*\n * Copyright (C) 2019 Toshiba Corporation\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport {\n\tBaseTexture,\n\tBLEND_MODES,\n\tObjectRenderer,\n\tRenderer,\n\tShader,\n\tTexture,\n\tutils\n} from \"pixi.js\";\nimport { DynamicAtlas } from \"../util/dynamic-atlas\";\nimport { DynamicAtlasItemImage } from \"../util/dynamic-atlas-item-image\";\nimport { DynamicSDFFontAtlases } from \"../util/dynamic-sdf-font-atlases\";\nimport { EShape } from \"./e-shape\";\nimport { EShapeBuffer } from \"./e-shape-buffer\";\nimport { EShapeContainer } from \"./e-shape-container\";\nimport { EShapeRendererIterator } from \"./e-shape-renderer-iterator\";\n\nconst VERTEX_SHADER = `\nattribute highp vec2 aPosition;\nattribute highp vec2 aStepA;\nattribute highp vec4 aStepB;\nattribute highp vec3 aColor;\nattribute highp vec2 aUv;\n\nuniform mat3 projectionMatrix;\nuniform mat3 translationMatrix;\nuniform mediump float shapeScale;\nuniform mediump float antialiasWeight;\n\nvarying mediump float vType;\nvarying mediump vec2 vStepA;\nvarying mediump vec4 vStepB;\nvarying mediump vec4 vLength;\nvarying mediump vec4 vColorFill;\nvarying mediump vec4 vColorStroke;\nvarying mediump vec2 vUv;\n\nvec2 toInverse(in vec2 v) {\n\treturn vec2(-v.y, v.x);\n}\n\nvec4 toGeneral(in float v) {\n\tvec4 c = vec4(1.0, 1.0/64.0, 1.0/64.0/64.0, 1.0/64.0/64.0/64.0) * v;\n\tc -= fract(c);\n\tc -= c.yzwx * vec4(64.0, 64.0, 64.0, 0.0);\n\treturn c;\n}\n\nfloat toStrokeWidthScale(in float scale) {\n\treturn (\n\t\tscale == 3.0 || scale == 7.0 ?\n\t\tshapeScale : (\n\t\t\tscale == 1.0 || scale == 5.0 ?\n\t\t\tmin(1.0, shapeScale) : (\n\t\t\t\tscale == 2.0 || scale == 6.0 ?\n\t\t\t\tmax(1.0, shapeScale) : 1.0\n\t\t\t)\n\t\t)\n\t);\n}\n\nvec2 toUnpackedClippings(in float v) {\n\tvec2 c = vec2(1.0, 1.0/1024.0) * v;\n\tc -= fract(c);\n\tc -= c.yx * vec2(1024.0, 0.0);\n\tc /= vec2(852.5, 852.5);\n\tc -= vec2(0.1, 0.1);\n\treturn c;\n}\n\nvec2 toUnpackedAlphas(in float v) {\n\tvec2 c = vec2(1.0, 1.0/1024.0) * v;\n\tc -= fract(c);\n\tc -= c.yx * vec2(1024.0, 0.0);\n\tc /= vec2(1023.0, 1023.0);\n\treturn c;\n}\n\nvec3 toUnpackedF3x256(in float v) {\n\tvec3 c = vec3(1.0, 1.0/256.0, 1.0/256.0/256.0) * v;\n\tc -= fract(c);\n\tc -= c.yzx * vec3(256.0, 256.0, 0.0);\n\tc /= 255.0;\n\treturn c;\n}\n\nvec2 toPosition012(in vec2 v) {\n\treturn (projectionMatrix * translationMatrix * vec3(v, 1.0)).xy;\n}\n\nvec4 toStepB01(in vec4 sb) {\n\treturn vec4(sb.xy, toUnpackedClippings(sb.z));\n}\n\nvec4 toStepB2(in vec4 sb, in float strokeWidth) {\n\tfloat x = min(0.4, 0.4 / 12.0 * sb.x * antialiasWeight);\n\tfloat w = clamp(strokeWidth, 0.0, 1.0) * 0.4;\n\tfloat p = w * sb.y + sb.z;\n\tfloat y = 0.5 - p;\n\tfloat z = 0.5 - p - w;\n\treturn vec4(y, z, y - max(0.01, y - x), z - max(0.01, z - x));\n}\n\nvec2 toPosition3(in float type, in vec2 p, in float npacked, in float length, in float strokeWidth, out float shift) {\n\tvec3 t = vec3(1.0, 1.0/1024.0, 1.0/1024.0/1024.0) * npacked;\n\tt -= fract(t);\n\tt -= t.yzx * vec3(1024.0, 1024.0, 0.0);\n\tt *= vec3(1.0/511.5, 1.0/511.5, 1.0);\n\tt -= vec3(1.0, 1.0, 0.0);\n\tvec2 n0 = vec2(t.x, ((0.5 < t.z && t.z < 1.5) || 2.5 < t.z ? +1.0 : -1.0) * sqrt(max(0.0, 1.0 - t.x * t.x)));\n\tvec2 n1 = vec2(t.y, (1.5 < t.z ? +1.0 : -1.0) * sqrt(max(0.0, 1.0 - t.y * t.y)));\n\n\tvec2 n0i = toInverse(n0);\n\tvec2 n1i = toInverse(n1);\n\tfloat direction = sign(4.5 - type);\n\n\t// Offset\n\tfloat cross = dot(n0i, n1);\n\tbool bcross = 0.00001 < abs(cross);\n\tfloat crossi = (bcross ? 1.0 / cross : 0.0);\n\tfloat b = dot(n1 - n0, n0) * crossi;\n\tfloat offsetSize = direction * strokeWidth * 0.5;\n\tvec2 offset = n1 + n1i * b;\n\n\t// Miter\n\tvec2 pmiter = p + offsetSize * offset;\n\tfloat miterAngle0 = dot( n0i, offsetSize * offset - length * n0i );\n\tfloat miterAngle1 = dot( n1i, offsetSize * offset + length * n1i );\n\tfloat miterLength = dot( offset, offset );\n\tfloat miterSide = direction * cross;\n\n\t// Bevel\n\tvec2 n = (type == 4.0 || type == 6.0 ? n1 : n0);\n\tvec2 pbevel = p + offsetSize * n;\n\n\t//\n\tvec2 presult = (\n\t\t0.0 <= miterSide ?\n\t\t(miterAngle0 < 0.0 && 0.0 <= miterAngle1 && bcross ? pmiter : pbevel) :\n\t\t(miterLength < 6.0 && bcross ? pmiter : pbevel)\n\t);\n\tvec2 ni = (type == 4.0 || type == 6.0 ? n1i : n0i);\n\tshift = dot(ni, p - presult);\n\treturn toPosition012(presult);\n}\n\nvec2 toStepA3(in float type, in float strokeWidth) {\n\treturn vec2(type < 4.5 ? 1.0 : 0.0, strokeWidth);\n}\n\nfloat toDotWidth(in float strokeScaling, in float strokeWidthScale) {\n\treturn aStepA.x * (\n\t\tstrokeScaling == 4.0 || strokeScaling == 5.0 ||\n\t\tstrokeScaling == 6.0 || strokeScaling == 7.0 ?\n\t\tstrokeWidthScale : 1.0\n\t);\n}\n\nvec2 toDotPattern(in float dash) {\n\treturn (dash < 0.5 ?\n\t\tvec2(1.0, 0.0) :\n\t\t(dash < 3.5 ?\n\t\t\t(dash < 1.5 ?\n\t\t\t\tvec2(1.0, 1.0) :\n\t\t\t\t(2.5 < dash ?\n\t\t\t\t\tvec2(1.0, 2.0) :\n\t\t\t\t\tvec2(1.0, 0.5)\n\t\t\t\t)\n\t\t\t) :\n\t\t\t(dash < 4.5 ?\n\t\t\t\tvec2(2.0, 1.0) :\n\t\t\t\t(5.5 < dash ?\n\t\t\t\t\tvec2(2.0, 2.0) :\n\t\t\t\t\tvec2(2.0, 0.5)\n\t\t\t\t)\n\t\t\t)\n\t\t)\n\t);\n}\n\nvec4 toLength3(in float shift, in float dash, in float strokeScaling, in float strokeWidthScale) {\n\tfloat width = toDotWidth(strokeScaling, strokeWidthScale);\n\tvec2 pattern = toDotPattern(dash);\n\treturn vec4(aStepB.y + shift, pattern.x * width, pattern.y * width, aStepB.z);\n}\n\nvec4 toLength7(in float type, in float strokeScaling, in float strokeWidthScale) {\n\tfloat width = toDotWidth(strokeScaling, strokeWidthScale);\n\tvec2 pattern = toDotPattern(type - 7.0);\n\treturn vec4(aStepB.w, pattern.x * width, pattern.y * width, -1.0);\n}\n\nvoid toColors(in vec3 source, out vec4 fillColor, out vec4 strokeColor) {\n\tvec2 a = toUnpackedAlphas(source.z);\n\tfillColor.xyz = toUnpackedF3x256(source.x).zyx * a.x;\n\tfillColor.w = a.x;\n\tstrokeColor.xyz = toUnpackedF3x256(source.y).zyx * a.y;\n\tstrokeColor.w = a.y;\n}\n\nvoid main(void) {\n\tvec4 general = toGeneral(aStepA.y);\n\tfloat type = general.x;\n\tfloat strokeScaling = general.y;\n\tfloat strokeWidthScale = toStrokeWidthScale(strokeScaling);\n\tfloat strokeWidth = strokeWidthScale * aStepA.x;\n\n\tvType = type;\n\tif (type < 2.5 || 6.5 < type) {\n\t\tgl_Position = vec4(toPosition012(aPosition), 0.0, 1.0);\n\t\tvStepA = strokeWidth * general.zw;\n\t\tif (type < 1.5) {\n\t\t\tvStepB = toStepB01(aStepB);\n\t\t\tvLength = vec4(-1.0, 0.0, 0.0, -1.0);\n\t\t} else if (type < 2.5) {\n\t\t\tvStepB = toStepB2(aStepB, strokeWidth);\n\t\t\tvLength = vec4(-1.0, 0.0, 0.0, -1.0);\n\t\t} else {\n\t\t\tvStepB = toStepB01(aStepB);\n\t\t\tvLength = toLength7(type, strokeScaling, strokeWidthScale);\n\t\t}\n\t} else {\n\t\tfloat shift3 = 0.0;\n\t\tgl_Position = vec4(toPosition3(type, aPosition, aStepB.x, aStepB.w, strokeWidth, shift3), 0.0, 1.0);\n\t\tvStepA = toStepA3(type, strokeWidth);\n\t\tvStepB = vec4(0.0);\n\t\tvLength = toLength3(shift3, general.z, strokeScaling, strokeWidthScale);\n\t}\n\ttoColors(aColor, vColorFill, vColorStroke);\n\tvUv = aUv;\n}`;\n\nconst FRAGMENT_SHADER = `\nvarying mediump float vType;\nvarying mediump vec2 vStepA;\nvarying mediump vec4 vStepB;\nvarying mediump vec4 vLength;\nvarying mediump vec4 vColorFill;\nvarying mediump vec4 vColorStroke;\nvarying mediump vec2 vUv;\n\nuniform sampler2D sampler;\nuniform mediump float antialiasWeight;\n\nvec4 toColor0(in vec4 texture) {\n\tvec2 f = vec2(1.0) / vStepB.xy;\n\tvec2 c = vStepB.zw;\n\tvec2 awd = 0.5 * antialiasWeight * f;\n\tvec2 swd = vStepA * f;\n\tvec2 one = vec2(1.0);\n\tvec2 s0 = smoothstep(one - awd, one + awd, c);\n\tvec2 s1 = smoothstep(one - swd - awd, one - swd + awd, c);\n\tfloat s2 = max(s0.x, s0.y);\n\tfloat s3 = max(s1.x, s1.y);\n\n\treturn texture * (\n\t\tvColorStroke * (s3 - s2) +\n\t\tvColorFill * (1.0 - s3)\n\t);\n}\n\nvec4 toColor1(in vec4 texture) {\n\tvec2 d = vStepB.xy;\n\tvec2 c = vStepB.zw;\n\tvec2 awd = 0.5 * antialiasWeight / d;\n\tvec2 swd = vStepA / d;\n\tvec2 one = vec2(1.0);\n\tvec2 zero = vec2(0.0);\n\tfloat s0 = smoothstep(length(c/clamp(one + awd, zero, one)), length(c/clamp(one - awd, zero, one)), 1.0);\n\tfloat s1 = smoothstep(length(c/clamp(one - swd + awd, zero, one)), length(c/clamp(one - swd - awd, zero, one)), 1.0);\n\treturn texture * (\n\t\tvColorStroke * (s0 - s1) +\n\t\tvColorFill * s1\n\t);\n}\n\nvec4 toColor2(in vec4 texture) {\n\tvec2 p0 = vStepB.xy;\n\tvec2 p1 = vStepB.zw;\n\tvec2 d = vec2(dot(texture, vec4(1.0, 1.0/255.0, 1.0/255.0/255.0, 0.0)));\n\tvec2 s = smoothstep(p0 - p1, p0 + p1, d);\n\treturn vColorStroke * (s.y - s.x) + vColorFill * s.x;\n}\n\nfloat toLineStep(in vec4 parameters) {\n\tfloat l = parameters.x;\n\tfloat lp0 = parameters.y;\n\tfloat lp1 = parameters.z;\n\tfloat lt = parameters.w;\n\tfloat ld = 0.5 * antialiasWeight;\n\tfloat lm = mod(l, lp0 + lp1);\n\tfloat s0 = (0.0 < lp1 ? smoothstep(-ld, ld, lm) - smoothstep(lp0 - ld, lp0 + ld, lm) : 1.0);\n\tfloat s1 = (0.0 <= lt ? smoothstep(-ld, ld, l) - smoothstep(lt - ld, lt + ld, l) : 1.0);\n\treturn s0 * s1;\n}\n\nvec4 toColor3(in vec4 texture) {\n\tfloat c = vStepA.x;\n\tfloat awd = 0.5 * antialiasWeight / vStepA.y;\n\tfloat s0 = smoothstep(-awd, awd, c);\n\tfloat s1 = smoothstep(1.0 - awd, 1.0 + awd, c);\n\treturn texture * vColorStroke * (s0 - s1) * toLineStep(vLength);\n}\n\nvec4 toColor7(in vec4 texture) {\n\tfloat aw = 0.5 * antialiasWeight;\n\tfloat awd = aw * vStepB.x;\n\tfloat swd = vStepA.x * vStepB.x;\n\tfloat s0 = smoothstep(1.0 - awd, 1.0 + awd, vStepB.z);\n\tfloat s1 = smoothstep(1.0 - swd - awd, 1.0 - swd + awd, vStepB.z) * toLineStep(vLength);\n\tfloat s2 = smoothstep(-aw, +aw, vStepB.y);\n\tfloat s3 = smoothstep(-awd, 0.0, vStepB.z);\n\treturn texture * (\n\t\tvColorStroke * (s1 - s0) +\n\t\tvColorFill * (1.0 - s1) * (1.0 - s0) * s2 * s3\n\t);\n}\n\nvoid main(void) {\n\tvec4 texture = texture2D(sampler, vUv);\n\tif (vType < 0.5) {\n\t\tgl_FragColor = toColor0(texture);\n\t} else if (vType < 1.5) {\n\t\tgl_FragColor = toColor1(texture);\n\t} else if (vType < 2.5) {\n\t\tgl_FragColor = toColor2(texture);\n\t} else if (vType < 6.5) {\n\t\tgl_FragColor = toColor3(texture);\n\t} else {\n\t\tgl_FragColor = toColor7(texture);\n\t}\n}`;\n\nexport class EShapeRenderer extends ObjectRenderer {\n\tstatic SHADER: Shader | null = null;\n\n\tprotected _shader: Shader | null;\n\tprotected _iterator: EShapeRendererIterator;\n\tprotected _bufferSizeMax: number;\n\n\tconstructor(renderer: Renderer) {\n\t\tsuper(renderer);\n\t\tEShapeRenderer.SHADER =\n\t\t\tEShapeRenderer.SHADER || Shader.from(VERTEX_SHADER, FRAGMENT_SHADER);\n\t\tthis._shader = EShapeRenderer.SHADER;\n\t\tthis._iterator = new EShapeRendererIterator();\n\t\tthis._bufferSizeMax = this.getBufferSizeMax(renderer);\n\t}\n\n\tprotected getBufferSizeMax(renderer: Renderer): number {\n\t\tconst context = renderer.context;\n\t\tconst extensions = context.extensions as any;\n\t\tif (1 < context.webGLVersion || !!extensions.uint32ElementIndex) {\n\t\t\treturn 1431655765; // 2^32 / 3\n\t\t}\n\t\treturn 21845; // 2^16 / 3\n\t}\n\n\tupdateAtlas(\n\t\tshape: EShape,\n\t\tatlas: DynamicAtlas,\n\t\tfontAtlases: DynamicSDFFontAtlases,\n\t\tdefaultTexture: Texture,\n\t\tbaseTexture: BaseTexture\n\t): void {\n\t\t// Texture\n\t\t// Do not access the shape.image.source here.\n\t\t// It slows down the rendering speed significantly.\n\t\tconst image = shape.image;\n\t\tif (image != null) {\n\t\t\tconst textureItem = atlas.get(image.url);\n\t\t\tif (textureItem != null) {\n\t\t\t\tshape.texture = textureItem.texture;\n\t\t\t} else {\n\t\t\t\tconst newTextureItem = new DynamicAtlasItemImage(\n\t\t\t\t\timage.url,\n\t\t\t\t\timage.width,\n\t\t\t\t\timage.height,\n\t\t\t\t\timage.source,\n\t\t\t\t\tbaseTexture\n\t\t\t\t);\n\t\t\t\tshape.texture = newTextureItem.texture;\n\t\t\t\tatlas.set(newTextureItem.id, newTextureItem);\n\t\t\t}\n\t\t} else {\n\t\t\tshape.texture = defaultTexture;\n\t\t}\n\n\t\t// Font texture atlas\n\t\tconst text = shape.text;\n\t\tconst textCharacters = text.characters;\n\t\tif (0 < textCharacters.length) {\n\t\t\tfontAtlases.add(text.family, textCharacters, text.nacharacters);\n\t\t}\n\t}\n\n\tupdateAtlases(\n\t\tshapes: EShape[],\n\t\tatlas: DynamicAtlas,\n\t\tfontAtlases: DynamicSDFFontAtlases,\n\t\tdefaultTexture: Texture,\n\t\tbaseTexture: BaseTexture\n\t): void {\n\t\tfor (let i = 0, imax = shapes.length; i < imax; ++i) {\n\t\t\tconst shape = shapes[i];\n\t\t\tthis.updateAtlas(shape, atlas, fontAtlases, defaultTexture, baseTexture);\n\t\t\tconst children = shape.children;\n\t\t\tfor (let j = 0, jmax = children.length; j < jmax; ++j) {\n\t\t\t\tconst child = children[j];\n\t\t\t\tthis.updateAtlas(child, atlas, fontAtlases, defaultTexture, baseTexture);\n\t\t\t\tthis.updateAtlases(child.children, atlas, fontAtlases, defaultTexture, baseTexture);\n\t\t\t}\n\t\t}\n\t}\n\n\tupdateFontAtlas(\n\t\tshape: EShape,\n\t\tatlas: DynamicAtlas,\n\t\tfontAtlases: DynamicSDFFontAtlases,\n\t\tdefaultTexture: Texture\n\t): void {\n\t\tconst text = shape.text;\n\t\tconst fontAtlas = fontAtlases.get(text.family);\n\t\tif (fontAtlas != null) {\n\t\t\tconst textureItem = atlas.get(fontAtlas.id);\n\t\t\tif (textureItem != null) {\n\t\t\t\ttext.atlas = fontAtlas;\n\t\t\t\ttext.texture = textureItem.texture;\n\t\t\t} else {\n\t\t\t\ttext.atlas = undefined;\n\t\t\t\ttext.texture = defaultTexture;\n\t\t\t}\n\t\t} else {\n\t\t\ttext.atlas = undefined;\n\t\t\ttext.texture = defaultTexture;\n\t\t}\n\t}\n\n\tupdateFontAtlases(\n\t\tshapes: EShape[],\n\t\tatlas: DynamicAtlas,\n\t\tfontAtlases: DynamicSDFFontAtlases,\n\t\tdefaultTexture: Texture\n\t): void {\n\t\tfor (let i = 0, imax = shapes.length; i < imax; ++i) {\n\t\t\tconst shape = shapes[i];\n\t\t\tthis.updateFontAtlas(shape, atlas, fontAtlases, defaultTexture);\n\t\t\tconst children = shape.children;\n\t\t\tfor (let j = 0, jmax = children.length; j < jmax; ++j) {\n\t\t\t\tconst child = children[j];\n\t\t\t\tthis.updateFontAtlas(child, atlas, fontAtlases, defaultTexture);\n\t\t\t\tthis.updateFontAtlases(child.children, atlas, fontAtlases, defaultTexture);\n\t\t\t}\n\t\t}\n\t}\n\n\trender_(\n\t\tcontainer: EShapeContainer,\n\t\tshape: EShape | null,\n\t\tshapes: EShape[],\n\t\tisDirty: boolean\n\t): void {\n\t\tconst renderer = this.renderer;\n\t\tconst shader = this._shader;\n\n\t\tif (shader != null && (shape != null || 0 < shapes.length)) {\n\t\t\tconst resolution = renderer.resolution;\n\t\t\tconst buffers = container.getBuffers();\n\t\t\tconst antialiasWeight = container.getAntialiasWeight();\n\n\t\t\t// Update textures\n\t\t\tif (isDirty) {\n\t\t\t\t// Atlases\n\t\t\t\tconst atlas = container.getAtlas(resolution);\n\t\t\t\tconst fontAtlases = container.getFontAtlases();\n\t\t\t\tatlas.begin();\n\t\t\t\tfontAtlases.begin();\n\t\t\t\tconst defaultTexture = atlas.getDefaultTexture();\n\t\t\t\tconst baseTexture: BaseTexture = atlas.getBaseTexture();\n\t\t\t\tthis.updateAtlases(shapes, atlas, fontAtlases, defaultTexture, baseTexture);\n\t\t\t\tfontAtlases.end();\n\t\t\t\tfontAtlases.update(atlas);\n\t\t\t\tthis.updateFontAtlases(shapes, atlas, fontAtlases, defaultTexture);\n\t\t\t\tatlas.end();\n\t\t\t\tatlas.repack();\n\n\t\t\t\t// Update buffers\n\t\t\t\tthis.updateBuffers(shape, shapes, buffers, renderer, antialiasWeight);\n\t\t\t}\n\n\t\t\t// Render buffers\n\t\t\tshader.uniforms.shapeScale = container.toShapeScale();\n\t\t\tshader.uniforms.antialiasWeight = container.toPixelScale(resolution) * antialiasWeight;\n\t\t\tshader.uniforms.translationMatrix = container.worldTransform.toArray(true);\n\t\t\trenderer.shader.bind(shader, false);\n\t\t\trenderer.state.setBlendMode(utils.correctBlendMode(BLEND_MODES.NORMAL, true));\n\t\t\tconst buffersLength = buffers.length;\n\t\t\tif (1 < buffersLength) {\n\t\t\t\tfor (let i = 0; i < buffersLength; ++i) {\n\t\t\t\t\tbuffers[i].upload();\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (let i = 0; i < buffersLength; ++i) {\n\t\t\t\tbuffers[i].render(shader);\n\t\t\t}\n\t\t}\n\t}\n\n\tupdateBuffers(\n\t\tshape: EShape | null,\n\t\tshapes: EShape[],\n\t\tbuffers: EShapeBuffer[],\n\t\trenderer: Renderer,\n\t\tantialiasWeight: number\n\t): void {\n\t\tconst iterator = this._iterator;\n\t\titerator.reset(shape, shapes);\n\n\t\tlet ib = 0;\n\t\tlet bufferSize = 0;\n\t\tconst bufferSizeBase = 5000;\n\t\tconst bufferSizeMax = this._bufferSizeMax;\n\t\twhile (iterator.get() != null) {\n\t\t\tlet buffer: EShapeBuffer | null = null;\n\t\t\tlet noMoreThanOne = false;\n\t\t\tif (0 < bufferSize) {\n\t\t\t\tbuffer = new EShapeBuffer(bufferSize, renderer);\n\t\t\t\tbuffers.splice(ib, 0, buffer);\n\t\t\t\tnoMoreThanOne = true;\n\t\t\t} else if (ib < buffers.length) {\n\t\t\t\tbuffer = buffers[ib];\n\t\t\t\tnoMoreThanOne = false;\n\t\t\t} else {\n\t\t\t\tbuffer = new EShapeBuffer(bufferSizeBase, renderer);\n\t\t\t\tbuffers.push(buffer);\n\t\t\t\tnoMoreThanOne = false;\n\t\t\t}\n\t\t\tif (buffer.update(iterator, antialiasWeight, noMoreThanOne)) {\n\t\t\t\tbufferSize = 0;\n\t\t\t\tib += 1;\n\t\t\t} else {\n\t\t\t\tbufferSize = buffer.indexCountRequested;\n\t\t\t\tif (bufferSize <= bufferSizeMax) {\n\t\t\t\t\tbufferSize = Math.ceil(bufferSize / bufferSizeBase) * bufferSizeBase;\n\t\t\t\t\tbufferSize = Math.min(bufferSize, bufferSizeMax);\n\t\t\t\t} else {\n\t\t\t\t\t// No way to render\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (ib < buffers.length) {\n\t\t\tfor (let jb = ib, ibmax = buffers.length; jb < ibmax; ++jb) {\n\t\t\t\tbuffers[jb].destroy();\n\t\t\t}\n\t\t\tbuffers.length = ib;\n\t\t}\n\t}\n}\n"]}
@@ -182,8 +182,8 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
182
182
  // The number of the arc segments is 2n and the number of the points on the arc is m.
183
183
  var n = EShapeDefaults.CIRCLE_SEGMENT_COUNT >> 2;
184
184
  var m = 2 * n + 1;
185
- var nv = 2 * m + 2 * (n + 3);
186
- var ni = 4 * n + 2 * (n + 1);
185
+ var nv = 4 * (m - 1) + 2 * (n + 4);
186
+ var ni = 4 * n + 2 * (n + 2);
187
187
  this._nvertices = nv;
188
188
  this._nindices = ni;
189
189
  this._id += 1;
@@ -243,7 +243,7 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
243
243
  var capped = !sided && !isExact;
244
244
  var chained = sided || capped;
245
245
  this.computeArcPoints(w, h, n, ea, sea, cea);
246
- this.computeArcNormals(w, h, n, ea);
246
+ this.computeArcNormals(w, h, n);
247
247
  var dmax = this.computeMedialPoints(w, h, n, st, ct, chained);
248
248
  if (capped) {
249
249
  // The distance field of the arc must cover O, which is the farthest point from the arc,
@@ -261,10 +261,10 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
261
261
  boundary[3] = 0;
262
262
  var fd = 1 / dmax;
263
263
  var fs = (EShapeFanTriangulatedImpl.SCALE - 1) * dmax;
264
- this.computeRimPoints(w, h, n, fs, st, ct, sea, cea, sided);
265
- // Strip: 2m vertices and 2 * 3 * (m - 1) indices
264
+ this.computeRimPoints(n, fs, st, ct, sided);
265
+ // Strip: 4 * (m - 1) vertices and 2 * 3 * (m - 1) indices
266
266
  this.writeStrip(m, fd, fx, fy, gx, gy);
267
- var iv = 2 * m;
267
+ var iv = 4 * (m - 1);
268
268
  var ii = 6 * (m - 1);
269
269
  // Polygons at the bottom: left (sign = -1) and right (sign = +1)
270
270
  if (sided) {
@@ -319,12 +319,12 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
319
319
  }
320
320
  };
321
321
  /**
322
- * Computes the unit inward normals of the arc, the speeds of the arc, and the arc lengths at P[k].
322
+ * Computes the unit inward normals of the arc, the speeds of the arc, and the lengths of the polyline at P[k].
323
323
  *
324
324
  * The normal at P is Np = (-h x / w, -w y / h), whose magnitude is the speed of the arc.
325
- * The speed is used to approximate the arc length without extra square roots.
325
+ * The lengths are the ones of the polyline, which is the actual outline, so that they are exact at clipping = 1.
326
326
  */
327
- EShapeFanTriangulatedImpl.prototype.computeArcNormals = function (w, h, n, ea) {
327
+ EShapeFanTriangulatedImpl.prototype.computeArcNormals = function (w, h, n) {
328
328
  var m = 2 * n + 1;
329
329
  var px = EShapeFanTriangulatedImpl.WORK_ARC_X;
330
330
  var py = EShapeFanTriangulatedImpl.WORK_ARC_Y;
@@ -332,11 +332,9 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
332
332
  var ny = EShapeFanTriangulatedImpl.WORK_NORMAL_Y;
333
333
  var speeds = EShapeFanTriangulatedImpl.WORK_SPEED;
334
334
  var ls = EShapeFanTriangulatedImpl.WORK_ARC_L;
335
- var da = ea / n;
336
335
  var hw = h / w;
337
336
  var wh = w / h;
338
337
  var l = 0;
339
- var previous = 0;
340
338
  for (var k = 0; k <= n; ++k) {
341
339
  var dx = -hw * px[k];
342
340
  var dy = -wh * py[k];
@@ -345,9 +343,10 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
345
343
  ny[k] = dy / speed;
346
344
  speeds[k] = speed;
347
345
  if (0 < k) {
348
- l += 0.5 * da * (previous + speed);
346
+ var ex = px[k] - px[k - 1];
347
+ var ey = py[k] - py[k - 1];
348
+ l += Math.sqrt(ex * ex + ey * ey);
349
349
  }
350
- previous = speed;
351
350
  ls[k] = l;
352
351
  }
353
352
  for (var k = 0; k < n; ++k) {
@@ -424,24 +423,21 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
424
423
  return dmax;
425
424
  };
426
425
  /**
427
- * Computes R[k], the points on the arc shifted outward by fs, and their lengths.
426
+ * Computes R[k], the points on the arc shifted outward by fs.
428
427
  * If the straight sides are the outline, the end points are shifted
429
428
  * to the intersections of the shifted arc and the shifted straight sides.
430
429
  */
431
- EShapeFanTriangulatedImpl.prototype.computeRimPoints = function (w, h, n, fs, st, ct, sea, cea, sided) {
430
+ EShapeFanTriangulatedImpl.prototype.computeRimPoints = function (n, fs, st, ct, sided) {
432
431
  var m = 2 * n + 1;
433
432
  var px = EShapeFanTriangulatedImpl.WORK_ARC_X;
434
433
  var py = EShapeFanTriangulatedImpl.WORK_ARC_Y;
435
434
  var nx = EShapeFanTriangulatedImpl.WORK_NORMAL_X;
436
435
  var ny = EShapeFanTriangulatedImpl.WORK_NORMAL_Y;
437
- var ls = EShapeFanTriangulatedImpl.WORK_ARC_L;
438
436
  var rx = EShapeFanTriangulatedImpl.WORK_RIM_X;
439
437
  var ry = EShapeFanTriangulatedImpl.WORK_RIM_Y;
440
- var rl = EShapeFanTriangulatedImpl.WORK_RIM_L;
441
438
  for (var k = 0; k < m; ++k) {
442
439
  var x = px[k] - fs * nx[k];
443
440
  var y = py[k] - fs * ny[k];
444
- var l = ls[k];
445
441
  if (sided && (k === 0 || k === m - 1)) {
446
442
  var sign = k === 0 ? -1 : +1;
447
443
  // The miter of the outward normal of the arc (n1) and that of the straight side (n2)
@@ -452,44 +448,63 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
452
448
  var miter = fs / Math.max(1 + n1x * n2x + n1y * n2y, 0.05);
453
449
  x = px[k] + miter * (n1x + n2x);
454
450
  y = py[k] + miter * (n1y + n2y);
455
- // The length is shifted along the tangent (tx, ty) / speed
456
- var tx = w * cea;
457
- var ty = sign * h * sea;
458
- l +=
459
- ((x - px[k]) * tx + (y - py[k]) * ty) / EShapeFanTriangulatedImpl.WORK_SPEED[0];
460
451
  }
461
452
  rx[k] = x;
462
453
  ry[k] = y;
463
- rl[k] = l;
464
454
  }
465
455
  };
466
456
  /**
467
- * Writes the strip P[k], P[k + 1], Q[k + 1], Q[k] with the vertices R[k] and Q[k].
457
+ * Writes the strip P[k], P[k + 1], Q[k + 1], Q[k] with the vertices R[k], Q[k], R[k + 1] and Q[k + 1].
458
+ *
459
+ * Each quad owns its vertices. The length in a quad is the length at P[k] plus the projection
460
+ * to the chord P[k]P[k + 1], which is exact at clipping = 1 where the chord is the outline.
468
461
  */
469
462
  EShapeFanTriangulatedImpl.prototype.writeStrip = function (m, fd, fx, fy, gx, gy) {
463
+ var px = EShapeFanTriangulatedImpl.WORK_ARC_X;
464
+ var py = EShapeFanTriangulatedImpl.WORK_ARC_Y;
470
465
  var qx = EShapeFanTriangulatedImpl.WORK_MEDIAL_X;
471
466
  var qy = EShapeFanTriangulatedImpl.WORK_MEDIAL_Y;
472
467
  var qd = EShapeFanTriangulatedImpl.WORK_MEDIAL_D;
473
468
  var ls = EShapeFanTriangulatedImpl.WORK_ARC_L;
474
469
  var rx = EShapeFanTriangulatedImpl.WORK_RIM_X;
475
470
  var ry = EShapeFanTriangulatedImpl.WORK_RIM_Y;
476
- var rl = EShapeFanTriangulatedImpl.WORK_RIM_L;
477
471
  var scale = EShapeFanTriangulatedImpl.SCALE;
478
472
  var indices = this._indices;
479
473
  var iv = 0;
480
474
  var ii = 0;
481
- for (var k = 0; k < m; ++k) {
482
- this.writeVertex(iv++, rx[k], ry[k], rl[k], scale, fd, fx, fy, gx, gy);
483
- this.writeVertex(iv++, qx[k], qy[k], ls[k], 1 - qd[k] * fd, fd, fx, fy, gx, gy);
484
- if (k < m - 1) {
485
- var a = 2 * k;
486
- indices[ii++] = a;
487
- indices[ii++] = a + 2;
488
- indices[ii++] = a + 3;
489
- indices[ii++] = a;
490
- indices[ii++] = a + 3;
491
- indices[ii++] = a + 1;
492
- }
475
+ for (var k = 0; k < m - 1; ++k) {
476
+ var x0 = px[k];
477
+ var y0 = py[k];
478
+ var l0 = ls[k];
479
+ var dl = ls[k + 1] - l0;
480
+ var fl = 0 < dl ? 1 / dl : 0;
481
+ var ex = (px[k + 1] - x0) * fl;
482
+ var ey = (py[k + 1] - y0) * fl;
483
+ var r0x = rx[k];
484
+ var r0y = ry[k];
485
+ var q0x = qx[k];
486
+ var q0y = qy[k];
487
+ var r1x = rx[k + 1];
488
+ var r1y = ry[k + 1];
489
+ var q1x = qx[k + 1];
490
+ var q1y = qy[k + 1];
491
+ var lr0 = l0 + (r0x - x0) * ex + (r0y - y0) * ey;
492
+ var lq0 = l0 + (q0x - x0) * ex + (q0y - y0) * ey;
493
+ var lr1 = l0 + (r1x - x0) * ex + (r1y - y0) * ey;
494
+ var lq1 = l0 + (q1x - x0) * ex + (q1y - y0) * ey;
495
+ var cq0 = 1 - qd[k] * fd;
496
+ var cq1 = 1 - qd[k + 1] * fd;
497
+ this.writeVertex(iv, r0x, r0y, lr0, scale, fd, fx, fy, gx, gy);
498
+ this.writeVertex(iv + 1, q0x, q0y, lq0, cq0, fd, fx, fy, gx, gy);
499
+ this.writeVertex(iv + 2, r1x, r1y, lr1, scale, fd, fx, fy, gx, gy);
500
+ this.writeVertex(iv + 3, q1x, q1y, lq1, cq1, fd, fx, fy, gx, gy);
501
+ indices[ii++] = iv;
502
+ indices[ii++] = iv + 2;
503
+ indices[ii++] = iv + 3;
504
+ indices[ii++] = iv;
505
+ indices[ii++] = iv + 3;
506
+ indices[ii++] = iv + 1;
507
+ iv += 4;
493
508
  }
494
509
  };
495
510
  /**
@@ -522,8 +537,23 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
522
537
  for (var j = 0; j <= n; ++j) {
523
538
  var k = sign < 0 ? j : m - 1 - j;
524
539
  var floor = 1 - qd[k] * fd;
540
+ var isOnAxis = Math.abs(qx[k]) <= eps;
541
+ // Where Q is clamped, the clipping of the side reaches the floor at T on the axis before Q.
542
+ // Without T, the clipping on the axis is not linear and a dent appears at O.
543
+ var ty = -qd[k] / st;
544
+ if (isOnAxis && qy[k] < ty - eps) {
545
+ this.writeSideVertex(iv + count++, 0, ty, floor, nx, st, l0, -st, ly, fd, fx, fy, gx, gy);
546
+ this.writeFan(ii, iv, count);
547
+ this.writeSideVertex(iv + count, qx[k], qy[k], floor, nx, st, l0, -st, ly, fd, fx, fy, gx, gy);
548
+ var indices = this._indices;
549
+ var i = ii + 3 * (count - 2);
550
+ indices[i] = iv + count - 2;
551
+ indices[i + 1] = iv + count;
552
+ indices[i + 2] = iv + count - 1;
553
+ return count + 1;
554
+ }
525
555
  this.writeSideVertex(iv + count++, qx[k], qy[k], floor, nx, st, l0, -st, ly, fd, fx, fy, gx, gy);
526
- if (Math.abs(qx[k]) <= eps) {
556
+ if (isOnAxis) {
527
557
  break;
528
558
  }
529
559
  }
@@ -702,7 +732,7 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
702
732
  /** P: the points on the arc */
703
733
  EShapeFanTriangulatedImpl.WORK_ARC_X = [];
704
734
  EShapeFanTriangulatedImpl.WORK_ARC_Y = [];
705
- /** The arc lengths measured from P[0] */
735
+ /** The lengths of the polyline P[0], ..., P[k] */
706
736
  EShapeFanTriangulatedImpl.WORK_ARC_L = [];
707
737
  /** The unit inward normals of the arc */
708
738
  EShapeFanTriangulatedImpl.WORK_NORMAL_X = [];
@@ -714,10 +744,9 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
714
744
  EShapeFanTriangulatedImpl.WORK_MEDIAL_Y = [];
715
745
  /** The distances from P to Q */
716
746
  EShapeFanTriangulatedImpl.WORK_MEDIAL_D = [];
717
- /** R: the points on the arc shifted outward, and their lengths */
747
+ /** R: the points on the arc shifted outward */
718
748
  EShapeFanTriangulatedImpl.WORK_RIM_X = [];
719
749
  EShapeFanTriangulatedImpl.WORK_RIM_Y = [];
720
- EShapeFanTriangulatedImpl.WORK_RIM_L = [];
721
750
  return EShapeFanTriangulatedImpl;
722
751
  }());
723
752
  export { EShapeFanTriangulatedImpl };