@flighthq/shape 0.3.0-next.1584.a68fe91 → 0.3.0-next.1593.a47f94a

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.
@@ -9,4 +9,5 @@ export * from './shapeStrokeOutline';
9
9
  export * from './shapeHitTestBuiltins';
10
10
  export * from './shapeHitTestRegistry';
11
11
  export * from './scale9ShapeCommands';
12
+ export * from './explainShapeTessellation';
12
13
  //# sourceMappingURL=contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC"}
package/dist/contract.js CHANGED
@@ -9,4 +9,5 @@ export * from './shapeStrokeOutline';
9
9
  export * from './shapeHitTestBuiltins';
10
10
  export * from './shapeHitTestRegistry';
11
11
  export * from './scale9ShapeCommands';
12
+ export * from './explainShapeTessellation';
12
13
  //# sourceMappingURL=contract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ShapeCommandToken, ShapeTessellationExplanation } from '@flighthq/types/contract';
2
+ export declare function explainShapeTessellation(commands: readonly ShapeCommandToken[], strokePathTessellationEnabled?: boolean): ShapeTessellationExplanation;
3
+ //# sourceMappingURL=explainShapeTessellation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explainShapeTessellation.d.ts","sourceRoot":"","sources":["../src/explainShapeTessellation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAYhG,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,SAAS,iBAAiB,EAAE,EACtC,6BAA6B,UAAQ,GACpC,4BAA4B,CAO9B"}
@@ -0,0 +1,20 @@
1
+ import { hasNonSolidShapeFill } from './shapeFill';
2
+ import { hasNonSolidShapeStroke } from './shapeStroke';
3
+ import { getShapeStrokeOutlineRegions } from './shapeStrokeOutline';
4
+ // Reports whether a command stream can be drawn as mesh regions, and what stops it when it cannot.
5
+ //
6
+ // `strokePathTessellationEnabled` selects which stroke lane the answer describes, because the two
7
+ // differ on exactly the case that catches authors out: the default lane declines a closed stroke — the
8
+ // outline of any rectangle, circle, or closed path — while the opt-in stroke-path tessellator expresses
9
+ // it. Fill alpha never matters to either; a solid fill tessellates at any alpha, including zero.
10
+ export function explainShapeTessellation(commands, strokePathTessellationEnabled = false) {
11
+ if (hasNonSolidShapeFill(commands))
12
+ return { blockedBy: 'non-solid-fill', status: 'needs-rasterizer' };
13
+ if (hasNonSolidShapeStroke(commands))
14
+ return { blockedBy: 'non-solid-stroke', status: 'needs-rasterizer' };
15
+ if (!strokePathTessellationEnabled && getShapeStrokeOutlineRegions(commands) === null) {
16
+ return { blockedBy: 'stroke-outline', status: 'needs-rasterizer' };
17
+ }
18
+ return { blockedBy: 'none', status: 'tessellates' };
19
+ }
20
+ //# sourceMappingURL=explainShapeTessellation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explainShapeTessellation.js","sourceRoot":"","sources":["../src/explainShapeTessellation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAEpE,mGAAmG;AACnG,EAAE;AACF,kGAAkG;AAClG,uGAAuG;AACvG,wGAAwG;AACxG,iGAAiG;AACjG,MAAM,UAAU,wBAAwB,CACtC,QAAsC,EACtC,6BAA6B,GAAG,KAAK;IAErC,IAAI,oBAAoB,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;IACvG,IAAI,sBAAsB,CAAC,QAAQ,CAAC;QAAE,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;IAC3G,IAAI,CAAC,6BAA6B,IAAI,4BAA4B,CAAC,QAAQ,CAAC,KAAK,IAAI,EAAE,CAAC;QACtF,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,kBAAkB,EAAE,CAAC;IACrE,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;AACtD,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { PathCommand, applyAnimationClipToMorphShape, applyMorphShapeAnimationSample, appendMorphShapePath, appendShapeArc, appendShapeArcTo, appendShapeBeginTextureFill, appendShapeBeginFill, appendShapeBeginGradientFill, appendShapeCircle, appendShapeCubicCurveTo, appendShapeCurveTo, appendShapeDrawTriangles, appendShapeEllipse, appendShapeEndFill, appendShapeGeometryCommand, appendShapeLineTextureStyle, appendShapeLineGradientStyle, appendShapeLineStyle, appendShapeLineTo, appendShapeMoveTo, appendShapePath, appendShapePolygon, appendShapePolyline, appendShapeRectangle, appendShapeRoundRectangle, appendShapeRoundRectangleVarying, clearShapeCommands, computeShapeLocalBoundsRectangle, copyShapeCommands, createMorphShape, createMorphShapeAnimationTarget, createScale9Shape, createShape, enableShapeHitTesting, getPathCommandOperandCount, getShapeBounds, getShapeCommandCount, getShapeFillRegions, getShapeStrokeRegions, getShapeStrokeOutlineRegions, hasNonSolidShapeFill, hasNonSolidShapeStroke, hasShapeFill, hitTestShapeCommandPoint, isShapeEmpty, registerShapeHitTestCommand, setMorphShapeProgress, } from './contract';
2
2
  export * from './scale9ShapeCommands';
