@luceosports/play-rendering 1.10.7 → 1.10.10
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/play-rendering.js +2 -2
- package/dist/play-rendering.js.map +1 -1
- package/package.json +1 -1
- package/src/layers/ShapeControlPointLayer.js +26 -0
- package/src/layers/shape/base/InternalShapeLayer.js +14 -4
- package/src/layers/shape/layers/CircleShapeLayer.js +1 -2
- package/src/layers/shape/layers/ConeShapeLayer.js +4 -2
- package/src/layers/shape/layers/SquareShapeLayer.js +1 -2
- package/src/layers/shape/layers/TriangleShapeLayer.js +1 -2
- package/src/models/Frame.js +2 -0
- package/src/models/Play.js +2 -0
- package/src/models/Shape.js +12 -2
- package/src/models/ShapeModels/CircleShape.js +1 -1
- package/src/models/ShapeModels/ConeShape.js +1 -1
- package/src/models/ShapeModels/SquareShape.js +1 -1
- package/src/models/ShapeModels/TriangleShape.js +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const BaseLayer = require('./base/BaseLayer');
|
|
2
|
+
|
|
3
|
+
class ShapeControlPointLayer extends BaseLayer {
|
|
4
|
+
apply() {
|
|
5
|
+
this.ctx.save();
|
|
6
|
+
|
|
7
|
+
this.ctx.fillStyle = 'blue';
|
|
8
|
+
|
|
9
|
+
this.playData.shapes.forEach(({ id, color, location, rectWrapPoints }) => {
|
|
10
|
+
if (this.options.shapeSelectedId !== id) return;
|
|
11
|
+
if (color.alpha === 0) return;
|
|
12
|
+
|
|
13
|
+
this.ctx.translate(location.x, location.y);
|
|
14
|
+
|
|
15
|
+
rectWrapPoints.forEach(point => {
|
|
16
|
+
this.ctx.beginPath();
|
|
17
|
+
this.ctx.arc(point.x, point.y, 0.4, 0, Math.PI * 2, true);
|
|
18
|
+
this.ctx.fill();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
this.ctx.restore();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = ShapeControlPointLayer;
|
|
@@ -28,23 +28,33 @@ class InternalShapeLayer extends InternalBaseLayer {
|
|
|
28
28
|
const b = Math.ceil(blue * 255);
|
|
29
29
|
|
|
30
30
|
this.ctx.fillStyle = `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
31
|
-
this.ctx.strokeStyle = `rgba(${r}, ${g}, ${b},
|
|
31
|
+
this.ctx.strokeStyle = `rgba(${r}, ${g}, ${b}, 1)`;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
drawShapeWrapPoints() {
|
|
35
35
|
if (!DEBUG_WRAP_POINTS) return;
|
|
36
36
|
|
|
37
|
-
const { rectWrapPoints } = this.shape;
|
|
37
|
+
const { rectWrapPoints, location } = this.shape;
|
|
38
|
+
|
|
39
|
+
this.ctx.fillStyle = 'red';
|
|
40
|
+
|
|
41
|
+
this.ctx.translate(location.x, location.y);
|
|
38
42
|
|
|
39
43
|
rectWrapPoints.forEach(point => {
|
|
40
44
|
this.ctx.beginPath();
|
|
41
|
-
this.ctx.arc(point.x, point.y, 0.
|
|
42
|
-
this.ctx.stroke();
|
|
45
|
+
this.ctx.arc(point.x, point.y, 0.4, 0, Math.PI * 2);
|
|
43
46
|
this.ctx.fill();
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
drawShape() {
|
|
51
|
+
this.ctx.save();
|
|
52
|
+
this.drawShapeLogic();
|
|
53
|
+
if (this.shape.showBorder) this.ctx.stroke();
|
|
54
|
+
this.ctx.restore();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
drawShapeLogic() {
|
|
48
58
|
// Override this function in a subclass
|
|
49
59
|
}
|
|
50
60
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
const InternalShapeLayer = require('../base/InternalShapeLayer');
|
|
2
2
|
|
|
3
3
|
class CircleShapeLayer extends InternalShapeLayer {
|
|
4
|
-
|
|
4
|
+
drawShapeLogic() {
|
|
5
5
|
const { location, scale, outerCircleRadius } = this.shape;
|
|
6
6
|
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH;
|
|
7
7
|
this.ctx.translate(location.x, location.y);
|
|
8
8
|
this.ctx.scale(scale.x, scale.y);
|
|
9
9
|
this.ctx.beginPath();
|
|
10
10
|
this.ctx.arc(0, 0, outerCircleRadius, 0, Math.PI * 2);
|
|
11
|
-
this.ctx.stroke();
|
|
12
11
|
this.ctx.fill();
|
|
13
12
|
}
|
|
14
13
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const InternalShapeLayer = require('../base/InternalShapeLayer');
|
|
2
2
|
|
|
3
3
|
class ConeShapeLayer extends InternalShapeLayer {
|
|
4
|
-
|
|
5
|
-
const { location, scale, outerCircleRadius } = this.shape;
|
|
4
|
+
drawShapeLogic() {
|
|
5
|
+
const { location, color, scale, outerCircleRadius } = this.shape;
|
|
6
|
+
if (color.alpha === 0) return;
|
|
7
|
+
|
|
6
8
|
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH;
|
|
7
9
|
this.ctx.translate(location.x, location.y);
|
|
8
10
|
this.ctx.scale(scale.x, scale.y);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const InternalShapeLayer = require('../base/InternalShapeLayer');
|
|
2
2
|
|
|
3
3
|
class SquareShapeLayer extends InternalShapeLayer {
|
|
4
|
-
|
|
4
|
+
drawShapeLogic() {
|
|
5
5
|
const { location, scale, outerCircleRadius } = this.shape;
|
|
6
6
|
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH;
|
|
7
7
|
this.ctx.translate(location.x, location.y);
|
|
@@ -10,7 +10,6 @@ class SquareShapeLayer extends InternalShapeLayer {
|
|
|
10
10
|
this.ctx.beginPath();
|
|
11
11
|
this.ctx.rect(-outerCircleRadius / 2, -outerCircleRadius / 2, outerCircleRadius, outerCircleRadius);
|
|
12
12
|
|
|
13
|
-
this.ctx.stroke();
|
|
14
13
|
this.ctx.fill();
|
|
15
14
|
}
|
|
16
15
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const InternalShapeLayer = require('../base/InternalShapeLayer');
|
|
2
2
|
|
|
3
3
|
class TriangleShapeLayer extends InternalShapeLayer {
|
|
4
|
-
|
|
4
|
+
drawShapeLogic() {
|
|
5
5
|
const { location, scale, shapeControlPoints: triangle } = this.shape;
|
|
6
6
|
|
|
7
7
|
this.ctx.lineWidth = this.courtTypeConstants.COURT_LINE_WIDTH;
|
|
@@ -15,7 +15,6 @@ class TriangleShapeLayer extends InternalShapeLayer {
|
|
|
15
15
|
this.ctx.lineTo(triangle[2].x, triangle[2].y);
|
|
16
16
|
this.ctx.lineTo(triangle[0].x, triangle[0].y);
|
|
17
17
|
|
|
18
|
-
this.ctx.stroke();
|
|
19
18
|
this.ctx.fill();
|
|
20
19
|
}
|
|
21
20
|
}
|
package/src/models/Frame.js
CHANGED
|
@@ -7,6 +7,7 @@ const LineLayer = require('../layers/LineLayer');
|
|
|
7
7
|
const PlayerLayer = require('../layers/PlayerLayer');
|
|
8
8
|
const ShapeLayer = require('../layers/ShapeLayer');
|
|
9
9
|
const LineControlPointLayer = require('../layers/LineControlPointLayer');
|
|
10
|
+
const ShapeControlPointLayer = require('../layers/ShapeControlPointLayer');
|
|
10
11
|
const Line = require('./Line');
|
|
11
12
|
const Player = require('./Player');
|
|
12
13
|
const ShapeModels = require('./ShapeModels');
|
|
@@ -216,6 +217,7 @@ class Frame {
|
|
|
216
217
|
new LineLayer(this.ctx, frameData).apply();
|
|
217
218
|
new PlayerLayer(this.ctx, frameData).apply();
|
|
218
219
|
new LineControlPointLayer(this.ctx, frameData).apply();
|
|
220
|
+
new ShapeControlPointLayer(this.ctx, frameData).apply();
|
|
219
221
|
|
|
220
222
|
// console.timeEnd('draw');
|
|
221
223
|
|
package/src/models/Play.js
CHANGED
|
@@ -16,6 +16,7 @@ class Play {
|
|
|
16
16
|
linesDisplayOnMoveOnly = true,
|
|
17
17
|
linesHiddenIds = [],
|
|
18
18
|
linesSelectedIds = [],
|
|
19
|
+
shapeSelectedId = null,
|
|
19
20
|
playersHiddenPositions = [],
|
|
20
21
|
background = '',
|
|
21
22
|
watermark = null,
|
|
@@ -35,6 +36,7 @@ class Play {
|
|
|
35
36
|
linesDisplayOnMoveOnly,
|
|
36
37
|
linesHiddenIds,
|
|
37
38
|
linesSelectedIds,
|
|
39
|
+
shapeSelectedId,
|
|
38
40
|
playersHiddenPositions,
|
|
39
41
|
background,
|
|
40
42
|
watermark,
|
package/src/models/Shape.js
CHANGED
|
@@ -21,11 +21,15 @@ class Shape extends Model {
|
|
|
21
21
|
return this._getAttr('type');
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
get showBorder() {
|
|
25
|
+
return this._getAttr('showBorder');
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
get outerCircleRadius() {
|
|
25
29
|
return 10;
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
get
|
|
32
|
+
get rectWrapPointsPure() {
|
|
29
33
|
const topLeft = { x: -this.outerCircleRadius / 2, y: -this.outerCircleRadius / 2 };
|
|
30
34
|
const topRight = { x: this.outerCircleRadius / 2, y: -this.outerCircleRadius / 2 };
|
|
31
35
|
const botRight = { x: this.outerCircleRadius / 2, y: this.outerCircleRadius / 2 };
|
|
@@ -33,9 +37,15 @@ class Shape extends Model {
|
|
|
33
37
|
return [topLeft, topRight, botRight, botLeft];
|
|
34
38
|
}
|
|
35
39
|
|
|
40
|
+
get rectWrapPoints() {
|
|
41
|
+
return this.rectWrapPointsPure.map(point => {
|
|
42
|
+
return { x: point.x * this.scale.x, y: point.y * this.scale.y };
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
36
46
|
get rectWrapPointsTranslated() {
|
|
37
47
|
return this.rectWrapPoints.map(point => {
|
|
38
|
-
return { x: point.x
|
|
48
|
+
return { x: point.x + this.location.x, y: point.y + this.location.y };
|
|
39
49
|
});
|
|
40
50
|
}
|
|
41
51
|
|
|
@@ -5,7 +5,7 @@ class CircleShape extends Shape {
|
|
|
5
5
|
return 5;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
get
|
|
8
|
+
get rectWrapPointsPure() {
|
|
9
9
|
const topLeft = { x: -this.outerCircleRadius, y: -this.outerCircleRadius };
|
|
10
10
|
const topRight = { x: this.outerCircleRadius, y: -this.outerCircleRadius };
|
|
11
11
|
const botRight = { x: this.outerCircleRadius, y: this.outerCircleRadius };
|
|
@@ -14,7 +14,7 @@ class TriangleShape extends Shape {
|
|
|
14
14
|
];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
get
|
|
17
|
+
get rectWrapPointsPure() {
|
|
18
18
|
const [topPoint, botLeft, botRight] = this.shapeControlPoints;
|
|
19
19
|
const topLeft = { x: botLeft.x, y: topPoint.y };
|
|
20
20
|
const topRight = { x: botRight.x, y: topPoint.y };
|