@operato/scene-compass 8.0.0-beta.1 → 8.0.0

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/demo/index.html DELETED
@@ -1,91 +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
- <title>things-scene-compass Demo</title>
11
- <script src="../../webcomponentsjs/webcomponents-lite.min.js"></script>
12
-
13
- <link rel="import" href="../../things-scene-viewer/things-scene-viewer.html">
14
- <link rel="import" href="../../things-scene-viewer/things-scene-layer.html">
15
- <link rel="import" href="../../things-scene-viewer/things-scene-handler.html">
16
-
17
- <link rel="import" href="../../things-designer-elements/things-editor-color.html">
18
- <link rel="import" href="../../things-designer-elements/things-editor-color-stops.html">
19
- <link rel="import" href="../../things-scene-modeler/things-scene-properties.html">
20
-
21
- <link rel="import" href="./things-scene-compass.html">
22
-
23
- <style is="custom-style">
24
-
25
- @font-face {
26
- font-family: "Bitstream Vera Serif Bold";
27
- src: url("fonts/VeraSeBd.ttf");
28
- }
29
-
30
- things-scene-viewer {
31
- display: block;
32
- width: 640px;
33
- height: 480px;
34
- }
35
- </style>
36
- </head>
37
- <body unresolved>
38
-
39
- <template is="dom-bind" id="app">
40
- <p>An example of <code>&lt;things-scene-compass&gt;</code>:</p>
41
-
42
- <things-scene-viewer id='scene'
43
- scene='{{scene}}'
44
- selected='{{selected}}'
45
- model='[[model]]'
46
- mode="1">
47
- <things-scene-layer type="selection-layer"></things-scene-layer>
48
- <things-scene-layer type="modeling-layer"></things-scene-layer>
49
- <things-scene-handler type="text-editor"></things-scene-handler>
50
- <things-scene-handler type="move-handler"></things-scene-handler>
51
- </things-scene-viewer>
52
-
53
- <things-scene-properties scene="[[scene]]"
54
- selected="[[selected]]"
55
- model="{{target}}"
56
- bounds="{{bounds}}">
57
- <fieldset>
58
- <legend>compass style</legend>
59
- <label>value</label>
60
- <input type="number" value-as-number="{{target.value::change}}" min="0" max="100" step="1"/>
61
- </fieldset>
62
- </things-scene-properties>
63
-
64
- </template>
65
-
66
- <script>
67
- window.addEventListener('WebComponentsReady', function(e) {
68
- var app = document.querySelector('#app')
69
-
70
- app.model = {
71
- fillStyle: '#0EB22A',
72
- width: 1500,
73
- height: 1000,
74
- components: [{
75
- type: 'compass',
76
- cx: 600,
77
- cy: 400,
78
- rx: 300,
79
- ry: 300,
80
- value: 0,
81
- fontSize: 80,
82
- fillStyle: '#F2F2F2',
83
- strokeStyle: '#AAAAAA',
84
- lineWidth: 10,
85
- fontColor: '#ff0000',
86
- }]
87
- }
88
- });
89
- </script>
90
- </body>
91
- </html>
@@ -1,5 +0,0 @@
1
- <!--
2
- @license
3
- Copyright © HatioLab Inc. All rights reserved.
4
- -->
5
- <script src="../things-scene-compass.js"></script>
package/src/compass.ts DELETED
@@ -1,139 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
-
5
- import { Component, ComponentNature, Ellipse, Properties } from '@hatiolab/things-scene'
6
-
7
- const NATURE: ComponentNature = {
8
- mutable: false,
9
- resizable: true,
10
- rotatable: true,
11
- properties: [
12
- {
13
- type: 'number',
14
- label: 'value',
15
- name: 'value',
16
- property: 'value'
17
- }
18
- ],
19
- help: 'scene/component/compass'
20
- }
21
-
22
- export default class Compass extends Ellipse {
23
- private _anim_alpha: number = 0
24
-
25
- is3dish() {
26
- return false
27
- }
28
-
29
- render(context: CanvasRenderingContext2D) {
30
- var { value = 0, fillStyle, cx, cy, rx, ry } = this.state
31
-
32
- context.translate(cx, cy)
33
-
34
- //// 메인 원 그리기 ////
35
- context.beginPath()
36
- context.ellipse(0, 0, Math.abs(rx), Math.abs(ry), 0, 0, 2 * Math.PI)
37
- context.ellipse(0, 0, Math.abs(rx * 0.75), Math.abs(ry * 0.75), 0, 2 * Math.PI, 0, true) // 반대로 그리며 원을 지움.
38
-
39
- this.drawStroke(context)
40
- this.drawFill(context)
41
- context.closePath()
42
-
43
- //// 무늬 그리기 ////
44
- context.beginPath()
45
- context.moveTo(rx * 0.65, 0)
46
- context.lineTo(0, ry * 0.09)
47
- context.lineTo(-rx * 0.65, 0)
48
- context.lineTo(0, -ry * 0.09)
49
-
50
- context.moveTo(0, ry * 0.65)
51
- context.lineTo(rx * 0.09, 0)
52
- context.lineTo(0, -ry * 0.65)
53
- context.lineTo(-rx * 0.09, 0)
54
-
55
- context.fillStyle = fillStyle
56
- context.fill()
57
- context.closePath()
58
-
59
- //// 텍스트 그리기 ////
60
- context.beginPath()
61
- context.fillStyle = 'black'
62
- context.font = (rx + ry) / 13 + 'px arial'
63
- context.textBaseline = 'middle'
64
- context.textAlign = 'center'
65
- context.fillText('N', 0, -ry + ry * 0.125)
66
- context.fillText('S', 0, ry - ry * 0.125)
67
- context.fillText('W', -rx + rx * 0.125, 0)
68
- context.fillText('E', rx - rx * 0.125, 0)
69
-
70
- //// 바늘 그리기 ////
71
- context.beginPath()
72
- var ang = ((value + (this._anim_alpha || 0)) / 50) * Math.PI
73
- context.rotate(ang)
74
-
75
- context.moveTo(0, -ry * 0.65)
76
- context.lineTo(rx * 0.13, 0)
77
- context.lineTo(-rx * 0.13, 0)
78
- context.fillStyle = '#F53B3B'
79
- context.fill()
80
-
81
- context.beginPath()
82
- context.moveTo(0, ry * 0.65)
83
- context.lineTo(rx * 0.13, 0)
84
- context.lineTo(-rx * 0.13, 0)
85
- context.fillStyle = '#3DC0E8'
86
- context.fill()
87
-
88
- context.rotate(-ang)
89
-
90
- //// 중앙 원 그리기 ////
91
- context.beginPath()
92
- context.ellipse(0, 0, Math.abs(rx * 0.15), Math.abs(ry * 0.15), 0, 0, 2 * Math.PI)
93
- context.lineWidth = (rx + ry) * 0.013
94
- context.strokeStyle = '#FFFFFF'
95
- context.fillStyle = '#3DC0E8'
96
- context.fill()
97
- context.stroke()
98
- context.beginPath()
99
-
100
- context.ellipse(0, 0, Math.abs(rx * 0.06), Math.abs(ry * 0.06), 0, 0, 2 * Math.PI)
101
- context.fillStyle = '#FFFFFF'
102
- context.fill()
103
- context.closePath()
104
-
105
- context.translate(-cx, -cy)
106
- }
107
-
108
- postrender(context: CanvasRenderingContext2D) {
109
- this.drawText(context)
110
- }
111
-
112
- onchange(after: Properties, before: Properties) {
113
- if (!after.hasOwnProperty('value')) return
114
-
115
- var self = this
116
- var diff = after.value - before.value
117
-
118
- this._anim_alpha = -diff
119
-
120
- this.animate({
121
- step: function (delta: number) {
122
- self._anim_alpha = diff * (delta - 1)
123
- self.invalidate()
124
- },
125
- duration: 1000,
126
- delta: 'elastic',
127
- options: {
128
- x: 2
129
- },
130
- ease: 'out'
131
- }).start()
132
- }
133
-
134
- get nature() {
135
- return NATURE
136
- }
137
- }
138
-
139
- Component.register('compass', Compass)
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- /*
2
- * Copyright © HatioLab Inc. All rights reserved.
3
- */
4
- export { default as Compass } from './compass'
@@ -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,23 +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
- },
22
- "include": ["**/*.ts", "*.d.ts"]
23
- }