@wcardinal/wcardinal-ui 0.469.0-beta.1 → 0.469.0-beta.3

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.
Files changed (30) hide show
  1. package/dist/types/wcardinal/ui/shape/variant/e-shape-fan-triangulated-impl.d.ts +12 -10
  2. package/dist/wcardinal/ui/shape/e-shape-renderer.js +2 -2
  3. package/dist/wcardinal/ui/shape/e-shape-renderer.js.map +1 -1
  4. package/dist/wcardinal/ui/shape/variant/e-shape-fan-triangulated-impl.js +33 -28
  5. package/dist/wcardinal/ui/shape/variant/e-shape-fan-triangulated-impl.js.map +1 -1
  6. package/dist/wcardinal/ui/shape/variant/e-shape-fan.js +1 -1
  7. package/dist/wcardinal/ui/shape/variant/e-shape-fan.js.map +1 -1
  8. package/dist/wcardinal/ui/shape/variant/e-shape-semicircle.js +1 -1
  9. package/dist/wcardinal/ui/shape/variant/e-shape-semicircle.js.map +1 -1
  10. package/dist/wcardinal/ui/shape/variant/hit-test-fan.js +3 -3
  11. package/dist/wcardinal/ui/shape/variant/hit-test-fan.js.map +1 -1
  12. package/dist/wcardinal/ui/shape/variant/to-packed.js +5 -3
  13. package/dist/wcardinal/ui/shape/variant/to-packed.js.map +1 -1
  14. package/dist/wcardinal-ui-theme-dark-en-us.js +1 -1
  15. package/dist/wcardinal-ui-theme-dark-en-us.min.js +1 -1
  16. package/dist/wcardinal-ui-theme-dark-ja-jp.js +1 -1
  17. package/dist/wcardinal-ui-theme-dark-ja-jp.min.js +1 -1
  18. package/dist/wcardinal-ui-theme-dark.js +1 -1
  19. package/dist/wcardinal-ui-theme-dark.min.js +1 -1
  20. package/dist/wcardinal-ui-theme-white-en-us.js +1 -1
  21. package/dist/wcardinal-ui-theme-white-en-us.min.js +1 -1
  22. package/dist/wcardinal-ui-theme-white-ja-jp.js +1 -1
  23. package/dist/wcardinal-ui-theme-white-ja-jp.min.js +1 -1
  24. package/dist/wcardinal-ui-theme-white.js +1 -1
  25. package/dist/wcardinal-ui-theme-white.min.js +1 -1
  26. package/dist/wcardinal-ui.cjs.js +46 -39
  27. package/dist/wcardinal-ui.js +46 -39
  28. package/dist/wcardinal-ui.min.js +2 -2
  29. package/dist/wcardinal-ui.min.js.map +1 -1
  30. package/package.json +1 -1
@@ -18,15 +18,17 @@ import { EShapeFanTriangulated } from "./e-shape-fan-triangulated";
18
18
  *
19
19
  * ## Stroke sides
20
20
  *
21
+ * The arc is stroked if any of the LEFT, TOP and RIGHT bits of the stroke side is set (ARC below),
22
+ * and the straight sides are stroked if the BOTTOM bit is set.
21
23
  * The clipping of a vertex is 1 on the outline and decreases toward the inside by (the distance from the outline) * fd,
22
24
  * where the outline is the arc and/or the straight sides depending on the stroke side.
23
25
  *
24
- * - ALL (and NONE): the stroke is at the arc and the straight sides.
26
+ * - ARC and BOTTOM (and NONE): the stroke is at the arc and the straight sides.
25
27
  * The fan is triangulated into the strip P[k], P[k + 1], Q[k + 1], Q[k] and
26
28
  * the two polygons O', A', Q[0], ..., Q[N] and O', B', Q[2N], ..., Q[N] at the bottom.
27
- * - TOP: the stroke is only at the arc.
29
+ * - ARC: the stroke is only at the arc.
28
30
  * For a circle and a semi-ellipse, Q[k] are the points on the axis, which gives the exact fan with the strip only.
29
- * For the other ellipses, Q[k] are on the medial axis as ALL, and the two polygons
31
+ * For the other ellipses, Q[k] are on the medial axis as ARC and BOTTOM, and the two polygons
30
32
  * O, Q[0], ..., Q[N] and O, Q[2N], ..., Q[N] are added at the bottom without the stroke and the anti-aliasing.
