-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathhydra-canvas.js
49 lines (47 loc) · 1.5 KB
/
hydra-canvas.js
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
{
const getHydra = function () {
const whereami = window.location?.href?.includes("hydra.ojack.xyz")
? "editor"
: window.atom?.packages
? "atom"
: "idk";
if (whereami === "editor") {
return window.hydraSynth;
}
if (whereami === "atom") {
return global.atom.packages.loadedPackages["atom-hydra"]
.mainModule.main.hydra;
}
let _h = [
window.hydraSynth,
window._hydra,
window.hydra,
window.h,
window.H,
window.hy
].find(h => h?.regl);
return _h;
};
window._hydra = getHydra();
window._hydraScope = _hydra.sandbox.makeGlobal ? window : _hydra.synth;
}
_hydraScope.canvas = window._hydra.canvas;
_hydraScope.canvas.setLinear = function () {
this.style.imageRendering = "auto";
};
_hydraScope.canvas.setNearest = function () {
this.style.imageRendering = "pixelated";
};
_hydraScope.canvas.setFullscreen = function (full = true) {
const set = full ? "100%" : "";
this.style.width = set;
this.style.height = set;
};
_hydraScope.canvas.setAlign = function (align = "right") {
this.style.position = "relative";
this.parentElement.style["text-align"] = align;
};
_hydraScope.canvas.setRelativeSize = function (ratio) {
this.style.width = "" + width * ratio + "px";
this.style.height = "" + height * ratio + "px";
};