@threekit-tools/treble 0.0.90-next-09 → 0.0.91

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 (193) hide show
  1. package/dist/Treble/Treble.d.ts +2 -2
  2. package/dist/Treble/Treble.js +2 -2
  3. package/dist/Treble/index.d.ts +1 -1
  4. package/dist/Treble/index.js +1 -1
  5. package/dist/hooks/useNestedConfigurator/index.js +2 -1
  6. package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +95 -0
  7. package/dist/hooks/useRoomBuilder/RoomBuilderState.js +1237 -0
  8. package/dist/hooks/useRoomBuilder/constants.d.ts +41 -0
  9. package/dist/hooks/useRoomBuilder/constants.js +48 -0
  10. package/dist/hooks/{useSpaces → useRoomBuilder}/dataHandlers.d.ts +4 -6
  11. package/dist/hooks/{useSpaces → useRoomBuilder}/dataHandlers.js +40 -102
  12. package/dist/hooks/useRoomBuilder/draw.d.ts +55 -0
  13. package/dist/hooks/useRoomBuilder/draw.js +573 -0
  14. package/dist/hooks/useRoomBuilder/findLoops.d.ts +5 -0
  15. package/dist/hooks/{useSpaces/geometry → useRoomBuilder}/findLoops.js +9 -14
  16. package/dist/hooks/useRoomBuilder/geometry.d.ts +33 -0
  17. package/dist/hooks/useRoomBuilder/geometry.js +325 -0
  18. package/dist/hooks/useRoomBuilder/index.d.ts +40 -0
  19. package/dist/hooks/useRoomBuilder/index.js +303 -0
  20. package/dist/hooks/{useSpaces/validators → useRoomBuilder}/messaging.js +1 -1
  21. package/dist/hooks/{useSpaces/themes/index.d.ts → useRoomBuilder/themes.d.ts} +4 -3
  22. package/dist/hooks/useRoomBuilder/themes.js +273 -0
  23. package/dist/hooks/{useSpaces → useRoomBuilder}/types.d.ts +35 -130
  24. package/dist/hooks/{useSpaces → useRoomBuilder}/types.js +1 -13
  25. package/dist/hooks/useRoomBuilder/validators.d.ts +36 -0
  26. package/dist/hooks/useRoomBuilder/validators.js +362 -0
  27. package/dist/hooks/useSpaces/Canvas.d.ts +37 -0
  28. package/dist/hooks/useSpaces/Canvas.js +199 -0
  29. package/dist/icons/AngleSnapping.d.ts +3 -0
  30. package/dist/icons/AngleSnapping.js +28 -0
  31. package/dist/icons/Center.d.ts +3 -0
  32. package/dist/icons/Center.js +24 -0
  33. package/dist/icons/Draw.js +3 -3
  34. package/dist/icons/GridSnapping.d.ts +3 -0
  35. package/dist/icons/GridSnapping.js +28 -0
  36. package/dist/icons/LayoutAlt.d.ts +3 -0
  37. package/dist/icons/LayoutAlt.js +21 -0
  38. package/dist/icons/Magnet.d.ts +3 -0
  39. package/dist/icons/Magnet.js +27 -0
  40. package/dist/icons/Save.d.ts +3 -0
  41. package/dist/icons/Save.js +21 -0
  42. package/dist/icons/UnitCm.d.ts +3 -0
  43. package/dist/icons/UnitCm.js +22 -0
  44. package/dist/icons/UnitFeet.d.ts +3 -0
  45. package/dist/icons/UnitFeet.js +22 -0
  46. package/dist/icons/UnitInch.d.ts +3 -0
  47. package/dist/icons/UnitInch.js +22 -0
  48. package/dist/icons/UnitMeter.d.ts +3 -0
  49. package/dist/icons/UnitMeter.js +21 -0
  50. package/dist/icons/Window.js +4 -4
  51. package/dist/icons/index.js +0 -2
  52. package/dist/icons/types.d.ts +1 -1
  53. package/dist/index.d.ts +2 -4
  54. package/dist/index.js +5 -9
  55. package/dist/store/attributes.d.ts +0 -1
  56. package/dist/store/index.d.ts +0 -10
  57. package/dist/store/index.js +1 -3
  58. package/dist/store/treble.js +17 -21
  59. package/dist/types.d.ts +3 -5
  60. package/package.json +1 -1
  61. package/dist/hooks/useSpaces/SpacesLayout.d.ts +0 -11
  62. package/dist/hooks/useSpaces/SpacesLayout.js +0 -74
  63. package/dist/hooks/useSpaces/SpacesState.d.ts +0 -162
  64. package/dist/hooks/useSpaces/SpacesState.js +0 -1759
  65. package/dist/hooks/useSpaces/constants.d.ts +0 -44
  66. package/dist/hooks/useSpaces/constants.js +0 -105
  67. package/dist/hooks/useSpaces/draw/clearCanvas.d.ts +0 -2
  68. package/dist/hooks/useSpaces/draw/clearCanvas.js +0 -9
  69. package/dist/hooks/useSpaces/draw/drawBackground.d.ts +0 -2
  70. package/dist/hooks/useSpaces/draw/drawBackground.js +0 -12
  71. package/dist/hooks/useSpaces/draw/drawDimensions.d.ts +0 -3
  72. package/dist/hooks/useSpaces/draw/drawDimensions.js +0 -53
  73. package/dist/hooks/useSpaces/draw/drawDoors.d.ts +0 -9
  74. package/dist/hooks/useSpaces/draw/drawDoors.js +0 -93
  75. package/dist/hooks/useSpaces/draw/drawFloor.d.ts +0 -3
  76. package/dist/hooks/useSpaces/draw/drawFloor.js +0 -36
  77. package/dist/hooks/useSpaces/draw/drawGrid.d.ts +0 -3
  78. package/dist/hooks/useSpaces/draw/drawGrid.js +0 -33
  79. package/dist/hooks/useSpaces/draw/drawGuides.d.ts +0 -3
  80. package/dist/hooks/useSpaces/draw/drawGuides.js +0 -23
  81. package/dist/hooks/useSpaces/draw/drawOpenings.d.ts +0 -9
  82. package/dist/hooks/useSpaces/draw/drawOpenings.js +0 -72
  83. package/dist/hooks/useSpaces/draw/drawVertices.d.ts +0 -8
  84. package/dist/hooks/useSpaces/draw/drawVertices.js +0 -61
  85. package/dist/hooks/useSpaces/draw/drawWalls.d.ts +0 -10
  86. package/dist/hooks/useSpaces/draw/drawWalls.js +0 -64
  87. package/dist/hooks/useSpaces/draw/drawWindows.d.ts +0 -9
  88. package/dist/hooks/useSpaces/draw/drawWindows.js +0 -82
  89. package/dist/hooks/useSpaces/draw/index.d.ts +0 -11
  90. package/dist/hooks/useSpaces/draw/index.js +0 -129
  91. package/dist/hooks/useSpaces/geometry/addThicknessToLine.d.ts +0 -3
  92. package/dist/hooks/useSpaces/geometry/addThicknessToLine.js +0 -13
  93. package/dist/hooks/useSpaces/geometry/areLinesEqual.d.ts +0 -3
  94. package/dist/hooks/useSpaces/geometry/areLinesEqual.js +0 -17
  95. package/dist/hooks/useSpaces/geometry/arePointsEqual.d.ts +0 -3
  96. package/dist/hooks/useSpaces/geometry/arePointsEqual.js +0 -8
  97. package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.d.ts +0 -3
  98. package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.js +0 -11
  99. package/dist/hooks/useSpaces/geometry/closestPointOnLine.d.ts +0 -3
  100. package/dist/hooks/useSpaces/geometry/closestPointOnLine.js +0 -13
  101. package/dist/hooks/useSpaces/geometry/doLinesOverlap.d.ts +0 -2
  102. package/dist/hooks/useSpaces/geometry/doLinesOverlap.js +0 -16
  103. package/dist/hooks/useSpaces/geometry/euclideanMod.d.ts +0 -2
  104. package/dist/hooks/useSpaces/geometry/euclideanMod.js +0 -6
  105. package/dist/hooks/useSpaces/geometry/findLoops.d.ts +0 -6
  106. package/dist/hooks/useSpaces/geometry/getAllLineIntersections.d.ts +0 -6
  107. package/dist/hooks/useSpaces/geometry/getAllLineIntersections.js +0 -23
  108. package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.d.ts +0 -3
  109. package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.js +0 -7
  110. package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.d.ts +0 -3
  111. package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.js +0 -17
  112. package/dist/hooks/useSpaces/geometry/getDistanceToLine.d.ts +0 -3
  113. package/dist/hooks/useSpaces/geometry/getDistanceToLine.js +0 -10
  114. package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.d.ts +0 -3
  115. package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.js +0 -7
  116. package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.d.ts +0 -3
  117. package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.js +0 -17
  118. package/dist/hooks/useSpaces/geometry/getLineOtherPoint.d.ts +0 -3
  119. package/dist/hooks/useSpaces/geometry/getLineOtherPoint.js +0 -11
  120. package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.d.ts +0 -3
  121. package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.js +0 -43
  122. package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.d.ts +0 -3
  123. package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.js +0 -9
  124. package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.d.ts +0 -3
  125. package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.js +0 -20
  126. package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.d.ts +0 -3
  127. package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.js +0 -11
  128. package/dist/hooks/useSpaces/geometry/getPolygonArea.d.ts +0 -3
  129. package/dist/hooks/useSpaces/geometry/getPolygonArea.js +0 -15
  130. package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.d.ts +0 -3
  131. package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.js +0 -16
  132. package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.d.ts +0 -6
  133. package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.js +0 -17
  134. package/dist/hooks/useSpaces/geometry/getTriangleArea.d.ts +0 -3
  135. package/dist/hooks/useSpaces/geometry/getTriangleArea.js +0 -9
  136. package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.d.ts +0 -3
  137. package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.js +0 -12
  138. package/dist/hooks/useSpaces/geometry/index.d.ts +0 -30
  139. package/dist/hooks/useSpaces/geometry/index.js +0 -64
  140. package/dist/hooks/useSpaces/geometry/isPointInPolygon.d.ts +0 -3
  141. package/dist/hooks/useSpaces/geometry/isPointInPolygon.js +0 -21
  142. package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.d.ts +0 -3
  143. package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.js +0 -25
  144. package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.d.ts +0 -3
  145. package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.js +0 -11
  146. package/dist/hooks/useSpaces/geometry/splitLineAtOffset.d.ts +0 -3
  147. package/dist/hooks/useSpaces/geometry/splitLineAtOffset.js +0 -12
  148. package/dist/hooks/useSpaces/geometry/splitLineAtPoint.d.ts +0 -3
  149. package/dist/hooks/useSpaces/geometry/splitLineAtPoint.js +0 -9
  150. package/dist/hooks/useSpaces/geometry/splitLineAtPoints.d.ts +0 -3
  151. package/dist/hooks/useSpaces/geometry/splitLineAtPoints.js +0 -28
  152. package/dist/hooks/useSpaces/index.d.ts +0 -76
  153. package/dist/hooks/useSpaces/index.js +0 -474
  154. package/dist/hooks/useSpaces/themes/blueprint.d.ts +0 -3
  155. package/dist/hooks/useSpaces/themes/blueprint.js +0 -96
  156. package/dist/hooks/useSpaces/themes/default.d.ts +0 -3
  157. package/dist/hooks/useSpaces/themes/default.js +0 -96
  158. package/dist/hooks/useSpaces/themes/index.js +0 -21
  159. package/dist/hooks/useSpaces/themes/light.d.ts +0 -3
  160. package/dist/hooks/useSpaces/themes/light.js +0 -96
  161. package/dist/hooks/useSpaces/validators/areWallsDuplicated.d.ts +0 -3
  162. package/dist/hooks/useSpaces/validators/areWallsDuplicated.js +0 -61
  163. package/dist/hooks/useSpaces/validators/areWallsIntersecting.d.ts +0 -3
  164. package/dist/hooks/useSpaces/validators/areWallsIntersecting.js +0 -42
  165. package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.d.ts +0 -3
  166. package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.js +0 -52
  167. package/dist/hooks/useSpaces/validators/areWallsTooShort.d.ts +0 -3
  168. package/dist/hooks/useSpaces/validators/areWallsTooShort.js +0 -37
  169. package/dist/hooks/useSpaces/validators/index.d.ts +0 -15
  170. package/dist/hooks/useSpaces/validators/index.js +0 -40
  171. package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.d.ts +0 -3
  172. package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.js +0 -31
  173. package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.d.ts +0 -3
  174. package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.js +0 -19
  175. package/dist/hooks/useSpaces/validators/isLineTooShort.d.ts +0 -3
  176. package/dist/hooks/useSpaces/validators/isLineTooShort.js +0 -26
  177. package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.d.ts +0 -4
  178. package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.js +0 -19
  179. package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.d.ts +0 -3
  180. package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.js +0 -19
  181. package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.d.ts +0 -3
  182. package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.js +0 -41
  183. package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.d.ts +0 -3
  184. package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.js +0 -54
  185. package/dist/hooks/useSpaces/validators/isWallTooShort.d.ts +0 -3
  186. package/dist/hooks/useSpaces/validators/isWallTooShort.js +0 -10
  187. package/dist/icons/Player3D.d.ts +0 -3
  188. package/dist/icons/Player3D.js +0 -21
  189. package/dist/store/spaces.d.ts +0 -47
  190. package/dist/store/spaces.js +0 -197
  191. /package/dist/Treble/{snapshot.d.ts → snapshots.d.ts} +0 -0
  192. /package/dist/Treble/{snapshot.js → snapshots.js} +0 -0
  193. /package/dist/hooks/{useSpaces/validators → useRoomBuilder}/messaging.d.ts +0 -0
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.drawWalls = exports.drawNewWall = void 0;
4
- var types_1 = require("../types");
5
- var geometry_1 = require("../geometry");
6
- var drawVertices_1 = require("./drawVertices");
7
- function drawWall(canvas, wall, style, mode) {
8
- var _a;
9
- var ctx = canvas.getContext('2d');
10
- if (!ctx)
11
- return;
12
- var path = (_a = wall.path) !== null && _a !== void 0 ? _a : (0, geometry_1.addThicknessToLine)(wall.line, style.thickness);
13
- var stroke = style.stroke, fill = style.fill, strokeWidth = style.strokeWidth;
14
- if (mode) {
15
- stroke = style[mode].stroke;
16
- fill = style[mode].fill;
17
- }
18
- ctx.strokeStyle = stroke || fill;
19
- ctx.fillStyle = fill;
20
- ctx.lineWidth = strokeWidth || 1;
21
- ctx.beginPath();
22
- ctx.moveTo.apply(ctx, path[0]);
23
- for (var i = 1; i < path.length; i++) {
24
- ctx.lineTo.apply(ctx, path[i]);
25
- }
26
- ctx.lineTo.apply(ctx, path[0]);
27
- ctx.fill();
28
- if (style.stroke && style.strokeWidth)
29
- ctx.stroke();
30
- }
31
- function drawNewWall(canvas, line, styles, mode) {
32
- drawWall(canvas, {
33
- line: line,
34
- path: (0, geometry_1.addThicknessToLine)(line, styles.wall.thickness),
35
- }, styles.wall, mode !== null && mode !== void 0 ? mode : types_1.IElementStyleModes.ACTIVE);
36
- line.forEach(function (point) {
37
- return (0, drawVertices_1.drawVertex)(canvas, point, styles.vertex, mode !== null && mode !== void 0 ? mode : types_1.IElementStyleModes.HIGHLIGHT);
38
- });
39
- }
40
- exports.drawNewWall = drawNewWall;
41
- function drawWalls(canvas, walls, selections, styles) {
42
- var styled = [
43
- selections.active,
44
- selections.highlighted,
45
- selections.error,
46
- selections.hidden,
47
- ];
48
- var defaultOpenings = walls.reduce(function (output, _, i) {
49
- if (!styled.flat().includes(i))
50
- output.push(i);
51
- return output;
52
- }, []);
53
- var wallsMap = [
54
- [types_1.IElementStyleModes.ACTIVE, selections.active],
55
- [types_1.IElementStyleModes.HIGHLIGHT, selections.highlighted],
56
- [types_1.IElementStyleModes.ERROR, selections.error],
57
- [undefined, defaultOpenings],
58
- ];
59
- wallsMap.forEach(function (_a) {
60
- var mode = _a[0], wallIndexes = _a[1];
61
- return wallIndexes.forEach(function (index) { return drawWall(canvas, walls[index], styles, mode); });
62
- });
63
- }
64
- exports.drawWalls = drawWalls;
@@ -1,9 +0,0 @@
1
- import { IFeature, ISpacesStyles } from '../types';
2
- import { IWallToDraw } from './drawWalls';
3
- declare function drawWindows(canvas: HTMLCanvasElement, walls: Array<IWallToDraw>, windows: Array<IFeature>, selections: {
4
- active: Array<number>;
5
- highlighted: Array<number>;
6
- error: Array<number>;
7
- hidden: Array<number>;
8
- }, styles: ISpacesStyles): void;
9
- export default drawWindows;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var geometry_1 = require("../geometry");
4
- var types_1 = require("../types");
5
- function drawWindow(canvas, wall, offset, length, style, mode) {
6
- var ctx = canvas.getContext('2d');
7
- if (!ctx)
8
- return;
9
- var windowLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(wall.line, offset, length);
10
- var windowRectangleLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(wall.line, offset + style.thickness / 2, length - style.thickness);
11
- var points = (0, geometry_1.addThicknessToLine)(windowLine, style.thickness);
12
- var rectanglePoints = (0, geometry_1.addThicknessToLine)(windowRectangleLine, style.thickness);
13
- var stroke = style.stroke, fill = style.fill, strokeWidth = style.strokeWidth;
14
- if (mode) {
15
- stroke = style[mode].stroke;
16
- fill = style[mode].fill;
17
- }
18
- ctx.fillStyle = 'white';
19
- ctx.beginPath();
20
- ctx.moveTo.apply(ctx, points[0]);
21
- for (var i = 1; i < points.length; i++) {
22
- ctx.lineTo.apply(ctx, points[i]);
23
- }
24
- ctx.lineTo.apply(ctx, points[0]);
25
- ctx.fill();
26
- ctx.closePath();
27
- ctx.strokeStyle = stroke || fill;
28
- ctx.fillStyle = fill;
29
- ctx.lineWidth = strokeWidth || 1;
30
- ctx.moveTo.apply(ctx, rectanglePoints[0]);
31
- ctx.beginPath();
32
- for (var i = 1; i < points.length; i++) {
33
- ctx.lineTo.apply(ctx, rectanglePoints[i]);
34
- }
35
- ctx.lineTo.apply(ctx, rectanglePoints[0]);
36
- ctx.fill();
37
- ctx.closePath();
38
- ctx.beginPath();
39
- ctx.moveTo.apply(ctx, windowLine[0]);
40
- ctx.lineTo.apply(ctx, windowLine[1]);
41
- if (style.stroke)
42
- ctx.stroke();
43
- ctx.closePath();
44
- var angle = (0, geometry_1.getAngleOfLineSegment)(windowLine);
45
- ctx.beginPath();
46
- ctx.arc(windowLine[0][0], windowLine[0][1], style.thickness / 2, angle - Math.PI / 2, angle + Math.PI / 2);
47
- ctx.fill();
48
- ctx.closePath();
49
- ctx.beginPath();
50
- ctx.arc(windowLine[1][0], windowLine[1][1], style.thickness / 2, angle + Math.PI / 2, angle - Math.PI / 2);
51
- ctx.fill();
52
- }
53
- function drawWindows(canvas, walls, windows, selections, styles) {
54
- var styled = [
55
- selections.active,
56
- selections.highlighted,
57
- selections.error,
58
- selections.hidden,
59
- ];
60
- var defaultOpenings = windows.reduce(function (output, _, i) {
61
- if (!styled.flat().includes(i))
62
- output.push(i);
63
- return output;
64
- }, []);
65
- var windowsMap = [
66
- [types_1.IElementStyleModes.ACTIVE, selections.active],
67
- [types_1.IElementStyleModes.HIGHLIGHT, selections.highlighted],
68
- [types_1.IElementStyleModes.ERROR, selections.error],
69
- [undefined, defaultOpenings],
70
- ];
71
- windowsMap.forEach(function (_a) {
72
- var mode = _a[0], windowIndexes = _a[1];
73
- return windowIndexes.forEach(function (index) {
74
- var window = windows[index];
75
- if (!(window === null || window === void 0 ? void 0 : window.connectedTo.length))
76
- return;
77
- var wallIndex = window.connectedTo[1];
78
- drawWindow(canvas, walls[wallIndex], window.offset, window.length, styles.feature, mode);
79
- });
80
- });
81
- }
82
- exports.default = drawWindows;
@@ -1,11 +0,0 @@
1
- import { IElementAddress, IEnclosedSpace, IFeatures, IGridToDraw, IGuides, ILineDimensions, ISpacesConfigInternal, IVertex } from '../types';
2
- import { drawDimensions } from './drawDimensions';
3
- import { drawVertex } from './drawVertices';
4
- import { IWallToDraw, drawNewWall } from './drawWalls';
5
- export { drawNewWall, drawVertex, drawDimensions };
6
- export declare function drawSpaces(canvas: HTMLCanvasElement, grid: IGridToDraw, enclosedSpaces: Array<IEnclosedSpace>, walls: Array<IWallToDraw>, vertices: Array<IVertex>, features: IFeatures, dimensions: Array<ILineDimensions> | undefined, guides: null | IGuides, selections: {
7
- active?: Array<IElementAddress> | IElementAddress;
8
- highlighted?: Array<IElementAddress> | IElementAddress;
9
- hidden?: Array<IElementAddress> | IElementAddress;
10
- error?: Array<IElementAddress> | IElementAddress;
11
- }, config: ISpacesConfigInternal): void;
@@ -1,129 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.drawSpaces = exports.drawDimensions = exports.drawVertex = exports.drawNewWall = void 0;
7
- var types_1 = require("../types");
8
- var clearCanvas_1 = __importDefault(require("./clearCanvas"));
9
- var drawBackground_1 = __importDefault(require("./drawBackground"));
10
- var drawDimensions_1 = require("./drawDimensions");
11
- Object.defineProperty(exports, "drawDimensions", { enumerable: true, get: function () { return drawDimensions_1.drawDimensions; } });
12
- var drawDoors_1 = __importDefault(require("./drawDoors"));
13
- var drawFloor_1 = require("./drawFloor");
14
- var drawGrid_1 = __importDefault(require("./drawGrid"));
15
- var drawGuides_1 = __importDefault(require("./drawGuides"));
16
- var drawOpenings_1 = __importDefault(require("./drawOpenings"));
17
- var drawVertices_1 = require("./drawVertices");
18
- Object.defineProperty(exports, "drawVertex", { enumerable: true, get: function () { return drawVertices_1.drawVertex; } });
19
- var drawWalls_1 = require("./drawWalls");
20
- Object.defineProperty(exports, "drawNewWall", { enumerable: true, get: function () { return drawWalls_1.drawNewWall; } });
21
- var drawWindows_1 = __importDefault(require("./drawWindows"));
22
- function drawElements(canvas, walls, vertices, features, selections, styles) {
23
- var wallSelections = {
24
- active: [],
25
- highlighted: [],
26
- hidden: [],
27
- error: [],
28
- };
29
- var verticesSelections = {
30
- active: [],
31
- highlighted: [],
32
- hidden: [],
33
- error: [],
34
- };
35
- var windowSelections = {
36
- active: [],
37
- highlighted: [],
38
- hidden: [],
39
- error: [],
40
- };
41
- var doorSelections = {
42
- active: [],
43
- highlighted: [],
44
- hidden: [],
45
- error: [],
46
- };
47
- var openingSelections = {
48
- active: [],
49
- highlighted: [],
50
- hidden: [],
51
- error: [],
52
- };
53
- selections.active.forEach(function (address) {
54
- if (address.type === types_1.IElements.WALL)
55
- wallSelections.active.push(address.index);
56
- else if (address.type === types_1.IElements.VERTEX)
57
- verticesSelections.active.push(address.index);
58
- else if (address.type === types_1.IElements.WINDOW)
59
- windowSelections.active.push(address.index);
60
- else if (address.type === types_1.IElements.DOOR)
61
- doorSelections.active.push(address.index);
62
- else if (address.type === types_1.IElements.OPENING)
63
- openingSelections.active.push(address.index);
64
- });
65
- selections.highlighted.forEach(function (address) {
66
- if (address.type === types_1.IElements.WALL)
67
- wallSelections.highlighted.push(address.index);
68
- else if (address.type === types_1.IElements.VERTEX)
69
- verticesSelections.highlighted.push(address.index);
70
- else if (address.type === types_1.IElements.WINDOW)
71
- windowSelections.highlighted.push(address.index);
72
- else if (address.type === types_1.IElements.DOOR)
73
- doorSelections.highlighted.push(address.index);
74
- else if (address.type === types_1.IElements.OPENING)
75
- openingSelections.highlighted.push(address.index);
76
- });
77
- selections.hidden.forEach(function (address) {
78
- if (address.type === types_1.IElements.WALL)
79
- wallSelections.hidden.push(address.index);
80
- else if (address.type === types_1.IElements.VERTEX)
81
- verticesSelections.hidden.push(address.index);
82
- else if (address.type === types_1.IElements.WINDOW)
83
- windowSelections.hidden.push(address.index);
84
- else if (address.type === types_1.IElements.DOOR)
85
- doorSelections.hidden.push(address.index);
86
- else if (address.type === types_1.IElements.OPENING)
87
- openingSelections.hidden.push(address.index);
88
- });
89
- selections.error.forEach(function (address) {
90
- if (address.type === types_1.IElements.WALL)
91
- wallSelections.error.push(address.index);
92
- else if (address.type === types_1.IElements.VERTEX)
93
- verticesSelections.error.push(address.index);
94
- else if (address.type === types_1.IElements.WINDOW)
95
- windowSelections.error.push(address.index);
96
- else if (address.type === types_1.IElements.DOOR)
97
- doorSelections.error.push(address.index);
98
- else if (address.type === types_1.IElements.OPENING)
99
- openingSelections.error.push(address.index);
100
- });
101
- (0, drawWalls_1.drawWalls)(canvas, walls, wallSelections, styles.wall);
102
- (0, drawVertices_1.drawVertices)(canvas, vertices, verticesSelections, styles.vertex);
103
- if (features[types_1.IElements.WINDOW])
104
- (0, drawWindows_1.default)(canvas, walls, features[types_1.IElements.WINDOW] || [], windowSelections, styles);
105
- if (features[types_1.IElements.DOOR])
106
- (0, drawDoors_1.default)(canvas, walls, features[types_1.IElements.DOOR] || [], doorSelections, styles);
107
- if (features[types_1.IElements.OPENING])
108
- (0, drawOpenings_1.default)(canvas, walls, features[types_1.IElements.OPENING] || [], openingSelections, styles);
109
- }
110
- function drawSpaces(canvas, grid, enclosedSpaces, walls, vertices, features, dimensions, guides, selections, config) {
111
- var preppedSelections = {
112
- active: [(selections === null || selections === void 0 ? void 0 : selections.active) || []].flat(),
113
- highlighted: [(selections === null || selections === void 0 ? void 0 : selections.highlighted) || []].flat(),
114
- error: [(selections === null || selections === void 0 ? void 0 : selections.error) || []].flat(),
115
- hidden: [(selections === null || selections === void 0 ? void 0 : selections.hidden) || []].flat(),
116
- };
117
- (0, clearCanvas_1.default)(canvas);
118
- (0, drawBackground_1.default)(canvas, config.styles.grid.backgroundColor);
119
- (0, drawGrid_1.default)(canvas, grid, config.styles.grid);
120
- (0, drawFloor_1.drawFloor)(canvas, enclosedSpaces, config.styles.floor);
121
- drawElements(canvas, walls, vertices, features, preppedSelections, config.styles);
122
- if (dimensions) {
123
- (0, drawDimensions_1.drawDimensions)(canvas, dimensions, config);
124
- (0, drawFloor_1.drawFloorArea)(canvas, enclosedSpaces, config.styles.floor);
125
- }
126
- if (guides)
127
- (0, drawGuides_1.default)(canvas, guides.point, guides.orientations, config.styles.guides);
128
- }
129
- exports.drawSpaces = drawSpaces;
@@ -1,3 +0,0 @@
1
- import { ICoordinatesLine, ICoordinatesQuadrilateral } from '../types';
2
- declare function addThicknessToLine(line: ICoordinatesLine, thickness: number): ICoordinatesQuadrilateral;
3
- export default addThicknessToLine;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var getParallelLineSegmentAtDistance_1 = __importDefault(require("./getParallelLineSegmentAtDistance"));
7
- function addThicknessToLine(line, thickness) {
8
- var offset = thickness / 2;
9
- var _a = (0, getParallelLineSegmentAtDistance_1.default)(line, offset), point1 = _a[0], point2 = _a[1];
10
- var _b = (0, getParallelLineSegmentAtDistance_1.default)(line, -offset), point4 = _b[0], point3 = _b[1];
11
- return [point1, point2, point3, point4];
12
- }
13
- exports.default = addThicknessToLine;
@@ -1,3 +0,0 @@
1
- import { ICoordinatesLine } from '../types';
2
- declare function areLinesEqual(line1: ICoordinatesLine, line2: ICoordinatesLine): boolean;
3
- export default areLinesEqual;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var arePointsEqual_1 = __importDefault(require("./arePointsEqual"));
7
- function areLinesEqual(line1, line2) {
8
- if (!line1 || !line2)
9
- return false;
10
- if (((0, arePointsEqual_1.default)(line1[0], line2[0]) &&
11
- (0, arePointsEqual_1.default)(line1[1], line2[1])) ||
12
- ((0, arePointsEqual_1.default)(line1[0], line2[1]) && (0, arePointsEqual_1.default)(line1[1], line2[0]))) {
13
- return true;
14
- }
15
- return false;
16
- }
17
- exports.default = areLinesEqual;
@@ -1,3 +0,0 @@
1
- import { ICoordinate2D } from '../types';
2
- declare function arePointsEqual(point1: ICoordinate2D, point2: ICoordinate2D): boolean;
3
- export default arePointsEqual;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function arePointsEqual(point1, point2) {
4
- if (!point1 || !point2)
5
- return false;
6
- return point1[0] === point2[0] && point1[1] === point2[1];
7
- }
8
- exports.default = arePointsEqual;
@@ -1,3 +0,0 @@
1
- import { ICoordinate2D } from '../types';
2
- declare function arePointsWithinProximity(point1: ICoordinate2D, point2: ICoordinate2D, proximity: number): boolean;
3
- export default arePointsWithinProximity;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var getLengthOfLineSegment_1 = __importDefault(require("./getLengthOfLineSegment"));
7
- function arePointsWithinProximity(point1, point2, proximity) {
8
- var length = (0, getLengthOfLineSegment_1.default)([point1, point2]);
9
- return length <= proximity;
10
- }
11
- exports.default = arePointsWithinProximity;
@@ -1,3 +0,0 @@
1
- import { ICoordinate2D } from '../types';
2
- declare function closestPointOnLine(pointOnLine: ICoordinate2D, angle: number, point: ICoordinate2D): ICoordinate2D;
3
- export default closestPointOnLine;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function closestPointOnLine(pointOnLine, angle, point) {
4
- var x1 = point[0], y1 = point[1];
5
- var x2 = pointOnLine[0], y2 = pointOnLine[1];
6
- var dx = Math.cos(angle);
7
- var dy = Math.sin(angle);
8
- var t = ((x1 - x2) * dx + (y1 - y2) * dy) / (dx * dx + dy * dy);
9
- var x = x2 + t * dx;
10
- var y = y2 + t * dy;
11
- return [x, y];
12
- }
13
- exports.default = closestPointOnLine;
@@ -1,2 +0,0 @@
1
- declare function doLinesOverlap(line1: [offset: number, length: number], line2: [offset: number, length: number]): boolean;
2
- export default doLinesOverlap;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function doLinesOverlap(line1, line2) {
4
- var start1 = line1[0];
5
- var end1 = line1[0] + line1[1];
6
- var start2 = line2[0];
7
- var end2 = line2[0] + line2[1];
8
- if (start2 < start1 && start1 < end2)
9
- return true;
10
- if (start2 < end1 && end1 < end2)
11
- return true;
12
- if (start1 < start2 && start2 < end1 && start1 < end2 && end2 < end1)
13
- return true;
14
- return false;
15
- }
16
- exports.default = doLinesOverlap;
@@ -1,2 +0,0 @@
1
- declare function euclideanMod(number: number, mod: number): number;
2
- export default euclideanMod;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function euclideanMod(number, mod) {
4
- return ((number % mod) + mod) % mod;
5
- }
6
- exports.default = euclideanMod;
@@ -1,6 +0,0 @@
1
- import type { ICoordinate2D, ICoordinatesLine } from '../types';
2
- declare function findLoops(lines: Array<ICoordinatesLine>): {
3
- inner: Array<ICoordinate2D[]>;
4
- outer: Array<ICoordinate2D[]>;
5
- };
6
- export default findLoops;
@@ -1,6 +0,0 @@
1
- import { ICoordinate2D, ICoordinatesLine } from '../types';
2
- declare function getAllLineIntersections(line: ICoordinatesLine, lines: Array<ICoordinatesLine | null>): {
3
- index: number;
4
- point: ICoordinate2D;
5
- }[];
6
- export default getAllLineIntersections;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var getLineSegmentsIntersection_1 = __importDefault(require("./getLineSegmentsIntersection"));
7
- function getAllLineIntersections(line, lines) {
8
- var lineStr = [JSON.stringify(line[0]), JSON.stringify(line[1])];
9
- return lines.reduce(function (output, existingLine, i) {
10
- if (existingLine === null)
11
- return output;
12
- var startStr = JSON.stringify(existingLine[0]);
13
- var endStr = JSON.stringify(existingLine[1]);
14
- if (lineStr.includes(startStr) || lineStr.includes(endStr))
15
- return output;
16
- var intersectionPoint = (0, getLineSegmentsIntersection_1.default)(line, existingLine);
17
- if (!intersectionPoint)
18
- return output;
19
- output.push({ index: i, point: intersectionPoint });
20
- return output;
21
- }, []);
22
- }
23
- exports.default = getAllLineIntersections;
@@ -1,3 +0,0 @@
1
- import { ICoordinatesLine } from '../types';
2
- declare function getAngleOfLineSegment(line: ICoordinatesLine): number;
3
- export default getAngleOfLineSegment;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function getAngleOfLineSegment(line) {
4
- var _a = line.flat(), x1 = _a[0], y1 = _a[1], x2 = _a[2], y2 = _a[3];
5
- return Math.atan2(y2 - y1, x2 - x1);
6
- }
7
- exports.default = getAngleOfLineSegment;
@@ -1,3 +0,0 @@
1
- import { ICoordinate2D, ICoordinatesLine } from '../types';
2
- declare function getClosestPointOnLineSegment(line: ICoordinatesLine, point: ICoordinate2D): undefined | ICoordinate2D;
3
- export default getClosestPointOnLineSegment;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function getClosestPointOnLineSegment(line, point) {
4
- var _a = line.flat(), x1 = _a[0], y1 = _a[1], x2 = _a[2], y2 = _a[3];
5
- var lineVector = [x2 - x1, y2 - y1];
6
- var pointVector = [point[0] - x1, point[1] - y1];
7
- var lineLength = Math.pow(lineVector[0], 2) + Math.pow(lineVector[1], 2);
8
- var dotProduct = (pointVector[0] * lineVector[0] + pointVector[1] * lineVector[1]) /
9
- lineLength;
10
- if (dotProduct < 0)
11
- return [x1, y1];
12
- if (dotProduct > 1)
13
- return [x2, y2];
14
- else
15
- return [x1 + dotProduct * lineVector[0], y1 + dotProduct * lineVector[1]];
16
- }
17
- exports.default = getClosestPointOnLineSegment;
@@ -1,3 +0,0 @@
1
- import { ICoordinate2D } from '../types';
2
- declare function getDistanceToLine(pointOnLine: ICoordinate2D, angle: number, point: ICoordinate2D): number;
3
- export default getDistanceToLine;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function getDistanceToLine(pointOnLine, angle, point) {
4
- var x1 = point[0], y1 = point[1];
5
- var x2 = pointOnLine[0], y2 = pointOnLine[1];
6
- var dx = Math.cos(angle);
7
- var dy = Math.sin(angle);
8
- return (Math.abs((y1 - y2) * dx - (x1 - x2) * dy) / Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)));
9
- }
10
- exports.default = getDistanceToLine;
@@ -1,3 +0,0 @@
1
- import { ICoordinatesLine } from '../types';
2
- declare function getLengthOfLineSegment(line: ICoordinatesLine): number;
3
- export default getLengthOfLineSegment;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function getLengthOfLineSegment(line) {
4
- var _a = line.flat(), x1 = _a[0], y1 = _a[1], x2 = _a[2], y2 = _a[3];
5
- return Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
6
- }
7
- exports.default = getLengthOfLineSegment;
@@ -1,3 +0,0 @@
1
- import { ICoordinatesLine } from '../types';
2
- declare function getLineAtOffsetOnLineSegment(line: ICoordinatesLine, offset: number, length: number): ICoordinatesLine;
3
- export default getLineAtOffsetOnLineSegment;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function getLineAtOffsetOnLineSegment(line, offset, length) {
4
- var _a = line.flat(), x1 = _a[0], y1 = _a[1], x2 = _a[2], y2 = _a[3];
5
- var d = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2));
6
- var startRatio = offset / d;
7
- var endRatio = (offset + length) / d;
8
- var startX = x1 + startRatio * (x2 - x1);
9
- var startY = y1 + startRatio * (y2 - y1);
10
- var endX = x1 + endRatio * (x2 - x1);
11
- var endY = y1 + endRatio * (y2 - y1);
12
- return [
13
- [startX, startY],
14
- [endX, endY],
15
- ];
16
- }
17
- exports.default = getLineAtOffsetOnLineSegment;
@@ -1,3 +0,0 @@
1
- import { ICoordinate2D, ICoordinatesLine } from '../types';
2
- declare function getLineOtherPoint(line: ICoordinatesLine, point: ICoordinate2D): ICoordinate2D;
3
- export default getLineOtherPoint;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var geometry_1 = require("../geometry");
4
- function getLineOtherPoint(line, point) {
5
- var eq0 = (0, geometry_1.arePointsEqual)(line[0], point);
6
- var eq1 = (0, geometry_1.arePointsEqual)(line[1], point);
7
- if (eq0 === eq1)
8
- console.warn('Unexpected. Is your wall of 0 length?', JSON.parse(JSON.stringify({ line: line, point: point })));
9
- return eq0 ? line[1] : line[0];
10
- }
11
- exports.default = getLineOtherPoint;
@@ -1,3 +0,0 @@
1
- import { ICoordinate2D, ICoordinatesLine } from '../types';
2
- declare function getLineSegmentsIntersection(line1: ICoordinatesLine, line2: ICoordinatesLine): null | ICoordinate2D;
3
- export default getLineSegmentsIntersection;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var arePointsEqual_1 = __importDefault(require("./arePointsEqual"));
7
- function getLineSegmentsIntersection(line1, line2) {
8
- if (arePointsEqual_1.default.apply(void 0, line1) || arePointsEqual_1.default.apply(void 0, line2))
9
- return null;
10
- if ((0, arePointsEqual_1.default)(line1[0], line2[0]))
11
- return null;
12
- if ((0, arePointsEqual_1.default)(line1[0], line2[1]))
13
- return null;
14
- if ((0, arePointsEqual_1.default)(line1[1], line2[0]))
15
- return null;
16
- if ((0, arePointsEqual_1.default)(line1[1], line2[1]))
17
- return null;
18
- var _a = line1.flat(), x1 = _a[0], y1 = _a[1], x2 = _a[2], y2 = _a[3];
19
- var _b = line2.flat(), x3 = _b[0], y3 = _b[1], x4 = _b[2], y4 = _b[3];
20
- var a1 = y2 - y1;
21
- var b1 = x1 - x2;
22
- var c1 = a1 * x1 + b1 * y1;
23
- var a2 = y4 - y3;
24
- var b2 = x3 - x4;
25
- var c2 = a2 * x3 + b2 * y3;
26
- var determinant = a1 * b2 - a2 * b1;
27
- if (determinant === 0)
28
- return null;
29
- var x = (b2 * c1 - b1 * c2) / determinant;
30
- var y = (a1 * c2 - a2 * c1) / determinant;
31
- if (x < Math.min(x1, x2) ||
32
- x > Math.max(x1, x2) ||
33
- x < Math.min(x3, x4) ||
34
- x > Math.max(x3, x4))
35
- return null;
36
- if (y < Math.min(y1, y2) ||
37
- y > Math.max(y1, y2) ||
38
- y < Math.min(y3, y4) ||
39
- y > Math.max(y3, y4))
40
- return null;
41
- return [x, y];
42
- }
43
- exports.default = getLineSegmentsIntersection;
@@ -1,3 +0,0 @@
1
- import { ICoordinate2D, ICoordinatesLine } from '../types';
2
- declare function getMidpointOfLineSegment(line: ICoordinatesLine): ICoordinate2D;
3
- export default getMidpointOfLineSegment;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function getMidpointOfLineSegment(line) {
4
- var _a = line.flat(), x1 = _a[0], y1 = _a[1], x2 = _a[2], y2 = _a[3];
5
- var xMidpoint = (x1 + x2) / 2;
6
- var yMidpoint = (y1 + y2) / 2;
7
- return [xMidpoint, yMidpoint];
8
- }
9
- exports.default = getMidpointOfLineSegment;