cleaned up types

This commit is contained in:
ari committed 2022-05-13 17:26:44 -04:00
1 parent 38b0aecffa
commit 49fea3fabd
3 files changed
+2 -65

No files matched your search

+2 -2
View File
@@ -1,10 +1,10 @@
import { Styles } from "jss";
import Color from 'chroma-js';
import { createAppUseStyles } from "styles/theme";
import { Node } from "types/graphs";
import { NodeColor } from "types/graphs";
export const useNodeStyles = createAppUseStyles<{
color: Node['color'],
color: NodeColor,
nodeHeight: number,
nodeWidth: number,
}>(theme => {
-12
View File
@@ -1,13 +1 @@
export type Point = [number, number];
export type BBox = [Point, Point];
export type NodeColor = 'red' | 'blue' | 'green';
export interface Node {
loc: Point;
text: string;
color: NodeColor;
}
export type EdgeDirection = '1->2' | '1<->2' | '1<-2';
export interface BoundedObj<J> {
elm: J;
bbox: BBox;
}
-51
View File
@@ -1,51 +0,0 @@
import { Point } from "types/graphs";
export const offsetPoint = (
[x, y]: Point,
[ox, oy]: Point = [0, 0],
): Point => [x + ox, y + oy];
export const applyPoints = (
[x1, y1]: Point,
[x2, y2]: Point,
fun: (a: number, b: number) => number,
): Point => [fun(x1, x2), fun(y1, y2)];
export const avgPoints = (
p1: Point,
p2: Point,
): Point => applyPoints(p1, p2, (a,b) => (a+b)/2);
export const minPoints = (
p1: Point,
p2: Point,
): Point => applyPoints(p1, p2, Math.min);
export const maxPoints = (
p1: Point,
p2: Point,
): Point => applyPoints(p1, p2, Math.max);
export const makeOffsetMaintainer = (startPoint: Point) => {
let offset: Point = [0, 0];
let i = 0;
return {
setI(newI: number) {
i = newI;
},
resetY() {
offset[1] = 0;
},
update(p: Point, innerStartLoc: Point) {
offset[0] = Math.max(offset[0], p[0] - i - 0.5 - startPoint[0])
offset[1] = Math.max(offset[1], p[1] - innerStartLoc[1] + 1)
},
get x() {
return offset[0]
},
get y() {
return offset[1]
}
}
}