31
33
  * - BOTTOM: the stroke is only at the straight sides.
32
34
  * It is the same as a polygon. Two triangle fans from C cover the area between the arc and the segments CA and CB,
@@ -59,7 +61,7 @@ export declare class EShapeFanTriangulatedImpl implements EShapeFanTriangulated
59
61
  protected _height: number;
60
62
  protected _strokeAlign: number;
61
63
  protected _strokeWidth: number;
62
- protected _strokeSideTop: boolean;
64
+ protected _strokeSideArc: boolean;
63
65
  protected _strokeSideBottom: boolean;
64
66
  protected _angle: number;
65
67
  protected _sizeX: number;
@@ -85,12 +87,12 @@ export declare class EShapeFanTriangulatedImpl implements EShapeFanTriangulated
85
87
  get nindices(): number;
86
88
  get boundary(): EShapeBoundary;
87
89
  protected triangulate(): void;
88
- protected update(sx: number, sy: number, angle: number, sst: boolean, ssb: boolean): void;
90
+ protected update(sx: number, sy: number, angle: number, ssa: boolean, ssb: boolean): void;
89
91
  /**
90
92
  * Fills the empty fan, which has no vertices to draw.
91
93
  */
92
94
  protected updateEmpty(w: number, h: number, nv: number, ni: number): void;
93
- protected updateArc(w: number, h: number, n: number, ea: number, sea: number, cea: number, bx: number, oa: number, st: number, ct: number, fx: number, fy: number, gx: number, gy: number, sst: boolean, ssb: boolean, nv: number, ni: number): void;
95
+ protected updateArc(w: number, h: number, n: number, ea: number, sea: number, cea: number, bx: number, oa: number, st: number, ct: number, fx: number, fy: number, gx: number, gy: number, ssa: boolean, ssb: boolean, nv: number, ni: number): void;
94
96
  /**
95
97
  * Computes P[k], the points on the arc, in the work arrays.
96
98
  *
@@ -161,16 +163,16 @@ export declare class EShapeFanTriangulatedImpl implements EShapeFanTriangulated
161
163
  * Returns the number of the written vertices.
162
164
  *
163
165
  * The clipping is 1 + fd * (n . p) where n is the outward unit normal of the straight side,
164
- * and the length is the distance along the straight side measured from O.
165
- * The side OA has n = (-ct, st) and l = (-st, -ct), and the side OB has n = (ct, st) and l = (st, -ct).
166
+ * and the length is l0 + (-st, sign * ct) . p, which is the same as the one of writeSidePolygon
167
+ * so that the dashes of the straight sides do not depend on the stroke side.
166
168
  */
167
- protected writeBottomFan(iv: number, ii: number, sign: number, n: number, yc: number, st: number, ct: number, fd: number, fx: number, fy: number, gx: number, gy: number): number;
169
+ protected writeBottomFan(iv: number, ii: number, sign: number, n: number, yc: number, l0: number, st: number, ct: number, fd: number, fx: number, fy: number, gx: number, gy: number): number;
168
170
  /**
169
171
  * Writes the quad O', A', A, C (sign = -1) or O', B', B, C (sign = +1) at the bottom.
170
172
  * O' is shifted outward by fs / st, and A' (B') is shifted outward by fs perpendicular to the straight side.
171
173
  * Returns the number of the written vertices.
172
174
  */
