This repository was archived by the owner on Mar 27, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
64 lines (48 loc) · 1.91 KB
/
main.js
File metadata and controls
64 lines (48 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { HTMLCanvas, XMLSVG } from './src/views/index.js';
import diffContext, {
ENUMS,
userConfigs,
initSVG,
transformSVG,
setGUIAction
} from './implementation/index.js';
import { initGUIRange, gridConfig } from './implementation/GUI/index.js';
import package_json from './package.json' with { type: 'json' };
const
{ CASE, UI_EVENT } = ENUMS
,
{ setRange, Converters } = HTMLCanvas.Helpers.Trigonometry
;
document.on(UI_EVENT.DOMContentLoaded, ()=>{
document.title = package_json.name;
const
stage = new HTMLCanvas.ViewGroup.Stage({...userConfigs.stage});
stage.append(...[
new HTMLCanvas.ViewGroup.Layer({...userConfigs.grid})
,
initSVG({XMLSVG, HTMLCanvas})
]);
const
GUIRange
= initGUIRange({id: 'wave', container: stage.parentElement, position: 'right', draggable: true});
window.on(UI_EVENT.resize, ()=>{
GUIRange.grid.scale.element.on(UI_EVENT.input, function(){
// DEV_NOTE # technically, this is redundant, but consistency matters, thus overriding
gridConfig.scale = Number( this.value ) ;
/**
* @override
*/
Object.assign( stage , { scale: gridConfig.scale } )
HTMLCanvas
.init({stage})
.on( diffContext.bind(null, {HTMLCanvas, XMLSVG, transformSVG, userConfigs}) );
}); GUIRange.grid.scale.element.dispatch( new Event(UI_EVENT.input) );
GUIRange.wave.all
.forEach(
setGUIAction[CASE.waveConfig].bind(null, { Converters, setRange })
)
;
})
// DEV_NOTE (!) # This allows to initiate `<canvas>` hosted "bitmap" with internal context without waiting `window.onresize` to be triggered by end-user
window.dispatch( new Event(UI_EVENT.resize) );
});