@bitbybit-dev/core
Version:
Bit By Bit Developers Core CAD API to Program Geometry
37 lines (36 loc) • 1.07 kB
JavaScript
export class ContextBase {
constructor() {
this.canvasZoneClass = "canvasZone";
this.tolerance = 0.00001;
this.snapTolerance = 0.00001;
this.tagBag = [];
this.timeoutBag = [];
this.intervalBag = [];
this.renderLoopBag = [];
this.keyDownBag = [];
this.keyUpBag = [];
this.keyPressBag = [];
this.currentlyPressedKeys = [];
}
getFile(file) {
return new Promise((resolve, reject) => {
if (file) {
const reader = new FileReader();
reader.readAsText(file, "UTF-8");
reader.onload = (evt) => {
const text = evt.target.result;
resolve(text);
};
reader.onerror = (evt) => {
reject();
};
}
else {
reject();
}
});
}
remap(value, from1, to1, from2, to2) {
return (value - from1) / (to1 - from1) * (to2 - from2) + from2;
}
}