update add, data, geo to use gapp.register()

This commit is contained in:
Stewart Allen 2022-02-20 14:31:27 -05:00
commit 32e9ceca55
23 changed files with 504 additions and 489 deletions

View file

@ -2,12 +2,14 @@
"use strict";
(function() {
const base = self.base;
if (base.Slope) return;
// dep: geo.base
// use: geo.line
// use: geo.point
gapp.register("geo.slope", [], (root, exports) => {
const { base } = root;
const { config } = base;
const ABS = Math.abs,
DEG2RAD = Math.PI / 180,
RAD2DEG = 180 / Math.PI;
@ -96,13 +98,17 @@ function newSlope(p1, p2, dx, dy) {
return new Slope(p1, p2, dx, dy);
}
base.Slope = Slope;
base.newSlope = newSlope;
base.newSlopeFromAngle = function(angle) {
function newSlopeFromAngle(angle) {
return newSlope(0,0,
Math.cos(angle * DEG2RAD),
Math.sin(angle * DEG2RAD)
);
};
}
})();
gapp.overlay(base, {
Slope,
newSlope,
newSlopeFromAngle
});
});