@threekit-tools/treble 0.0.95-next-01 → 0.0.96
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.
- package/dist/Treble/Treble.d.ts +2 -2
- package/dist/Treble/Treble.js +2 -2
- package/dist/Treble/index.d.ts +1 -1
- package/dist/Treble/index.js +1 -1
- package/dist/hooks/useNestedConfigurator/index.js +2 -1
- package/dist/hooks/useRoomBuilder/RoomBuilderState.d.ts +95 -0
- package/dist/hooks/useRoomBuilder/RoomBuilderState.js +1237 -0
- package/dist/hooks/useRoomBuilder/constants.d.ts +41 -0
- package/dist/hooks/useRoomBuilder/constants.js +48 -0
- package/dist/hooks/useRoomBuilder/dataHandlers.d.ts +18 -0
- package/dist/hooks/useRoomBuilder/dataHandlers.js +187 -0
- package/dist/hooks/useRoomBuilder/draw.d.ts +55 -0
- package/dist/hooks/useRoomBuilder/draw.js +573 -0
- package/dist/hooks/useRoomBuilder/findLoops.d.ts +5 -0
- package/dist/hooks/{useSpaces/geometry → useRoomBuilder}/findLoops.js +13 -31
- package/dist/hooks/useRoomBuilder/geometry.d.ts +33 -0
- package/dist/hooks/useRoomBuilder/geometry.js +325 -0
- package/dist/hooks/useRoomBuilder/index.d.ts +40 -0
- package/dist/hooks/useRoomBuilder/index.js +303 -0
- package/dist/hooks/{useSpaces/validators → useRoomBuilder}/messaging.js +1 -1
- package/dist/hooks/{useSpaces/themes/index.d.ts → useRoomBuilder/themes.d.ts} +4 -3
- package/dist/hooks/useRoomBuilder/themes.js +273 -0
- package/dist/hooks/useRoomBuilder/types.d.ts +238 -0
- package/dist/hooks/{useSpaces → useRoomBuilder}/types.js +1 -19
- package/dist/hooks/useRoomBuilder/validators.d.ts +36 -0
- package/dist/hooks/useRoomBuilder/validators.js +362 -0
- package/dist/icons/Draw.js +3 -3
- package/dist/icons/Window.js +4 -4
- package/dist/icons/index.js +0 -28
- package/dist/icons/types.d.ts +1 -1
- package/dist/index.d.ts +2 -17
- package/dist/index.js +5 -35
- package/dist/store/attributes.d.ts +0 -1
- package/dist/store/index.d.ts +0 -10
- package/dist/store/index.js +1 -3
- package/dist/store/product.js +7 -4
- package/dist/store/treble.d.ts +1 -1
- package/dist/store/treble.js +21 -14
- package/dist/types.d.ts +1 -3
- package/package.json +1 -1
- package/dist/hooks/useSpaces/SpacesLayout.d.ts +0 -11
- package/dist/hooks/useSpaces/SpacesLayout.js +0 -74
- package/dist/hooks/useSpaces/SpacesState.d.ts +0 -177
- package/dist/hooks/useSpaces/SpacesState.js +0 -1816
- package/dist/hooks/useSpaces/constants.d.ts +0 -79
- package/dist/hooks/useSpaces/constants.js +0 -130
- package/dist/hooks/useSpaces/dataHandlers.d.ts +0 -38
- package/dist/hooks/useSpaces/dataHandlers.js +0 -411
- package/dist/hooks/useSpaces/draw/clearCanvas.d.ts +0 -2
- package/dist/hooks/useSpaces/draw/clearCanvas.js +0 -9
- package/dist/hooks/useSpaces/draw/drawBackground.d.ts +0 -2
- package/dist/hooks/useSpaces/draw/drawBackground.js +0 -12
- package/dist/hooks/useSpaces/draw/drawDimensions.d.ts +0 -3
- package/dist/hooks/useSpaces/draw/drawDimensions.js +0 -53
- package/dist/hooks/useSpaces/draw/drawDoors.d.ts +0 -9
- package/dist/hooks/useSpaces/draw/drawDoors.js +0 -99
- package/dist/hooks/useSpaces/draw/drawFloor.d.ts +0 -3
- package/dist/hooks/useSpaces/draw/drawFloor.js +0 -36
- package/dist/hooks/useSpaces/draw/drawGrid.d.ts +0 -3
- package/dist/hooks/useSpaces/draw/drawGrid.js +0 -36
- package/dist/hooks/useSpaces/draw/drawGuides.d.ts +0 -3
- package/dist/hooks/useSpaces/draw/drawGuides.js +0 -23
- package/dist/hooks/useSpaces/draw/drawOpenings.d.ts +0 -9
- package/dist/hooks/useSpaces/draw/drawOpenings.js +0 -72
- package/dist/hooks/useSpaces/draw/drawVertices.d.ts +0 -8
- package/dist/hooks/useSpaces/draw/drawVertices.js +0 -61
- package/dist/hooks/useSpaces/draw/drawWalls.d.ts +0 -11
- package/dist/hooks/useSpaces/draw/drawWalls.js +0 -90
- package/dist/hooks/useSpaces/draw/drawWindows.d.ts +0 -9
- package/dist/hooks/useSpaces/draw/drawWindows.js +0 -82
- package/dist/hooks/useSpaces/draw/index.d.ts +0 -11
- package/dist/hooks/useSpaces/draw/index.js +0 -129
- package/dist/hooks/useSpaces/geometry/addThicknessToLine.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/addThicknessToLine.js +0 -13
- package/dist/hooks/useSpaces/geometry/areLinesEqual.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/areLinesEqual.js +0 -17
- package/dist/hooks/useSpaces/geometry/arePointsEqual.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/arePointsEqual.js +0 -8
- package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/arePointsWithinProximity.js +0 -11
- package/dist/hooks/useSpaces/geometry/closestPointOnLine.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/closestPointOnLine.js +0 -13
- package/dist/hooks/useSpaces/geometry/doLinesOverlap.d.ts +0 -2
- package/dist/hooks/useSpaces/geometry/doLinesOverlap.js +0 -16
- package/dist/hooks/useSpaces/geometry/euclideanMod.d.ts +0 -2
- package/dist/hooks/useSpaces/geometry/euclideanMod.js +0 -6
- package/dist/hooks/useSpaces/geometry/findLoops.d.ts +0 -6
- package/dist/hooks/useSpaces/geometry/getAllLineIntersections.d.ts +0 -6
- package/dist/hooks/useSpaces/geometry/getAllLineIntersections.js +0 -23
- package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getAngleOfLineSegment.js +0 -7
- package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getClosestPointOnLineSegment.js +0 -17
- package/dist/hooks/useSpaces/geometry/getDistanceToLine.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getDistanceToLine.js +0 -10
- package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getLengthOfLineSegment.js +0 -7
- package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getLineAtOffsetOnLineSegment.js +0 -17
- package/dist/hooks/useSpaces/geometry/getLineOtherPoint.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getLineOtherPoint.js +0 -11
- package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getLineSegmentsIntersection.js +0 -43
- package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getMidpointOfLineSegment.js +0 -9
- package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getParallelLineSegmentAtDistance.js +0 -20
- package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getPointAtOffsetOnLineSegment.js +0 -11
- package/dist/hooks/useSpaces/geometry/getPolygonArea.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getPolygonArea.js +0 -15
- package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getQuadrilateralArea.js +0 -16
- package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.d.ts +0 -6
- package/dist/hooks/useSpaces/geometry/getTangetIntersectionAndOffset.js +0 -17
- package/dist/hooks/useSpaces/geometry/getTriangleArea.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getTriangleArea.js +0 -9
- package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/getUnitVectorOfLineSegment.js +0 -12
- package/dist/hooks/useSpaces/geometry/index.d.ts +0 -30
- package/dist/hooks/useSpaces/geometry/index.js +0 -64
- package/dist/hooks/useSpaces/geometry/isPointInPolygon.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/isPointInPolygon.js +0 -21
- package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/isPointInQuadrilateral.js +0 -25
- package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/orderCoordinatesOnLineSegment.js +0 -11
- package/dist/hooks/useSpaces/geometry/splitLineAtOffset.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/splitLineAtOffset.js +0 -12
- package/dist/hooks/useSpaces/geometry/splitLineAtPoint.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/splitLineAtPoint.js +0 -9
- package/dist/hooks/useSpaces/geometry/splitLineAtPoints.d.ts +0 -3
- package/dist/hooks/useSpaces/geometry/splitLineAtPoints.js +0 -28
- package/dist/hooks/useSpaces/index.d.ts +0 -95
- package/dist/hooks/useSpaces/index.js +0 -625
- package/dist/hooks/useSpaces/themes/blueprint.d.ts +0 -3
- package/dist/hooks/useSpaces/themes/blueprint.js +0 -96
- package/dist/hooks/useSpaces/themes/default.d.ts +0 -3
- package/dist/hooks/useSpaces/themes/default.js +0 -96
- package/dist/hooks/useSpaces/themes/index.js +0 -21
- package/dist/hooks/useSpaces/themes/light.d.ts +0 -3
- package/dist/hooks/useSpaces/themes/light.js +0 -96
- package/dist/hooks/useSpaces/types.d.ts +0 -378
- package/dist/hooks/useSpaces/validators/areWallsDuplicated.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/areWallsDuplicated.js +0 -61
- package/dist/hooks/useSpaces/validators/areWallsIntersecting.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/areWallsIntersecting.js +0 -42
- package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/areWallsOrphaningFeatures.js +0 -52
- package/dist/hooks/useSpaces/validators/areWallsTooShort.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/areWallsTooShort.js +0 -37
- package/dist/hooks/useSpaces/validators/index.d.ts +0 -15
- package/dist/hooks/useSpaces/validators/index.js +0 -40
- package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isFeatureCollidingWithExistingFeature.js +0 -31
- package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isFeatureOutsideWallBounds.js +0 -19
- package/dist/hooks/useSpaces/validators/isLineTooShort.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isLineTooShort.js +0 -26
- package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.d.ts +0 -4
- package/dist/hooks/useSpaces/validators/isVertexLandingOnFeature.js +0 -19
- package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isWallEndingOnFeature.js +0 -19
- package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isWallIntersectingFeature.js +0 -41
- package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isWallOverlappingExisitingWalls.js +0 -54
- package/dist/hooks/useSpaces/validators/isWallTooShort.d.ts +0 -3
- package/dist/hooks/useSpaces/validators/isWallTooShort.js +0 -10
- package/dist/icons/AngleSnapping.d.ts +0 -3
- package/dist/icons/AngleSnapping.js +0 -28
- package/dist/icons/Boundary.d.ts +0 -3
- package/dist/icons/Boundary.js +0 -21
- package/dist/icons/Center.d.ts +0 -3
- package/dist/icons/Center.js +0 -24
- package/dist/icons/GridSnapping.d.ts +0 -3
- package/dist/icons/GridSnapping.js +0 -28
- package/dist/icons/LayoutAlt.d.ts +0 -3
- package/dist/icons/LayoutAlt.js +0 -21
- package/dist/icons/Magnet.d.ts +0 -3
- package/dist/icons/Magnet.js +0 -27
- package/dist/icons/Player3D.d.ts +0 -3
- package/dist/icons/Player3D.js +0 -21
- package/dist/icons/RulerBlank.d.ts +0 -3
- package/dist/icons/RulerBlank.js +0 -25
- package/dist/icons/RulerDetailed.d.ts +0 -3
- package/dist/icons/RulerDetailed.js +0 -27
- package/dist/icons/Save.d.ts +0 -3
- package/dist/icons/Save.js +0 -21
- package/dist/icons/UnitCm.d.ts +0 -3
- package/dist/icons/UnitCm.js +0 -22
- package/dist/icons/UnitFeet.d.ts +0 -3
- package/dist/icons/UnitFeet.js +0 -22
- package/dist/icons/UnitInch.d.ts +0 -3
- package/dist/icons/UnitInch.js +0 -22
- package/dist/icons/UnitMeter.d.ts +0 -3
- package/dist/icons/UnitMeter.js +0 -21
- package/dist/store/spaces.d.ts +0 -74
- package/dist/store/spaces.js +0 -354
- /package/dist/Treble/{snapshot.d.ts → snapshots.d.ts} +0 -0
- /package/dist/Treble/{snapshot.js → snapshots.js} +0 -0
- /package/dist/hooks/{useSpaces/validators → useRoomBuilder}/messaging.d.ts +0 -0
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function drawBackground(canvas, color) {
|
|
4
|
-
if (!color)
|
|
5
|
-
return;
|
|
6
|
-
var ctx = canvas.getContext('2d');
|
|
7
|
-
if (!ctx)
|
|
8
|
-
return;
|
|
9
|
-
ctx.fillStyle = color;
|
|
10
|
-
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
11
|
-
}
|
|
12
|
-
exports.default = drawBackground;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { ICoordinatesLine, ILineDimensions, ISpacesConfigInternal, IStylesDimension } from '../types';
|
|
2
|
-
export declare function drawDimension(canvas: HTMLCanvasElement, line: ICoordinatesLine, styles: IStylesDimension, message: string): void;
|
|
3
|
-
export declare function drawDimensions(canvas: HTMLCanvasElement, dimensions: Array<ILineDimensions>, config: ISpacesConfigInternal): void;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.drawDimensions = exports.drawDimension = void 0;
|
|
4
|
-
var geometry_1 = require("../geometry");
|
|
5
|
-
function drawDimension(canvas, line, styles, message) {
|
|
6
|
-
var ctx = canvas.getContext('2d');
|
|
7
|
-
if (!ctx)
|
|
8
|
-
return;
|
|
9
|
-
var dimensionsBoxHeight = styles.fontSize + 6;
|
|
10
|
-
var dimensionsHeight = dimensionsBoxHeight + 6;
|
|
11
|
-
var line1 = (0, geometry_1.getParallelLineSegmentAtDistance)(line, styles.padding);
|
|
12
|
-
var line2 = (0, geometry_1.getParallelLineSegmentAtDistance)(line, styles.padding + dimensionsHeight / 2);
|
|
13
|
-
var line3 = (0, geometry_1.getParallelLineSegmentAtDistance)(line, styles.padding + dimensionsHeight);
|
|
14
|
-
var textLine = (0, geometry_1.getParallelLineSegmentAtDistance)(line, styles.padding + dimensionsHeight / 3);
|
|
15
|
-
var textCoordinates = (0, geometry_1.getMidpointOfLineSegment)(textLine);
|
|
16
|
-
var textAngle = (0, geometry_1.getAngleOfLineSegment)(textLine);
|
|
17
|
-
if (2 < textAngle || textAngle < -2)
|
|
18
|
-
textAngle += Math.PI;
|
|
19
|
-
ctx.strokeStyle = styles.lineColor;
|
|
20
|
-
ctx.lineWidth = 1;
|
|
21
|
-
ctx.beginPath();
|
|
22
|
-
ctx.moveTo.apply(ctx, line2[0]);
|
|
23
|
-
ctx.lineTo.apply(ctx, line2[1]);
|
|
24
|
-
ctx.stroke();
|
|
25
|
-
ctx.beginPath();
|
|
26
|
-
ctx.moveTo.apply(ctx, line1[0]);
|
|
27
|
-
ctx.lineTo.apply(ctx, line3[0]);
|
|
28
|
-
ctx.stroke();
|
|
29
|
-
ctx.beginPath();
|
|
30
|
-
ctx.moveTo.apply(ctx, line1[1]);
|
|
31
|
-
ctx.lineTo.apply(ctx, line3[1]);
|
|
32
|
-
ctx.stroke();
|
|
33
|
-
ctx.beginPath();
|
|
34
|
-
ctx.font = "".concat(styles.fontSize, "px ").concat(styles.font);
|
|
35
|
-
ctx.font = "".concat(styles.fontSize, "px ").concat(styles.font);
|
|
36
|
-
ctx.translate.apply(ctx, textCoordinates);
|
|
37
|
-
ctx.rotate(textAngle);
|
|
38
|
-
ctx.fillStyle = styles.textBackgroundColor;
|
|
39
|
-
var textWidth = ctx.measureText(message).width + 12;
|
|
40
|
-
ctx.fillRect(-(textWidth / 2), -((dimensionsBoxHeight * 3) / 4), textWidth, dimensionsBoxHeight);
|
|
41
|
-
ctx.fillStyle = styles.textColor;
|
|
42
|
-
ctx.textAlign = 'center';
|
|
43
|
-
ctx.fillText(message, 0, 0);
|
|
44
|
-
ctx.resetTransform();
|
|
45
|
-
}
|
|
46
|
-
exports.drawDimension = drawDimension;
|
|
47
|
-
function drawDimensions(canvas, dimensions, config) {
|
|
48
|
-
dimensions.forEach(function (_a) {
|
|
49
|
-
var line = _a.line, label = _a.label;
|
|
50
|
-
drawDimension(canvas, line, config.styles.dimensions, label);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
exports.drawDimensions = drawDimensions;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IFeatureDoor, ISpacesStyles } from '../types';
|
|
2
|
-
import { IWallToDraw } from './drawWalls';
|
|
3
|
-
declare function drawDoors(canvas: HTMLCanvasElement, walls: Array<IWallToDraw>, doors: Array<IFeatureDoor>, selections: {
|
|
4
|
-
active: Array<number>;
|
|
5
|
-
highlighted: Array<number>;
|
|
6
|
-
error: Array<number>;
|
|
7
|
-
hidden: Array<number>;
|
|
8
|
-
}, styles: ISpacesStyles): void;
|
|
9
|
-
export default drawDoors;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
-
if (ar || !(i in from)) {
|
|
5
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
-
ar[i] = from[i];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
var constants_1 = require("../constants");
|
|
13
|
-
var geometry_1 = require("../geometry");
|
|
14
|
-
var types_1 = require("../types");
|
|
15
|
-
function drawDoor(canvas, wall, offset, length, showSwing, openingDirection, orientation, style, mode) {
|
|
16
|
-
var ctx = canvas.getContext('2d');
|
|
17
|
-
if (!ctx)
|
|
18
|
-
return;
|
|
19
|
-
var doorLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(wall.line, offset, length);
|
|
20
|
-
var points = (0, geometry_1.addThicknessToLine)(doorLine, style.thickness);
|
|
21
|
-
var angle = (0, geometry_1.getAngleOfLineSegment)(doorLine);
|
|
22
|
-
var stroke = style.stroke, fill = style.fill, strokeWidth = style.strokeWidth;
|
|
23
|
-
if (mode) {
|
|
24
|
-
stroke = style[mode].stroke;
|
|
25
|
-
fill = style[mode].fill;
|
|
26
|
-
}
|
|
27
|
-
ctx.beginPath();
|
|
28
|
-
ctx.strokeStyle = stroke || fill;
|
|
29
|
-
ctx.lineWidth = 2;
|
|
30
|
-
var swingRatio = showSwing === constants_1.DoorShowSwing.SHOW ? 2 : 48;
|
|
31
|
-
if (openingDirection === constants_1.DoorOpeningDirections.INSIDE) {
|
|
32
|
-
if (orientation === constants_1.DoorOrientations.LEFT) {
|
|
33
|
-
ctx.moveTo.apply(ctx, points[0]);
|
|
34
|
-
ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[0], false), [length, angle - Math.PI / swingRatio, angle], false));
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
ctx.moveTo.apply(ctx, points[1]);
|
|
38
|
-
ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[1], false), [length,
|
|
39
|
-
angle - (Math.PI * (swingRatio - 1)) / swingRatio,
|
|
40
|
-
angle - Math.PI,
|
|
41
|
-
true], false));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
if (orientation === constants_1.DoorOrientations.LEFT) {
|
|
46
|
-
ctx.moveTo.apply(ctx, points[2]);
|
|
47
|
-
ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[2], false), [length,
|
|
48
|
-
angle + (Math.PI * (swingRatio - 1)) / swingRatio,
|
|
49
|
-
angle + Math.PI], false));
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
ctx.moveTo.apply(ctx, points[3]);
|
|
53
|
-
ctx.arc.apply(ctx, __spreadArray(__spreadArray([], points[3], false), [length, angle + Math.PI / swingRatio, angle, true], false));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
ctx.stroke();
|
|
57
|
-
ctx.strokeStyle = stroke || fill;
|
|
58
|
-
ctx.fillStyle = fill;
|
|
59
|
-
ctx.lineWidth = strokeWidth || 1;
|
|
60
|
-
ctx.beginPath();
|
|
61
|
-
ctx.moveTo.apply(ctx, points[0]);
|
|
62
|
-
for (var i = 1; i < points.length; i++) {
|
|
63
|
-
ctx.lineTo.apply(ctx, points[i]);
|
|
64
|
-
}
|
|
65
|
-
ctx.lineTo.apply(ctx, points[0]);
|
|
66
|
-
ctx.fill();
|
|
67
|
-
if (style.stroke)
|
|
68
|
-
ctx.stroke();
|
|
69
|
-
}
|
|
70
|
-
function drawDoors(canvas, walls, doors, selections, styles) {
|
|
71
|
-
var styled = [
|
|
72
|
-
selections.active,
|
|
73
|
-
selections.highlighted,
|
|
74
|
-
selections.error,
|
|
75
|
-
selections.hidden,
|
|
76
|
-
];
|
|
77
|
-
var defaultOpenings = doors.reduce(function (output, _, i) {
|
|
78
|
-
if (!styled.flat().includes(i))
|
|
79
|
-
output.push(i);
|
|
80
|
-
return output;
|
|
81
|
-
}, []);
|
|
82
|
-
var doorsMap = [
|
|
83
|
-
[types_1.IElementStyleModes.ACTIVE, selections.active],
|
|
84
|
-
[types_1.IElementStyleModes.HIGHLIGHT, selections.highlighted],
|
|
85
|
-
[types_1.IElementStyleModes.ERROR, selections.error],
|
|
86
|
-
[undefined, defaultOpenings],
|
|
87
|
-
];
|
|
88
|
-
doorsMap.forEach(function (_a) {
|
|
89
|
-
var mode = _a[0], doorsIndexes = _a[1];
|
|
90
|
-
return doorsIndexes.forEach(function (index) {
|
|
91
|
-
var door = doors[index];
|
|
92
|
-
if (!(door === null || door === void 0 ? void 0 : door.connectedTo.length))
|
|
93
|
-
return;
|
|
94
|
-
var wallIndex = door.connectedTo[1];
|
|
95
|
-
drawDoor(canvas, walls[wallIndex], door.offset, door.length, door.showSwing, door.openingDirection, door.orientation, styles.feature, mode);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
exports.default = drawDoors;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { IEnclosedSpace, IStylesFloor } from '../types';
|
|
2
|
-
export declare function drawFloor(canvas: HTMLCanvasElement, enclosedSpaces: Array<IEnclosedSpace>, styles: IStylesFloor): void;
|
|
3
|
-
export declare function drawFloorArea(canvas: HTMLCanvasElement, enclosedSpaces: Array<IEnclosedSpace>, styles: IStylesFloor): void;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.drawFloorArea = exports.drawFloor = void 0;
|
|
4
|
-
function drawFloor(canvas, enclosedSpaces, styles) {
|
|
5
|
-
var ctx = canvas.getContext('2d');
|
|
6
|
-
if (!ctx)
|
|
7
|
-
return;
|
|
8
|
-
if (!enclosedSpaces.length)
|
|
9
|
-
return;
|
|
10
|
-
for (var _i = 0, enclosedSpaces_1 = enclosedSpaces; _i < enclosedSpaces_1.length; _i++) {
|
|
11
|
-
var enclosedSpace = enclosedSpaces_1[_i];
|
|
12
|
-
var loop = enclosedSpace.loop;
|
|
13
|
-
ctx.fillStyle = styles.color;
|
|
14
|
-
ctx.beginPath();
|
|
15
|
-
ctx.moveTo.apply(ctx, loop[0]);
|
|
16
|
-
for (var i = 1; i < loop.length; i++)
|
|
17
|
-
ctx.lineTo.apply(ctx, loop[i]);
|
|
18
|
-
ctx.fill();
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.drawFloor = drawFloor;
|
|
22
|
-
function drawFloorArea(canvas, enclosedSpaces, styles) {
|
|
23
|
-
var ctx = canvas.getContext('2d');
|
|
24
|
-
if (!ctx)
|
|
25
|
-
return;
|
|
26
|
-
if (!enclosedSpaces.length)
|
|
27
|
-
return;
|
|
28
|
-
for (var _i = 0, enclosedSpaces_2 = enclosedSpaces; _i < enclosedSpaces_2.length; _i++) {
|
|
29
|
-
var enclosedSpace = enclosedSpaces_2[_i];
|
|
30
|
-
var center = enclosedSpace.center, area = enclosedSpace.area;
|
|
31
|
-
ctx.font = '20px Arial';
|
|
32
|
-
ctx.fillStyle = styles.textColor;
|
|
33
|
-
ctx.fillText(area, center[0], center[1]);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.drawFloorArea = drawFloorArea;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function drawGrid(canvas, grid, styles) {
|
|
4
|
-
var ctx = canvas.getContext('2d');
|
|
5
|
-
if (!ctx)
|
|
6
|
-
return;
|
|
7
|
-
var unitLength = grid.unitLength, subdivisions = grid.subdivisions;
|
|
8
|
-
var showSubdivisions = styles.showSubdivisions &&
|
|
9
|
-
unitLength / subdivisions > styles.subdivisionThreshold;
|
|
10
|
-
var length = showSubdivisions ? unitLength / subdivisions : unitLength;
|
|
11
|
-
var offset = showSubdivisions
|
|
12
|
-
? [grid.offset[0] % length, grid.offset[1] % length]
|
|
13
|
-
: grid.offset;
|
|
14
|
-
ctx.strokeStyle = styles.lineColor;
|
|
15
|
-
var numHorizontalLines = Math.ceil(canvas.height / length) +
|
|
16
|
-
1 * (showSubdivisions ? subdivisions : 1);
|
|
17
|
-
var numVerticalLines = Math.ceil(canvas.width / length) +
|
|
18
|
-
1 * (showSubdivisions ? subdivisions : 1);
|
|
19
|
-
for (var i = 0; i < numHorizontalLines; i++) {
|
|
20
|
-
var y = i * length + offset[1];
|
|
21
|
-
ctx.lineWidth = showSubdivisions && i % subdivisions === 0 ? 2 : 1;
|
|
22
|
-
ctx.beginPath();
|
|
23
|
-
ctx.moveTo(0, y);
|
|
24
|
-
ctx.lineTo(canvas.width, y);
|
|
25
|
-
ctx.stroke();
|
|
26
|
-
}
|
|
27
|
-
for (var i = 0; i < numVerticalLines; i++) {
|
|
28
|
-
var x = i * length + offset[0];
|
|
29
|
-
ctx.lineWidth = showSubdivisions && i % subdivisions === 0 ? 2 : 1;
|
|
30
|
-
ctx.beginPath();
|
|
31
|
-
ctx.moveTo(x, 0);
|
|
32
|
-
ctx.lineTo(x, canvas.height);
|
|
33
|
-
ctx.stroke();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.default = drawGrid;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var types_1 = require("../types");
|
|
4
|
-
function drawGuides(canvas, point, orientations, style) {
|
|
5
|
-
var ctx = canvas.getContext('2d');
|
|
6
|
-
if (!ctx)
|
|
7
|
-
return;
|
|
8
|
-
ctx.strokeStyle = style.color;
|
|
9
|
-
ctx.lineWidth = style.thickness;
|
|
10
|
-
if (orientations.includes(types_1.GUIDE_ORIENTATIONS.VERTICAL)) {
|
|
11
|
-
ctx.beginPath();
|
|
12
|
-
ctx.moveTo(point[0], 0);
|
|
13
|
-
ctx.lineTo(point[0], canvas.height);
|
|
14
|
-
ctx.stroke();
|
|
15
|
-
}
|
|
16
|
-
if (orientations.includes(types_1.GUIDE_ORIENTATIONS.HORIZONTAL)) {
|
|
17
|
-
ctx.beginPath();
|
|
18
|
-
ctx.moveTo(0, point[1]);
|
|
19
|
-
ctx.lineTo(canvas.width, point[1]);
|
|
20
|
-
ctx.stroke();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.default = drawGuides;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { IFeature, ISpacesStyles } from '../types';
|
|
2
|
-
import { IWallToDraw } from './drawWalls';
|
|
3
|
-
declare function drawOpenings(canvas: HTMLCanvasElement, walls: Array<IWallToDraw>, openings: 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 drawOpenings;
|
|
@@ -1,72 +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 drawOpening(canvas, wall, offset, length, style, mode) {
|
|
6
|
-
var ctx = canvas.getContext('2d');
|
|
7
|
-
if (!ctx)
|
|
8
|
-
return;
|
|
9
|
-
var openingLine = (0, geometry_1.getLineAtOffsetOnLineSegment)(wall.line, offset, length);
|
|
10
|
-
var points = (0, geometry_1.addThicknessToLine)(openingLine, style.thickness);
|
|
11
|
-
var stroke = style.stroke, fill = style.fill, strokeWidth = style.strokeWidth;
|
|
12
|
-
if (mode) {
|
|
13
|
-
stroke = style[mode].stroke;
|
|
14
|
-
fill = style[mode].fill;
|
|
15
|
-
}
|
|
16
|
-
ctx.fillStyle = 'white';
|
|
17
|
-
ctx.beginPath();
|
|
18
|
-
ctx.moveTo.apply(ctx, points[0]);
|
|
19
|
-
for (var i = 1; i < points.length; i++) {
|
|
20
|
-
ctx.lineTo.apply(ctx, points[i]);
|
|
21
|
-
}
|
|
22
|
-
ctx.lineTo.apply(ctx, points[0]);
|
|
23
|
-
ctx.fill();
|
|
24
|
-
ctx.beginPath();
|
|
25
|
-
ctx.strokeStyle = stroke || fill;
|
|
26
|
-
ctx.fillStyle = fill;
|
|
27
|
-
ctx.lineWidth = strokeWidth || 1;
|
|
28
|
-
ctx.setLineDash([10, 10]);
|
|
29
|
-
ctx.moveTo.apply(ctx, openingLine[0]);
|
|
30
|
-
ctx.lineTo.apply(ctx, openingLine[1]);
|
|
31
|
-
ctx.stroke();
|
|
32
|
-
ctx.closePath();
|
|
33
|
-
ctx.beginPath();
|
|
34
|
-
ctx.setLineDash([]);
|
|
35
|
-
var angle = (0, geometry_1.getAngleOfLineSegment)(openingLine);
|
|
36
|
-
ctx.arc(openingLine[0][0], openingLine[0][1], style.thickness / 2, angle - Math.PI / 2, angle + Math.PI / 2);
|
|
37
|
-
ctx.fill();
|
|
38
|
-
ctx.closePath();
|
|
39
|
-
ctx.beginPath();
|
|
40
|
-
ctx.arc(openingLine[1][0], openingLine[1][1], style.thickness / 2, angle + Math.PI / 2, angle - Math.PI / 2);
|
|
41
|
-
ctx.fill();
|
|
42
|
-
}
|
|
43
|
-
function drawOpenings(canvas, walls, openings, selections, styles) {
|
|
44
|
-
var styled = [
|
|
45
|
-
selections.active,
|
|
46
|
-
selections.highlighted,
|
|
47
|
-
selections.error,
|
|
48
|
-
selections.hidden,
|
|
49
|
-
];
|
|
50
|
-
var defaultOpenings = openings.reduce(function (output, _, i) {
|
|
51
|
-
if (!styled.flat().includes(i))
|
|
52
|
-
output.push(i);
|
|
53
|
-
return output;
|
|
54
|
-
}, []);
|
|
55
|
-
var openingsMap = [
|
|
56
|
-
[types_1.IElementStyleModes.ACTIVE, selections.active],
|
|
57
|
-
[types_1.IElementStyleModes.HIGHLIGHT, selections.highlighted],
|
|
58
|
-
[types_1.IElementStyleModes.ERROR, selections.error],
|
|
59
|
-
[undefined, defaultOpenings],
|
|
60
|
-
];
|
|
61
|
-
openingsMap.forEach(function (_a) {
|
|
62
|
-
var mode = _a[0], openingsIndexes = _a[1];
|
|
63
|
-
return openingsIndexes.forEach(function (index) {
|
|
64
|
-
var opening = openings[index];
|
|
65
|
-
if (!(opening === null || opening === void 0 ? void 0 : opening.connectedTo.length))
|
|
66
|
-
return;
|
|
67
|
-
var wallIndex = opening.connectedTo[1];
|
|
68
|
-
drawOpening(canvas, walls[wallIndex], opening.offset, opening.length, styles.feature, mode);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
exports.default = drawOpenings;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ICoordinate2D, IVertex, IElementStyleModes, IStylesVertex } from '../types';
|
|
2
|
-
export declare function drawVertex(canvas: HTMLCanvasElement, point: ICoordinate2D, style: IStylesVertex, mode?: IElementStyleModes): void;
|
|
3
|
-
export declare function drawVertices(canvas: HTMLCanvasElement, vertices: Array<IVertex>, selections: {
|
|
4
|
-
active: Array<number>;
|
|
5
|
-
highlighted: Array<number>;
|
|
6
|
-
error: Array<number>;
|
|
7
|
-
hidden: Array<number>;
|
|
8
|
-
}, styles: IStylesVertex): void;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.drawVertices = exports.drawVertex = void 0;
|
|
4
|
-
var types_1 = require("../types");
|
|
5
|
-
function drawVertex(canvas, point, style, mode) {
|
|
6
|
-
var ctx = canvas.getContext('2d');
|
|
7
|
-
if (!ctx)
|
|
8
|
-
return;
|
|
9
|
-
var stroke = style.stroke, innerFill = style.innerFill, outerFill = style.outerFill, strokeWidth = style.strokeWidth, outerRadius = style.outerRadius;
|
|
10
|
-
if (mode) {
|
|
11
|
-
stroke = style[mode].stroke;
|
|
12
|
-
innerFill = style[mode].innerFill;
|
|
13
|
-
outerFill = style[mode].outerFill;
|
|
14
|
-
}
|
|
15
|
-
ctx.lineWidth = strokeWidth || 1;
|
|
16
|
-
ctx.strokeStyle = stroke || innerFill;
|
|
17
|
-
ctx.fillStyle = outerFill;
|
|
18
|
-
if (outerRadius) {
|
|
19
|
-
ctx.beginPath();
|
|
20
|
-
ctx.arc(point[0], point[1], outerRadius, 0, 2 * Math.PI);
|
|
21
|
-
if (style.strokeWidth)
|
|
22
|
-
ctx.stroke();
|
|
23
|
-
ctx.fill();
|
|
24
|
-
}
|
|
25
|
-
ctx.lineWidth = strokeWidth || 1;
|
|
26
|
-
ctx.fillStyle = innerFill;
|
|
27
|
-
ctx.strokeStyle = stroke || innerFill;
|
|
28
|
-
ctx.beginPath();
|
|
29
|
-
ctx.arc(point[0], point[1], style.innerRadius, 0, 2 * Math.PI);
|
|
30
|
-
ctx.fill();
|
|
31
|
-
if (!outerRadius && strokeWidth)
|
|
32
|
-
ctx.stroke();
|
|
33
|
-
}
|
|
34
|
-
exports.drawVertex = drawVertex;
|
|
35
|
-
function drawVertices(canvas, vertices, selections, styles) {
|
|
36
|
-
var styled = [
|
|
37
|
-
selections.active,
|
|
38
|
-
selections.highlighted,
|
|
39
|
-
selections.error,
|
|
40
|
-
selections.hidden,
|
|
41
|
-
];
|
|
42
|
-
var defaultOpenings = vertices.reduce(function (output, _, i) {
|
|
43
|
-
if (!styled.flat().includes(i))
|
|
44
|
-
output.push(i);
|
|
45
|
-
return output;
|
|
46
|
-
}, []);
|
|
47
|
-
var verticesMap = [
|
|
48
|
-
[types_1.IElementStyleModes.ACTIVE, selections.active],
|
|
49
|
-
[types_1.IElementStyleModes.HIGHLIGHT, selections.highlighted],
|
|
50
|
-
[types_1.IElementStyleModes.ERROR, selections.error],
|
|
51
|
-
[undefined, defaultOpenings],
|
|
52
|
-
];
|
|
53
|
-
verticesMap.forEach(function (_a) {
|
|
54
|
-
var mode = _a[0], vertexIndexes = _a[1];
|
|
55
|
-
return vertexIndexes.forEach(function (index) {
|
|
56
|
-
var point = vertices[index].point;
|
|
57
|
-
drawVertex(canvas, point, styles, mode);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
exports.drawVertices = drawVertices;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { IWall, ICoordinatesLine, ISpacesStyles, IStylesWall, IElementStyleModes } from '../types';
|
|
2
|
-
import { WallModes } from '../constants';
|
|
3
|
-
export interface IWallToDraw extends Pick<IWall, 'line' | 'path' | 'mode'> {
|
|
4
|
-
}
|
|
5
|
-
export declare function drawNewWall(canvas: HTMLCanvasElement, line: ICoordinatesLine, wallMode: WallModes, styles: ISpacesStyles, mode?: IElementStyleModes.ERROR): void;
|
|
6
|
-
export declare function drawWalls(canvas: HTMLCanvasElement, walls: Array<IWallToDraw>, selections: {
|
|
7
|
-
active: Array<number>;
|
|
8
|
-
highlighted: Array<number>;
|
|
9
|
-
error: Array<number>;
|
|
10
|
-
hidden: Array<number>;
|
|
11
|
-
}, styles: IStylesWall): void;
|
|
@@ -1,90 +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
|
-
var constants_1 = require("../constants");
|
|
8
|
-
function drawBoundary(canvas, wall, style, mode) {
|
|
9
|
-
var ctx = canvas.getContext('2d');
|
|
10
|
-
if (!ctx)
|
|
11
|
-
return;
|
|
12
|
-
var stroke = style.stroke, fill = style.fill;
|
|
13
|
-
if (mode) {
|
|
14
|
-
stroke = style[mode].stroke;
|
|
15
|
-
fill = style[mode].fill;
|
|
16
|
-
}
|
|
17
|
-
ctx.strokeStyle = stroke || fill;
|
|
18
|
-
ctx.fillStyle = fill;
|
|
19
|
-
ctx.lineWidth = style.thickness;
|
|
20
|
-
ctx.beginPath();
|
|
21
|
-
ctx.setLineDash([10, 10]);
|
|
22
|
-
ctx.moveTo.apply(ctx, wall.line[0]);
|
|
23
|
-
ctx.lineTo.apply(ctx, wall.line[1]);
|
|
24
|
-
ctx.stroke();
|
|
25
|
-
ctx.closePath();
|
|
26
|
-
ctx.beginPath();
|
|
27
|
-
ctx.setLineDash([]);
|
|
28
|
-
}
|
|
29
|
-
function drawWall(canvas, wall, style, mode) {
|
|
30
|
-
var _a;
|
|
31
|
-
var ctx = canvas.getContext('2d');
|
|
32
|
-
if (!ctx)
|
|
33
|
-
return;
|
|
34
|
-
var path = (_a = wall.path) !== null && _a !== void 0 ? _a : (0, geometry_1.addThicknessToLine)(wall.line, style.thickness);
|
|
35
|
-
var stroke = style.stroke, fill = style.fill, strokeWidth = style.strokeWidth;
|
|
36
|
-
if (mode) {
|
|
37
|
-
stroke = style[mode].stroke;
|
|
38
|
-
fill = style[mode].fill;
|
|
39
|
-
}
|
|
40
|
-
ctx.strokeStyle = stroke || fill;
|
|
41
|
-
ctx.fillStyle = fill;
|
|
42
|
-
ctx.lineWidth = strokeWidth || 1;
|
|
43
|
-
ctx.beginPath();
|
|
44
|
-
ctx.moveTo.apply(ctx, path[0]);
|
|
45
|
-
for (var i = 1; i < path.length; i++) {
|
|
46
|
-
ctx.lineTo.apply(ctx, path[i]);
|
|
47
|
-
}
|
|
48
|
-
ctx.lineTo.apply(ctx, path[0]);
|
|
49
|
-
ctx.fill();
|
|
50
|
-
if (style.stroke && style.strokeWidth)
|
|
51
|
-
ctx.stroke();
|
|
52
|
-
}
|
|
53
|
-
function drawNewWall(canvas, line, wallMode, styles, mode) {
|
|
54
|
-
var draw = wallMode === constants_1.WallModes.WALL ? drawWall : drawBoundary;
|
|
55
|
-
draw(canvas, {
|
|
56
|
-
line: line,
|
|
57
|
-
path: (0, geometry_1.addThicknessToLine)(line, styles.wall.thickness),
|
|
58
|
-
}, styles.wall, mode !== null && mode !== void 0 ? mode : types_1.IElementStyleModes.ACTIVE);
|
|
59
|
-
line.forEach(function (point) {
|
|
60
|
-
return (0, drawVertices_1.drawVertex)(canvas, point, styles.vertex, mode !== null && mode !== void 0 ? mode : types_1.IElementStyleModes.HIGHLIGHT);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
exports.drawNewWall = drawNewWall;
|
|
64
|
-
function drawWalls(canvas, walls, selections, styles) {
|
|
65
|
-
var styled = [
|
|
66
|
-
selections.active,
|
|
67
|
-
selections.highlighted,
|
|
68
|
-
selections.error,
|
|
69
|
-
selections.hidden,
|
|
70
|
-
];
|
|
71
|
-
var defaultOpenings = walls.reduce(function (output, _, i) {
|
|
72
|
-
if (!styled.flat().includes(i))
|
|
73
|
-
output.push(i);
|
|
74
|
-
return output;
|
|
75
|
-
}, []);
|
|
76
|
-
var wallsMap = [
|
|
77
|
-
[types_1.IElementStyleModes.ACTIVE, selections.active],
|
|
78
|
-
[types_1.IElementStyleModes.HIGHLIGHT, selections.highlighted],
|
|
79
|
-
[types_1.IElementStyleModes.ERROR, selections.error],
|
|
80
|
-
[undefined, defaultOpenings],
|
|
81
|
-
];
|
|
82
|
-
wallsMap.forEach(function (_a) {
|
|
83
|
-
var mode = _a[0], wallIndexes = _a[1];
|
|
84
|
-
return wallIndexes.forEach(function (index) {
|
|
85
|
-
var draw = walls[index].mode === constants_1.WallModes.WALL ? drawWall : drawBoundary;
|
|
86
|
-
draw(canvas, walls[index], styles, mode);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
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;
|