3
+ export * from './explainShapeTessellation';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,8BAA8B,EAC9B,8BAA8B,EAC9B,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,EAC5B,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,gCAAgC,EAChC,kBAAkB,EAClB,gCAAgC,EAChC,iBAAiB,EACjB,gBAAgB,EAChB,+BAA+B,EAC/B,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,0BAA0B,EAC1B,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,wBAAwB,EACxB,YAAY,EACZ,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,8BAA8B,EAC9B,8BAA8B,EAC9B,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,EAC5B,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,gCAAgC,EAChC,kBAAkB,EAClB,gCAAgC,EAChC,iBAAiB,EACjB,gBAAgB,EAChB,+BAA+B,EAC/B,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,0BAA0B,EAC1B,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,wBAAwB,EACxB,YAAY,EACZ,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { PathCommand, applyAnimationClipToMorphShape, applyMorphShapeAnimationSample, appendMorphShapePath, appendShapeArc, appendShapeArcTo, appendShapeBeginTextureFill, appendShapeBeginFill, appendShapeBeginGradientFill, appendShapeCircle, appendShapeCubicCurveTo, appendShapeCurveTo, appendShapeDrawTriangles, appendShapeEllipse, appendShapeEndFill, appendShapeGeometryCommand, appendShapeLineTextureStyle, appendShapeLineGradientStyle, appendShapeLineStyle, appendShapeLineTo, appendShapeMoveTo, appendShapePath, appendShapePolygon, appendShapePolyline, appendShapeRectangle, appendShapeRoundRectangle, appendShapeRoundRectangleVarying, clearShapeCommands, computeShapeLocalBoundsRectangle, copyShapeCommands, createMorphShape, createMorphShapeAnimationTarget, createScale9Shape, createShape, enableShapeHitTesting, getPathCommandOperandCount, getShapeBounds, getShapeCommandCount, getShapeFillRegions, getShapeStrokeRegions, getShapeStrokeOutlineRegions, hasNonSolidShapeFill, hasNonSolidShapeStroke, hasShapeFill, hitTestShapeCommandPoint, isShapeEmpty, registerShapeHitTestCommand, setMorphShapeProgress, } from './contract';
2
2
  export * from './scale9ShapeCommands';
3
+ export * from './explainShapeTessellation';
3
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,8BAA8B,EAC9B,8BAA8B,EAC9B,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,EAC5B,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,gCAAgC,EAChC,kBAAkB,EAClB,gCAAgC,EAChC,iBAAiB,EACjB,gBAAgB,EAChB,+BAA+B,EAC/B,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,0BAA0B,EAC1B,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,wBAAwB,EACxB,YAAY,EACZ,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,8BAA8B,EAC9B,8BAA8B,EAC9B,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,2BAA2B,EAC3B,oBAAoB,EACpB,4BAA4B,EAC5B,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,gCAAgC,EAChC,kBAAkB,EAClB,gCAAgC,EAChC,iBAAiB,EACjB,gBAAgB,EAChB,+BAA+B,EAC/B,iBAAiB,EACjB,WAAW,EACX,qBAAqB,EACrB,0BAA0B,EAC1B,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,oBAAoB,EACpB,sBAAsB,EACtB,YAAY,EACZ,wBAAwB,EACxB,YAAY,EACZ,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,YAAY,CAAC;AACpB,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/shape",
3
- "version": "0.3.0-next.1584.a68fe91",
3
+ "version": "0.3.0-next.1593.a47f94a",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/flighthq/flight.git",
@@ -36,12 +36,12 @@
36
36
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@flighthq/animation": "0.3.0-next.1584.a68fe91",
40
- "@flighthq/scene2d": "0.3.0-next.1584.a68fe91",
41
- "@flighthq/geometry": "0.3.0-next.1584.a68fe91",
42
- "@flighthq/node": "0.3.0-next.1584.a68fe91",
43
- "@flighthq/path": "0.3.0-next.1584.a68fe91",
44
- "@flighthq/types": "0.3.0-next.1584.a68fe91"
39
+ "@flighthq/animation": "0.3.0-next.1593.a47f94a",
40
+ "@flighthq/scene2d": "0.3.0-next.1593.a47f94a",
41
+ "@flighthq/geometry": "0.3.0-next.1593.a47f94a",
42
+ "@flighthq/node": "0.3.0-next.1593.a47f94a",
43
+ "@flighthq/path": "0.3.0-next.1593.a47f94a",
44
+ "@flighthq/types": "0.3.0-next.1593.a47f94a"
45
45
  },