173
- protected writeBottomQuad(iv: number, ii: number, sign: number, bx: number, by: number, yc: number, fs: number, st: number, ct: number, fd: number, fx: number, fy: number, gx: number, gy: number): number;
175
+ protected writeBottomQuad(iv: number, ii: number, sign: number, bx: number, by: number, yc: number, l0: number, fs: number, st: number, ct: number, fd: number, fx: number, fy: number, gx: number, gy: number): number;
174
176
  /**
175
177
  * Writes a vertex whose clipping and length are computed from the parameters of a straight side.
176
178
  * The clipping is 1 + fd * (nx * x + ny * y), which is not less than the given floor,
@@ -7,8 +7,8 @@ import { BLEND_MODES, ObjectRenderer, Shader, utils } from "pixi.js";
7
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
- 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}";
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(930.0, 930.0);\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) * (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,6BAA6B,CAAC;AAErE,IAAM,aAAa,GAAG,guMAqNpB,CAAC;AAEH,IAAM,eAAe,GAAG,4hGAmGtB,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,GAA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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}\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,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(930.0, 930.0);\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"]}
@@ -23,15 +23,17 @@ import { toFanAngleEccentric } from "./to-fan-angle-eccentric";
23
23
  *
24
24
  * ## Stroke sides
25
25
  *
26
+ * The arc is stroked if any of the LEFT, TOP and RIGHT bits of the stroke side is set (ARC below),
27
+ * and the straight sides are stroked if the BOTTOM bit is set.
26
28
  * The clipping of a vertex is 1 on the outline and decreases toward the inside by (the distance from the outline) * fd,
27
29
  * where the outline is the arc and/or the straight sides depending on the stroke side.
28
30
  *
29
- * - ALL (and NONE): the stroke is at the arc and the straight sides.
31
+ * - ARC and BOTTOM (and NONE): the stroke is at the arc and the straight sides.
30
32
  * The fan is triangulated into the strip P[k], P[k + 1], Q[k + 1], Q[k] and
31
33
  * the two polygons O', A', Q[0], ..., Q[N] and O', B', Q[2N], ..., Q[N] at the bottom.
32
- * - TOP: the stroke is only at the arc.
34
+ * - ARC: the stroke is only at the arc.
33
35
  * For a circle and a semi-ellipse, Q[k] are the points on the axis, which gives the exact fan with the strip only.
34
- * For the other ellipses, Q[k] are on the medial axis as ALL, and the two polygons
36
+ * For the other ellipses, Q[k] are on the medial axis as ARC and BOTTOM, and the two polygons
35
37
  * O, Q[0], ..., Q[N] and O, Q[2N], ..., Q[N] are added at the bottom without the stroke and the anti-aliasing.
36
38
  * - BOTTOM: the stroke is only at the straight sides.
37
39
  * It is the same as a polygon. Two triangle fans from C cover the area between the arc and the segments CA and CB,
@@ -45,7 +47,7 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
45
47
  this._height = 0;
46
48
  this._strokeAlign = 0;
47
49
  this._strokeWidth = 0;
48
- this._strokeSideTop = true;
50
+ this._strokeSideArc = true;
49
51
  this._strokeSideBottom = true;
50
52
  this._angle = 0;
51
53
  this._sizeX = 0;
@@ -149,11 +151,11 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
149
151
  var isRectChanged = this._width !== width || this._height !== height;
150
152
  var stroke = parent.stroke;
151
153
  var strokeAlign = stroke.align;
152
- var strokeSideTop = (stroke.side & EShapeStrokeSide.TOP) !== 0;
154
+ var strokeSideArc = (stroke.side & EShapeStrokeSide.NOT_BOTTOM) !== 0;
153
155
  var strokeSideBottom = (stroke.side & EShapeStrokeSide.BOTTOM) !== 0;
154
- var strokeWidth = stroke.enable && (strokeSideTop || strokeSideBottom) ? stroke.width : 0;
156
+ var strokeWidth = stroke.enable && (strokeSideArc || strokeSideBottom) ? stroke.width : 0;
155
157
  var isStrokeChanged = this._strokeAlign !== strokeAlign || this._strokeWidth !== strokeWidth;
156
- var isStrokeSideChanged = this._strokeSideTop !== strokeSideTop || this._strokeSideBottom !== strokeSideBottom;
158
+ var isStrokeSideChanged = this._strokeSideArc !== strokeSideArc || this._strokeSideBottom !== strokeSideBottom;
157
159
  var angle = parent.angle;
158
160
  var isAngleChanged = this._angle !== angle;
159
161
  var isSizeChanged = false;
@@ -172,13 +174,13 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
172
174
  if (isNotInitialized || isSizeChanged || isStrokeSideChanged || isAngleChanged) {
173
175
  this._sizeX = sizeX;
174
176
  this._sizeY = sizeY;
175
- this._strokeSideTop = strokeSideTop;
177
+ this._strokeSideArc = strokeSideArc;
176
178
  this._strokeSideBottom = strokeSideBottom;
177
179
  this._angle = angle;
178
- this.update(sizeX, sizeY, angle, strokeSideTop, strokeSideBottom);
180
+ this.update(sizeX, sizeY, angle, strokeSideArc, strokeSideBottom);
179
181
  }
180
182
  };
181
- EShapeFanTriangulatedImpl.prototype.update = function (sx, sy, angle, sst, ssb) {
183
+ EShapeFanTriangulatedImpl.prototype.update = function (sx, sy, angle, ssa, ssb) {
182
184
  // The number of the arc segments is 2n and the number of the points on the arc is m.
183
185
  var n = EShapeDefaults.CIRCLE_SEGMENT_COUNT >> 2;
184
186
  var m = 2 * n + 1;
@@ -214,11 +216,11 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
214
216
  var fy = 1 / ay;
215
217
  var gx = Math.sign(sx);
216
218
  var gy = Math.sign(sy);
217
- if (!sst && ssb) {
219
+ if (!ssa && ssb) {
218
220
  this.updateBottom(ax, ay, n, ea, sea, cea, bx, by, st, ct, fx, fy, gx, gy, nv, ni);
219
221
  }
220
222
  else {
221
- this.updateArc(ax, ay, n, ea, sea, cea, bx, oa, st, ct, fx, fy, gx, gy, sst, ssb, nv, ni);
223
+ this.updateArc(ax, ay, n, ea, sea, cea, bx, oa, st, ct, fx, fy, gx, gy, ssa, ssb, nv, ni);
222
224
  }
223
225
  };
224
226
  /**
@@ -232,13 +234,13 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
232
234
  boundary[3] = +h;
233
235
  this.pad(0, 0, nv, ni, 0);
234
236
  };
235
- EShapeFanTriangulatedImpl.prototype.updateArc = function (w, h, n, ea, sea, cea, bx, oa, st, ct, fx, fy, gx, gy, sst, ssb, nv, ni) {
237
+ EShapeFanTriangulatedImpl.prototype.updateArc = function (w, h, n, ea, sea, cea, bx, oa, st, ct, fx, fy, gx, gy, ssa, ssb, nv, ni) {
236
238
  var m = 2 * n + 1;
237
239
  // sided: the straight sides are the outline, which has the stroke and the anti-aliasing
238
240
  // capped: the polygons are added at the bottom to cover the sector with the hard straight sides
239
241
  // chained: Q is on the medial axis. Otherwise, Q is on the axis x = 0 (w <= h) or y = 0 (h < w)
240
242
  // For a circle and a semi-ellipse, Q on the axis gives the exact fan.
241
- var sided = !sst || ssb;
243
+ var sided = !ssa || ssb;
242
244
  var isExact = Math.abs(w - h) <= 1e-9 * w || Math.PI * 0.5 <= ea;
243
245
  var capped = !sided && !isExact;
244
246
  var chained = sided || capped;
@@ -601,17 +603,20 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
601
603
  var fd = (1 + st) / (h * st);
602
604
  var fs = (EShapeFanTriangulatedImpl.SCALE - 1) / fd;
603
605
  this.computeArcPoints(w, h, n, ea, sea, cea);
606
+ this.computeArcNormals(w, h, n);
607
+ // The length of O, which is the same as the one of writeSidePolygon: |OA| + the length of the arc
608
+ var l0 = Math.sqrt(bx * bx + by * by) + EShapeFanTriangulatedImpl.WORK_ARC_L[2 * n];
604
609
  // Triangle fans from C to the arc: left (sign = -1) and right (sign = +1)
605
610
  var iv = 0;
606
611
  var ii = 0;
607
612
  for (var sign = -1; sign <= 1; sign += 2) {
608
- var count = this.writeBottomFan(iv, ii, sign, n, yc, st, ct, fd, fx, fy, gx, gy);
613
+ var count = this.writeBottomFan(iv, ii, sign, n, yc, l0, st, ct, fd, fx, fy, gx, gy);
609
614
  iv += count;
610
615
  ii += 3 * (count - 2);
611
616
  }
612
617
  // Quads at the bottom: O', A', A, C and O', B', B, C
613
618
  for (var sign = -1; sign <= 1; sign += 2) {
614
- var count = this.writeBottomQuad(iv, ii, sign, bx, by, yc, fs, st, ct, fd, fx, fy, gx, gy);
619
+ var count = this.writeBottomQuad(iv, ii, sign, bx, by, yc, l0, fs, st, ct, fd, fx, fy, gx, gy);
615
620
  iv += count;
616
621
  ii += 3 * (count - 2);
617
622
  }
@@ -622,19 +627,19 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
622
627
  * Returns the number of the written vertices.
623
628
  *
624
629
  * The clipping is 1 + fd * (n . p) where n is the outward unit normal of the straight side,
625
- * and the length is the distance along the straight side measured from O.
626
- * The side OA has n = (-ct, st) and l = (-st, -ct), and the side OB has n = (ct, st) and l = (st, -ct).
630
+ * and the length is l0 + (-st, sign * ct) . p, which is the same as the one of writeSidePolygon
631
+ * so that the dashes of the straight sides do not depend on the stroke side.
627
632
  */
