@operato/scene-polypath 8.0.0-beta.0 → 8.0.0-beta.2
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/package.json +4 -4
- package/CHANGELOG.md +0 -216
- package/src/index.ts +0 -1
- package/src/polyline.ts +0 -80
- package/src/polypath.ts +0 -205
- package/test/basic-test.html +0 -67
- package/test/index.html +0 -22
- package/tsconfig.json +0 -24
- package/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@operato/scene-polypath",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.2",
|
|
4
4
|
"description": "Poly path component for things-scene",
|
|
5
5
|
"author": "heartyoh",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@hatiolab/prettier-config": "^1.0.0",
|
|
34
|
-
"@things-factory/builder": "^8.0.0-
|
|
35
|
-
"@things-factory/operato-board": "^8.0.0-
|
|
34
|
+
"@things-factory/builder": "^8.0.0-beta",
|
|
35
|
+
"@things-factory/operato-board": "^8.0.0-beta",
|
|
36
36
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
37
37
|
"@typescript-eslint/parser": "^4.33.0",
|
|
38
38
|
"@web/dev-server": "^0.1.28",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"prettier --write"
|
|
58
58
|
]
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "d6329b4f15ae63c2a99ec5b58ee1d527e88a4c36"
|
|
61
61
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
## [8.0.0-beta.0](https://github.com/things-scene/operato-scene/compare/v8.0.0-alpha.12...v8.0.0-beta.0) (2025-01-07)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### :bug: Bug Fix
|
|
10
|
-
|
|
11
|
-
* @hatiolab/things-scene@^8.0.0-beta ([c32f4c0](https://github.com/things-scene/operato-scene/commit/c32f4c00decf244ca82ae17a41e33f269e1882e7))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
## [8.0.0-alpha.1](https://github.com/things-scene/operato-scene/compare/v8.0.0-alpha.0...v8.0.0-alpha.1) (2024-09-09)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### :bug: Bug Fix
|
|
19
|
-
|
|
20
|
-
* update [@things-factory](https://github.com/things-factory)@^8.0.0-alpha ([1dc3163](https://github.com/things-scene/operato-scene/commit/1dc31638ed9d3fd0ecb2ac55be0ce541e5599ab8))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
## [8.0.0-alpha.0](https://github.com/things-scene/operato-scene/compare/v7.3.7...v8.0.0-alpha.0) (2024-09-01)
|
|
25
|
-
|
|
26
|
-
**Note:** Version bump only for package @operato/scene-polypath
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
## [7.0.1](https://github.com/things-scene/operato-scene/compare/v7.0.0...v7.0.1) (2024-06-30)
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
### :bug: Bug Fix
|
|
36
|
-
|
|
37
|
-
* things-factory@7.0.0 ([f4cfe44](https://github.com/things-scene/operato-scene/commit/f4cfe44cb565e7b8fdc0df210a722b6526871848))
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
## [7.0.0](https://github.com/things-scene/operato-scene/compare/v7.0.0-rc.4...v7.0.0) (2024-06-30)
|
|
42
|
-
|
|
43
|
-
**Note:** Version bump only for package @operato/scene-polypath
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
## [7.0.0-rc.1](https://github.com/things-scene/operato-scene/compare/v7.0.0-rc.0...v7.0.0-rc.1) (2024-06-21)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
### :bug: Bug Fix
|
|
53
|
-
|
|
54
|
-
* apply v7-rc dependencies ([eee5612](https://github.com/things-scene/operato-scene/commit/eee5612e1d569387c284a7c6c49d64ef44b6d701))
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## [7.0.0-rc.0](https://github.com/things-scene/operato-scene/compare/v2.0.0-beta.8...v7.0.0-rc.0) (2024-06-21)
|
|
59
|
-
|
|
60
|
-
**Note:** Version bump only for package @operato/scene-polypath
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
## [2.0.0-beta.0](https://github.com/things-scene/operato-scene/compare/v2.0.0-alpha.12...v2.0.0-beta.0) (2024-06-01)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
### :rocket: New Features
|
|
70
|
-
|
|
71
|
-
* 2.0.0-beta.0 ([a2e2869](https://github.com/things-scene/operato-scene/commit/a2e28694eedf5bab0c54bcab5432d54ec59edd7f))
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
### :bug: Bug Fix
|
|
75
|
-
|
|
76
|
-
* allowJs in tsconfig option ([fa77174](https://github.com/things-scene/operato-scene/commit/fa771742188f21f177f0a85281570f59f0c478cf))
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
## [2.0.0-alpha.12](https://github.com/things-scene/operato-scene/compare/v2.0.0-alpha.11...v2.0.0-alpha.12) (2024-05-11)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
### :bug: Bug Fix
|
|
84
|
-
|
|
85
|
-
* ignore 'cache' folder for git and npm ([d70f811](https://github.com/things-scene/operato-scene/commit/d70f8118ff3e9248f80aa9435d6e6cbb8aacfcaf))
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
## [2.0.0-alpha.9](https://github.com/things-scene/operato-scene/compare/v2.0.0-alpha.8...v2.0.0-alpha.9) (2024-04-11)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
### :bug: Bug Fix
|
|
93
|
-
|
|
94
|
-
* things-factory@7.0.1 ([a9f4c18](https://github.com/things-scene/operato-scene/commit/a9f4c1873b80c540e4c2e16649e127ccffcf9a4c))
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
## [2.0.0-alpha.6](https://github.com/things-scene/operato-scene/compare/v2.0.0-alpha.5...v2.0.0-alpha.6) (2024-03-24)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
### :bug: Bug Fix
|
|
102
|
-
|
|
103
|
-
* translation ([266d423](https://github.com/things-scene/operato-scene/commit/266d423d9d6992464f45a437acc90ccf8ed33bf6))
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
## [2.0.0-alpha.5](https://github.com/things-scene/operato-scene/compare/v2.0.0-alpha.4...v2.0.0-alpha.5) (2024-03-21)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
### :bug: Bug Fix
|
|
111
|
-
|
|
112
|
-
* 컴포넌트 명 다국어 ([fbc26d9](https://github.com/things-scene/operato-scene/commit/fbc26d9fb24e858541598ba55e2b8d33f2df8d8a))
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
## [2.0.0-alpha.4](https://github.com/things-scene/operato-scene/compare/v2.0.0-alpha.3...v2.0.0-alpha.4) (2024-03-21)
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
### :bug: Bug Fix
|
|
120
|
-
|
|
121
|
-
* 컴포넌트 명 다국어 ([64e1f08](https://github.com/things-scene/operato-scene/commit/64e1f08af32d2ac193c3d31b0025f8d06f569ca4))
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
## [2.0.0-alpha.0](https://github.com/things-scene/operato-scene/compare/v1.3.9...v2.0.0-alpha.0) (2024-01-14)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
### :bug: Bug Fix
|
|
129
|
-
|
|
130
|
-
* 2.0.0-alpha.0 ([93274e3](https://github.com/things-scene/operato-scene/commit/93274e36c5d184f339f83899654dd48b4786ac2b))
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
## [1.3.7](https://github.com/things-scene/operato-scene/compare/v1.3.6...v1.3.7) (2024-01-01)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
### :bug: Bug Fix
|
|
138
|
-
|
|
139
|
-
* mpi module moved from things-factory ([47b743f](https://github.com/things-scene/operato-scene/commit/47b743fd19001f195db85e50b8f6e457a1573aa5))
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
## [1.2.90](https://github.com/things-scene/operato-scene/compare/v1.2.89...v1.2.90) (2023-11-22)
|
|
144
|
-
|
|
145
|
-
**Note:** Version bump only for package @operato/scene-polypath
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
## [1.2.87](https://github.com/things-scene/operato-scene/compare/v1.2.86...v1.2.87) (2023-11-10)
|
|
152
|
-
|
|
153
|
-
**Note:** Version bump only for package @operato/scene-polypath
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
## [1.2.76](https://github.com/things-scene/operato-scene/compare/v1.2.75...v1.2.76) (2023-10-28)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
### :bug: Bug Fix
|
|
163
|
-
|
|
164
|
-
* scene-tab ([ad62f96](https://github.com/things-scene/operato-scene/commit/ad62f967b149eb5adf8f2e0714d79e8a9dc7186c))
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
## [1.2.66](https://github.com/things-scene/operato-scene/compare/v1.2.65...v1.2.66) (2023-09-14)
|
|
169
|
-
|
|
170
|
-
**Note:** Version bump only for package @operato/scene-polypath
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
## [1.2.65](https://github.com/things-scene/operato-scene/compare/v1.2.64...v1.2.65) (2023-09-14)
|
|
177
|
-
|
|
178
|
-
**Note:** Version bump only for package @operato/scene-polypath
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
## [1.2.62](https://github.com/things-scene/operato-scene/compare/v1.2.61...v1.2.62) (2023-09-11)
|
|
185
|
-
|
|
186
|
-
**Note:** Version bump only for package @operato/scene-polypath
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
## [1.2.49](https://github.com/things-scene/operato-scene/compare/v1.2.48...v1.2.49) (2023-06-26)
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
### :bug: Bug Fix
|
|
196
|
-
|
|
197
|
-
* missing .npmignore ([61ba4f2](https://github.com/things-scene/operato-scene/commit/61ba4f2ae22a865d700a971d62eb01f950c34d0e))
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
## [1.2.47](https://github.com/things-scene/operato-scene/compare/v1.2.46...v1.2.47) (2023-06-11)
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
### :bug: Bug Fix
|
|
205
|
-
|
|
206
|
-
* polypath ([a2b3bf4](https://github.com/things-scene/operato-scene/commit/a2b3bf4faaeda751c727eb487f8dd1780c7acbe5))
|
|
207
|
-
* polypath ([e3f28b2](https://github.com/things-scene/operato-scene/commit/e3f28b222021c213d0fba4c79e09a516fd9a95be))
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
## [1.2.46](https://github.com/things-scene/operato-scene/compare/v1.2.45...v1.2.46) (2023-06-10)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
### :bug: Bug Fix
|
|
215
|
-
|
|
216
|
-
* add polypath ([9d97250](https://github.com/things-scene/operato-scene/commit/9d97250b299cdb07f1d3629df85ad9a0a2445df5))
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as PolyPath } from './polypath'
|
package/src/polyline.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
export interface Point {
|
|
2
|
-
x: number
|
|
3
|
-
y: number
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export class Vector {
|
|
7
|
-
constructor(public x: number, public y: number) {}
|
|
8
|
-
|
|
9
|
-
static subtract(v1: Vector, v2: Vector): Vector {
|
|
10
|
-
return new Vector(v1.x - v2.x, v1.y - v2.y)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static add(v1: Vector, v2: Vector): Vector {
|
|
14
|
-
return new Vector(v1.x + v2.x, v1.y + v2.y)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
normalize(): Vector {
|
|
18
|
-
const length = Math.sqrt(this.x * this.x + this.y * this.y)
|
|
19
|
-
return new Vector(this.x / length, this.y / length)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
perp(): Vector {
|
|
23
|
-
return new Vector(-this.y, this.x)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
mult(scalar: number): Vector {
|
|
27
|
-
return new Vector(this.x * scalar, this.y * scalar)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class Polyline {
|
|
32
|
-
private points: Vector[]
|
|
33
|
-
private thickness: number
|
|
34
|
-
|
|
35
|
-
constructor(points: Point[], thickness: number) {
|
|
36
|
-
this.points = points.map(p => new Vector(p.x, p.y))
|
|
37
|
-
this.thickness = thickness
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
get path(): Vector[] {
|
|
41
|
-
let innerPoints: Vector[] = []
|
|
42
|
-
let outerPoints: Vector[] = []
|
|
43
|
-
|
|
44
|
-
for (let i = 0; i < this.points.length - 1; i++) {
|
|
45
|
-
let start = this.points[i]
|
|
46
|
-
let end = this.points[i + 1]
|
|
47
|
-
|
|
48
|
-
let direction = Vector.subtract(end, start).normalize()
|
|
49
|
-
let perpendicular = direction.perp()
|
|
50
|
-
let thicknessVector = perpendicular.mult(this.thickness / 2)
|
|
51
|
-
|
|
52
|
-
let startInner = Vector.subtract(start, thicknessVector)
|
|
53
|
-
let startOuter = Vector.add(start, thicknessVector)
|
|
54
|
-
let endInner = Vector.subtract(end, thicknessVector)
|
|
55
|
-
let endOuter = Vector.add(end, thicknessVector)
|
|
56
|
-
|
|
57
|
-
innerPoints.push(startInner, endInner)
|
|
58
|
-
outerPoints.push(startOuter, endOuter)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return [...outerPoints, ...innerPoints.reverse()]
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
draw(ctx: CanvasRenderingContext2D): void {
|
|
65
|
-
const path = this.path
|
|
66
|
-
|
|
67
|
-
ctx.beginPath()
|
|
68
|
-
|
|
69
|
-
path.forEach((point, index) => {
|
|
70
|
-
if (index === 0) {
|
|
71
|
-
ctx.moveTo(point.x, point.y)
|
|
72
|
-
} else {
|
|
73
|
-
ctx.lineTo(point.x, point.y)
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
ctx.closePath()
|
|
78
|
-
ctx.fill()
|
|
79
|
-
}
|
|
80
|
-
}
|
package/src/polypath.ts
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { Component, POSITION, Line, Shape, Properties, ComponentNature } from '@hatiolab/things-scene'
|
|
6
|
-
import { Polyline } from './polyline'
|
|
7
|
-
import { Vector } from './polyline'
|
|
8
|
-
|
|
9
|
-
var controlHandler = {
|
|
10
|
-
ondragstart: function (point: POSITION, index: number, component: Component) {
|
|
11
|
-
component.mutatePath(null, function (path) {
|
|
12
|
-
path.splice(index, 0, point) // array.insert(index, point) 의 의미임.
|
|
13
|
-
})
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
ondragmove: function (point: POSITION, index: number, component: Component) {
|
|
17
|
-
component.mutatePath(null, function (path) {
|
|
18
|
-
path[index] = point
|
|
19
|
-
})
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
ondragend: function (point: POSITION, index: number, component: Component) {}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const NATURE: ComponentNature = {
|
|
26
|
-
mutable: false,
|
|
27
|
-
resizable: false,
|
|
28
|
-
rotatable: false,
|
|
29
|
-
properties: [
|
|
30
|
-
{
|
|
31
|
-
type: 'number',
|
|
32
|
-
label: 'thickness',
|
|
33
|
-
name: 'thickness'
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
type: 'string',
|
|
37
|
-
label: 'line-dash',
|
|
38
|
-
name: 'lineDash'
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
type: 'number',
|
|
42
|
-
label: 'line-dash-offset',
|
|
43
|
-
name: 'lineDashOffset'
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
help: 'scene/component/polypath'
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export default class PolyPath extends Line {
|
|
50
|
-
_fromEnd: any
|
|
51
|
-
_toEnd: any
|
|
52
|
-
|
|
53
|
-
get pathExtendable() {
|
|
54
|
-
return true
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
get path() {
|
|
58
|
-
const { from, to } = this.state
|
|
59
|
-
const { path } = this.state
|
|
60
|
-
|
|
61
|
-
return [
|
|
62
|
-
this.fromEnd?.position || from?.position || path[0],
|
|
63
|
-
...path.slice(1, -1),
|
|
64
|
-
this.toEnd?.position || to?.position || path[path.length - 1]
|
|
65
|
-
]
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
set path(path) {
|
|
69
|
-
const { from, to } = this.state
|
|
70
|
-
|
|
71
|
-
delete this._fromEnd
|
|
72
|
-
delete this._toEnd
|
|
73
|
-
|
|
74
|
-
this.set({
|
|
75
|
-
from: {
|
|
76
|
-
...from,
|
|
77
|
-
position: path[0]
|
|
78
|
-
},
|
|
79
|
-
to: {
|
|
80
|
-
...to,
|
|
81
|
-
position: path[path.length - 1]
|
|
82
|
-
},
|
|
83
|
-
path
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
this._polyline = new Polyline(path, this.state.thickness || 50)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
get polyline(): Polyline {
|
|
90
|
-
if (!this._polyline) {
|
|
91
|
-
this._polyline = new Polyline(this.path, this.state.thickness || 50)
|
|
92
|
-
}
|
|
93
|
-
return this._polyline
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
_polyline?: Polyline
|
|
97
|
-
|
|
98
|
-
contains(x: number, y: number) {
|
|
99
|
-
var path: Vector[] = this.polyline.path
|
|
100
|
-
var result = false
|
|
101
|
-
|
|
102
|
-
path.forEach((p, idx) => {
|
|
103
|
-
let j = (idx + path.length + 1) % path.length
|
|
104
|
-
|
|
105
|
-
let x1 = p.x
|
|
106
|
-
let y1 = p.y
|
|
107
|
-
let x2 = path[j].x
|
|
108
|
-
let y2 = path[j].y
|
|
109
|
-
|
|
110
|
-
if (y1 > y != y2 > y && x < ((x2 - x1) * (y - y1)) / (y2 - y1) + x1) result = !result
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
return result
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
get controls() {
|
|
117
|
-
// 폴리라인에서의 control은 새로운 path를 추가하는 포인트이다.
|
|
118
|
-
var path = this.path
|
|
119
|
-
var controls = []
|
|
120
|
-
|
|
121
|
-
for (let i = 0; i < path.length - 1; i++) {
|
|
122
|
-
let p1 = path[i]
|
|
123
|
-
let p2 = path[i + 1]
|
|
124
|
-
|
|
125
|
-
if (i == 0) {
|
|
126
|
-
controls.push({
|
|
127
|
-
x: p1.x,
|
|
128
|
-
y: p1.y,
|
|
129
|
-
handler: controlHandler
|
|
130
|
-
})
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
controls.push({
|
|
134
|
-
x: (p1.x + p2.x) / 2,
|
|
135
|
-
y: (p1.y + p2.y) / 2,
|
|
136
|
-
handler: controlHandler
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
if (i == path.length - 2) {
|
|
140
|
-
controls.push({
|
|
141
|
-
x: p2.x,
|
|
142
|
-
y: p2.y,
|
|
143
|
-
handler: controlHandler
|
|
144
|
-
})
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return controls
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
draw(ctx: CanvasRenderingContext2D): void {
|
|
152
|
-
const { thickness = 50, fillStyle, strokeStyle, lineWidth, lineDash, lineDashOffset } = this.state
|
|
153
|
-
const path: Vector[] = this.path
|
|
154
|
-
|
|
155
|
-
ctx.save()
|
|
156
|
-
ctx.beginPath()
|
|
157
|
-
|
|
158
|
-
ctx.fillStyle = fillStyle
|
|
159
|
-
|
|
160
|
-
this.polyline.draw(ctx)
|
|
161
|
-
|
|
162
|
-
ctx.beginPath()
|
|
163
|
-
|
|
164
|
-
ctx.strokeStyle = strokeStyle
|
|
165
|
-
ctx.lineJoin = 'bevel'
|
|
166
|
-
ctx.lineWidth = Math.round(thickness - lineWidth)
|
|
167
|
-
if (lineDash) {
|
|
168
|
-
ctx.setLineDash(
|
|
169
|
-
lineDash
|
|
170
|
-
.split(',')
|
|
171
|
-
.map((text: string) => Number(text))
|
|
172
|
-
.filter((num: number) => !isNaN(num))
|
|
173
|
-
)
|
|
174
|
-
|
|
175
|
-
if (lineDashOffset) {
|
|
176
|
-
ctx.lineDashOffset = lineDashOffset
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
ctx.moveTo(path[0].x, path[0].y)
|
|
181
|
-
|
|
182
|
-
path.slice(1).forEach(point => {
|
|
183
|
-
ctx.lineTo(point.x, point.y)
|
|
184
|
-
})
|
|
185
|
-
|
|
186
|
-
ctx.stroke()
|
|
187
|
-
ctx.restore()
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
onchange(after: Properties, before: Properties) {
|
|
191
|
-
if ('thickness' in after) {
|
|
192
|
-
delete this._polyline
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
is3dish() {
|
|
197
|
-
return false
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
get nature() {
|
|
201
|
-
return NATURE
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
Component.register('polypath', PolyPath)
|
package/test/basic-test.html
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<!--
|
|
3
|
-
@license
|
|
4
|
-
Copyright © HatioLab Inc. All rights reserved.
|
|
5
|
-
-->
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<meta charset="utf-8">
|
|
9
|
-
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
|
10
|
-
|
|
11
|
-
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
|
12
|
-
<script src="../../web-component-tester/browser.js"></script>
|
|
13
|
-
|
|
14
|
-
<!-- Step 1: import the element to test -->
|
|
15
|
-
<link rel="import" href="../things-scene-gauge.html">
|
|
16
|
-
</head>
|
|
17
|
-
<body>
|
|
18
|
-
|
|
19
|
-
<!-- You can use the document as a place to set up your fixtures. -->
|
|
20
|
-
<test-fixture id="things-scene-gauge-fixture">
|
|
21
|
-
<template>
|
|
22
|
-
<things-scene-gauge>
|
|
23
|
-
<h2>things-scene-gauge</h2>
|
|
24
|
-
</things-scene-gauge>
|
|
25
|
-
</template>
|
|
26
|
-
</test-fixture>
|
|
27
|
-
|
|
28
|
-
<script>
|
|
29
|
-
suite('<things-scene-gauge>', function() {
|
|
30
|
-
|
|
31
|
-
var myEl;
|
|
32
|
-
|
|
33
|
-
setup(function() {
|
|
34
|
-
myEl = fixture('things-scene-gauge-fixture');
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('defines the "author" property', function() {
|
|
38
|
-
assert.equal(myEl.author.name, 'Dimitri Glazkov');
|
|
39
|
-
assert.equal(myEl.author.image, 'http://addyosmani.com/blog/wp-content/uploads/2013/04/unicorn.jpg');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('says hello', function() {
|
|
43
|
-
assert.equal(myEl.sayHello(), 'things-scene-gauge says, Hello World!');
|
|
44
|
-
|
|
45
|
-
var greetings = myEl.sayHello('greetings Earthlings');
|
|
46
|
-
assert.equal(greetings, 'things-scene-gauge says, greetings Earthlings');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('fires lasers', function(done) {
|
|
50
|
-
myEl.addEventListener('things-scene-gauge-lasers', function(event) {
|
|
51
|
-
assert.equal(event.detail.sound, 'Pew pew!');
|
|
52
|
-
done();
|
|
53
|
-
});
|
|
54
|
-
myEl.fireLasers();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('distributed children', function() {
|
|
58
|
-
var els = myEl.getContentChildren();
|
|
59
|
-
assert.equal(els.length, 1, 'one distributed node');
|
|
60
|
-
assert.equal(els[0], myEl.querySelector('h2'), 'content distributed correctly');
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
</script>
|
|
65
|
-
|
|
66
|
-
</body>
|
|
67
|
-
</html>
|
package/test/index.html
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<!--
|
|
3
|
-
@license
|
|
4
|
-
Copyright © HatioLab Inc. All rights reserved.
|
|
5
|
-
-->
|
|
6
|
-
<html><head>
|
|
7
|
-
<meta charset="utf-8">
|
|
8
|
-
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
|
9
|
-
|
|
10
|
-
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
|
|
11
|
-
<script src="../../web-component-tester/browser.js"></script>
|
|
12
|
-
</head>
|
|
13
|
-
<body>
|
|
14
|
-
<script>
|
|
15
|
-
// Load and run all tests (.html, .js):
|
|
16
|
-
WCT.loadSuites([
|
|
17
|
-
'basic-test.html',
|
|
18
|
-
'basic-test.html?dom=shadow'
|
|
19
|
-
]);
|
|
20
|
-
</script>
|
|
21
|
-
|
|
22
|
-
</body></html>
|
package/tsconfig.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2018",
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"noEmitOnError": true,
|
|
7
|
-
"lib": ["es2019", "dom"],
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": false,
|
|
10
|
-
"allowJs": true,
|
|
11
|
-
"allowSyntheticDefaultImports": true,
|
|
12
|
-
"experimentalDecorators": true,
|
|
13
|
-
"importHelpers": true,
|
|
14
|
-
"outDir": "dist",
|
|
15
|
-
"sourceMap": true,
|
|
16
|
-
"inlineSources": true,
|
|
17
|
-
"rootDir": "src",
|
|
18
|
-
"declaration": true,
|
|
19
|
-
"incremental": true,
|
|
20
|
-
"skipLibCheck": true,
|
|
21
|
-
"types": []
|
|
22
|
-
},
|
|
23
|
-
"include": ["**/*.ts", "*.d.ts"]
|
|
24
|
-
}
|
package/tsconfig.tsbuildinfo
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"fileNames":["../../node_modules/typescript/lib/lib.es5.d.ts","../../node_modules/typescript/lib/lib.es2015.d.ts","../../node_modules/typescript/lib/lib.es2016.d.ts","../../node_modules/typescript/lib/lib.es2017.d.ts","../../node_modules/typescript/lib/lib.es2018.d.ts","../../node_modules/typescript/lib/lib.es2019.d.ts","../../node_modules/typescript/lib/lib.dom.d.ts","../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../node_modules/typescript/lib/lib.decorators.d.ts","../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../node_modules/tslib/tslib.d.ts","../../node_modules/@hatiolab/things-scene/things-scene.d.ts","./src/polyline.ts","./src/polypath.ts","./src/index.ts"],"fileIdsList":[[38,41],[38],[38,39,40]],"fileInfos":[{"version":"e41c290ef7dd7dab3493e6cbe5909e0148edf4a8dad0271be08edec368a0f7b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"4fd3f3422b2d2a3dfd5cdd0f387b3a8ec45f006c6ea896a4cb41264c2100bb2c","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"62bb211266ee48b2d0edf0d8d1b191f0c24fc379a82bd4c1692a082c540bc6b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"936e80ad36a2ee83fc3caf008e7c4c5afe45b3cf3d5c24408f039c1d47bdc1df","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"fef8cfad2e2dc5f5b3d97a6f4f2e92848eb1b88e897bb7318cef0e2820bceaab","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"a6a5253138c5432c68a1510c70fe78a644fe2e632111ba778e1978010d6edfec","impliedFormat":1},{"version":"ef4e4dc2fd14de20903f5010671dab9cf547c831dce4802306676c80649b990b","impliedFormat":1},{"version":"21b757a7717c9911a8abec5a69e443e8286046ac778581396097e2076922a241","signature":"5f613c4ea347afec06e148d2ec6ba2390a564cc615f9d2095a7e2b3c10f5981c"},{"version":"de5755b7e0893ac565db0b68573cff7fec474ed641c698361badcd7376d20d3e","signature":"afd5eab24e67b8ff4b41b7be11ad6e8608cf2b4b058bbe9c2540250716d62f73"},{"version":"5c8bf786f2ceb87c1622e50d9fe6476a412df88a57222d5f382b3de90e54c8b3","signature":"a6da775445708dbeee29b3bae8acff86a069026a135ad2e10e95ed7e7881b614"}],"root":[[40,42]],"options":{"allowJs":true,"allowSyntheticDefaultImports":true,"declaration":true,"esModuleInterop":false,"experimentalDecorators":true,"importHelpers":true,"inlineSources":true,"module":99,"noEmitOnError":true,"outDir":"./dist","rootDir":"./src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":5},"referencedMap":[[42,1],[40,2],[41,3]],"version":"5.7.2"}
|