46
46
  "devDependencies": {
47
47
  "typescript": "^5.3.0"
@@ -0,0 +1,65 @@
1
+ import { explainShapeTessellation } from './explainShapeTessellation';
2
+ import { createShape } from './shape';
3
+ import {
4
+ appendShapeBeginFill,
5
+ appendShapeBeginGradientFill,
6
+ appendShapeEndFill,
7
+ appendShapeLineStyle,
8
+ appendShapeLineTo,
9
+ appendShapeMoveTo,
10
+ appendShapeRectangle,
11
+ } from './shapeCommands';
12
+
13
+ describe('explainShapeTessellation', () => {
14
+ it('reports a solid fill as tessellating at any alpha, opaque or not', () => {
15
+ // Alpha is carried on the region, so it never moves a shape off the mesh lane — worth pinning,
16
+ // because a translucent shape that fails to draw invites blaming the alpha.
17
+ for (const alpha of [1, 0.25, 0]) {
18
+ const shape = createShape();
19
+ appendShapeBeginFill(shape, 0xff0000, alpha);
20
+ appendShapeRectangle(shape, 0, 0, 50, 50);
21
+ appendShapeEndFill(shape);
22
+
23
+ expect(explainShapeTessellation(shape.data.commands)).toEqual({ blockedBy: 'none', status: 'tessellates' });
24
+ }
25
+ });
26
+
27
+ it('reports an open stroke as tessellating', () => {
28
+ const shape = createShape();
29
+ appendShapeLineStyle(shape, 2, 0x000000);
30
+ appendShapeMoveTo(shape, 0, 0);
31
+ appendShapeLineTo(shape, 50, 0);
32
+
33
+ expect(explainShapeTessellation(shape.data.commands)).toEqual({ blockedBy: 'none', status: 'tessellates' });
34
+ });
35
+
36
+ it('names the closed stroke that the default lane declines, and clears it for the opt-in lane', () => {
37
+ const shape = createShape();
38
+ appendShapeBeginFill(shape, 0xff0000, 1);
39
+ appendShapeLineStyle(shape, 2, 0x000000);
40
+ appendShapeRectangle(shape, 0, 0, 50, 50);
41
+ appendShapeEndFill(shape);
42
+
43
+ expect(explainShapeTessellation(shape.data.commands)).toEqual({
44
+ blockedBy: 'stroke-outline',
45
+ status: 'needs-rasterizer',
46
+ });
47
+ expect(explainShapeTessellation(shape.data.commands, true)).toEqual({
48
+ blockedBy: 'none',
49
+ status: 'tessellates',
50
+ });
51
+ });
52
+
53
+ it('names a non-solid fill, which no stroke lane setting can rescue', () => {
54
+ const shape = createShape();
55
+ appendShapeBeginGradientFill(shape, 'linear', [0xff0000, 0x0000ff], [1, 1], [0, 255]);
56
+ appendShapeRectangle(shape, 0, 0, 50, 50);
57
+ appendShapeEndFill(shape);
58
+
59
+ expect(explainShapeTessellation(shape.data.commands)).toEqual({
60
+ blockedBy: 'non-solid-fill',
61
+ status: 'needs-rasterizer',
62
+ });
63
+ expect(explainShapeTessellation(shape.data.commands, true).status).toBe('needs-rasterizer');
64
+ });
65
+ });