628
- EShapeFanTriangulatedImpl.prototype.writeBottomFan = function (iv, ii, sign, n, yc, st, ct, fd, fx, fy, gx, gy) {
633
+ EShapeFanTriangulatedImpl.prototype.writeBottomFan = function (iv, ii, sign, n, yc, l0, st, ct, fd, fx, fy, gx, gy) {
629
634
  var px = EShapeFanTriangulatedImpl.WORK_ARC_X;
630
635
  var py = EShapeFanTriangulatedImpl.WORK_ARC_Y;
631
636
  var nx = sign * ct;
632
- var lx = sign * st;
637
+ var ly = sign * ct;
633
638
  var count = 0;
634
- this.writeSideVertex(iv + count++, 0, -yc, 0, nx, st, 0, lx, -ct, fd, fx, fy, gx, gy);
639
+ this.writeSideVertex(iv + count++, 0, -yc, 0, nx, st, l0, -st, ly, fd, fx, fy, gx, gy);
635
640
  for (var j = 0; j <= n; ++j) {
636
641
  var k = sign < 0 ? j : n + j;
637
- this.writeSideVertex(iv + count++, px[k], py[k], 0, nx, st, 0, lx, -ct, fd, fx, fy, gx, gy);
642
+ this.writeSideVertex(iv + count++, px[k], py[k], 0, nx, st, l0, -st, ly, fd, fx, fy, gx, gy);
638
643
  }
639
644
  this.writeFan(ii, iv, count);
640
645
  return count;
@@ -644,13 +649,13 @@ var EShapeFanTriangulatedImpl = /** @class */ (function () {
644
649
  * O' is shifted outward by fs / st, and A' (B') is shifted outward by fs perpendicular to the straight side.
645
650
  * Returns the number of the written vertices.
646
651
  */
647
- EShapeFanTriangulatedImpl.prototype.writeBottomQuad = function (iv, ii, sign, bx, by, yc, fs, st, ct, fd, fx, fy, gx, gy) {
652
+ EShapeFanTriangulatedImpl.prototype.writeBottomQuad = function (iv, ii, sign, bx, by, yc, l0, fs, st, ct, fd, fx, fy, gx, gy) {
648
653
  var nx = sign * ct;
649
- var lx = sign * st;
650
- this.writeSideVertex(iv, 0, fs / st, 0, nx, st, 0, lx, -ct, fd, fx, fy, gx, gy);
651
- this.writeSideVertex(iv + 1, sign * (bx + fs * ct), -by + fs * st, 0, nx, st, 0, lx, -ct, fd, fx, fy, gx, gy);
652
- this.writeSideVertex(iv + 2, sign * bx, -by, 0, nx, st, 0, lx, -ct, fd, fx, fy, gx, gy);
653
- this.writeSideVertex(iv + 3, 0, -yc, 0, nx, st, 0, lx, -ct, fd, fx, fy, gx, gy);
654
+ var ly = sign * ct;
655
+ this.writeSideVertex(iv, 0, fs / st, 0, nx, st, l0, -st, ly, fd, fx, fy, gx, gy);
656
+ this.writeSideVertex(iv + 1, sign * (bx + fs * ct), -by + fs * st, 0, nx, st, l0, -st, ly, fd, fx, fy, gx, gy);
657
+ this.writeSideVertex(iv + 2, sign * bx, -by, 0, nx, st, l0, -st, ly, fd, fx, fy, gx, gy);
658
+ this.writeSideVertex(iv + 3, 0, -yc, 0, nx, st, l0, -st, ly, fd, fx, fy, gx, gy);
654
659
  this.writeFan(ii, iv, 4);
655
660
  return 4;
656
661
  };