Skip to content

Commit

Permalink
refactor(geom-splines): update deps, imports, use new Fn types
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Sep 5, 2020
1 parent 780a7b7 commit 7921929
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/imgui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@microsoft/api-extractor": "^7.9.11",
"@thi.ng/api": "^6.12.3",
"@types/mocha": "^8.0.3",
"@types/node": "^14.6.1",
"mocha": "^8.1.2",
Expand All @@ -49,7 +50,6 @@
"typescript": "^4.0.2"
},
"dependencies": {
"@thi.ng/api": "^6.12.3",
"@thi.ng/checks": "^2.7.7",
"@thi.ng/geom": "^1.11.7",
"@thi.ng/geom-api": "^1.0.33",
Expand Down
2 changes: 1 addition & 1 deletion packages/imgui/src/behaviors/button.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { pointInside } from "@thi.ng/geom";
import type { IShape } from "@thi.ng/geom-api";
import { Key } from "../api";
import { IMGUI } from "../gui";
import type { IShape } from "@thi.ng/geom-api";

export const isHoverButton = (gui: IMGUI, id: string, shape: IShape) => {
if (gui.disabled) return false;
Expand Down
5 changes: 3 additions & 2 deletions packages/imgui/src/behaviors/slider.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { FnN4 } from "@thi.ng/api";
import { pointInside } from "@thi.ng/geom";
import type { IShape } from "@thi.ng/geom-api";
import { clamp, roundTo } from "@thi.ng/math";
import { add2, clamp2, round2, Vec } from "@thi.ng/vectors";
import { Key } from "../api";
import { IMGUI } from "../gui";
import type { IShape } from "@thi.ng/geom-api";

export const isHoverSlider = (
gui: IMGUI,
Expand All @@ -21,7 +22,7 @@ export const isHoverSlider = (
return hover;
};

export const slider1Val = (x: number, min: number, max: number, prec: number) =>
export const slider1Val: FnN4 = (x, min, max, prec) =>
clamp(roundTo(x, prec), min, max);

export const slider2Val = (v: Vec, min: Vec, max: Vec, prec: number) =>
Expand Down
4 changes: 2 additions & 2 deletions packages/imgui/src/components/button.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { rect } from "@thi.ng/geom";
import type { IShape } from "@thi.ng/geom-api";
import { IGridLayout, isLayout, LayoutBox } from "@thi.ng/layout";
import { hash, ZERO2 } from "@thi.ng/vectors";
import type { Color, Hash } from "../api";
import { handleButtonKeys, isHoverButton } from "../behaviors/button";
import { IMGUI } from "../gui";
import { labelHash } from "../hash";
import { textLabelRaw, textTransformH, textTransformV } from "./textlabel";
import { tooltipRaw } from "./tooltip";
import type { IShape } from "@thi.ng/geom-api";
import type { Color, Hash } from "../api";

const mkLabel = (transform: number[], fill: Color, label: string) =>
textLabelRaw(ZERO2, { transform, fill }, label);
Expand Down
2 changes: 1 addition & 1 deletion packages/imgui/src/components/dial.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Fn } from "@thi.ng/api";
import { circle, line } from "@thi.ng/geom";
import { IGridLayout, isLayout, LayoutBox } from "@thi.ng/layout";
import { HALF_PI, norm, PI, TAU } from "@thi.ng/math";
Expand All @@ -8,7 +9,6 @@ import { IMGUI } from "../gui";
import { valHash } from "../hash";
import { textLabelRaw } from "./textlabel";
import { tooltipRaw } from "./tooltip";
import type { Fn } from "@thi.ng/api";

export const dial = (
gui: IMGUI,
Expand Down
4 changes: 2 additions & 2 deletions packages/imgui/src/components/ring.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Fn, FnN2 } from "@thi.ng/api";
import { polygon } from "@thi.ng/geom";
import { pointInRect } from "@thi.ng/geom-isec";
import { IGridLayout, isLayout, LayoutBox } from "@thi.ng/layout";
Expand All @@ -10,9 +11,8 @@ import { IMGUI } from "../gui";
import { valHash } from "../hash";
import { textLabelRaw } from "./textlabel";
import { tooltipRaw } from "./tooltip";
import type { Fn } from "@thi.ng/api";

const ringHeight = (w: number, thetaGap: number) =>
const ringHeight: FnN2 = (w, thetaGap) =>
(w / 2) * (1 + Math.sin(HALF_PI + thetaGap / 2));

const arcVerts = (
Expand Down
2 changes: 1 addition & 1 deletion packages/imgui/src/components/sliderh.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Fn } from "@thi.ng/api";
import { rect } from "@thi.ng/geom";
import { IGridLayout, isLayout, LayoutBox } from "@thi.ng/layout";
import { fit, norm } from "@thi.ng/math";
Expand All @@ -11,7 +12,6 @@ import { IMGUI } from "../gui";
import { valHash } from "../hash";
import { textLabelRaw } from "./textlabel";
import { tooltipRaw } from "./tooltip";
import type { Fn } from "@thi.ng/api";

export const sliderH = (
gui: IMGUI,
Expand Down
2 changes: 1 addition & 1 deletion packages/imgui/src/components/sliderv.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Fn } from "@thi.ng/api";
import { rect } from "@thi.ng/geom";
import { IGridLayout, isLayout, LayoutBox } from "@thi.ng/layout";
import { fit, norm } from "@thi.ng/math";
Expand All @@ -11,7 +12,6 @@ import { IMGUI } from "../gui";
import { valHash } from "../hash";
import { textLabelRaw, textTransformV } from "./textlabel";
import { tooltipRaw } from "./tooltip";
import type { Fn } from "@thi.ng/api";

export const sliderV = (
gui: IMGUI,
Expand Down
2 changes: 1 addition & 1 deletion packages/imgui/src/components/textfield.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Predicate } from "@thi.ng/api";
import { rect } from "@thi.ng/geom";
import { IGridLayout, isLayout, LayoutBox } from "@thi.ng/layout";
import { fitClamped } from "@thi.ng/math";
Expand All @@ -7,7 +8,6 @@ import { isHoverSlider } from "../behaviors/slider";
import { IMGUI } from "../gui";
import { textLabelRaw } from "./textlabel";
import { tooltipRaw } from "./tooltip";
import type { Predicate } from "@thi.ng/api";

interface TextfieldState {
cursor: number;
Expand Down
2 changes: 1 addition & 1 deletion packages/imgui/src/components/textlabel.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { isPlainObject } from "@thi.ng/checks";
import { IGridLayout, isLayout, LayoutBox } from "@thi.ng/layout";
import { IMGUI } from "../gui";
import type { ReadonlyVec } from "@thi.ng/vectors";
import type { Color, GUITheme } from "../api";
import { IMGUI } from "../gui";

export const textLabel = (
gui: IMGUI,
Expand Down
2 changes: 1 addition & 1 deletion packages/imgui/src/components/xypad.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Fn } from "@thi.ng/api";
import { line, rect } from "@thi.ng/geom";
import { IGridLayout, LayoutBox } from "@thi.ng/layout";
import { fit2, hash, Vec } from "@thi.ng/vectors";
Expand All @@ -9,7 +10,6 @@ import {
import { IMGUI } from "../gui";
import { textLabelRaw } from "./textlabel";
import { tooltipRaw } from "./tooltip";
import type { Fn } from "@thi.ng/api";

/**
* `mode` interpretation:
Expand Down
2 changes: 1 addition & 1 deletion packages/imgui/src/gui.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Fn0, IClear, IToHiccup } from "@thi.ng/api";
import { set2, Vec } from "@thi.ng/vectors";
import {
DEFAULT_THEME,
Expand All @@ -9,7 +10,6 @@ import {
MouseButton,
NONE,
} from "./api";
import type { Fn0, IClear, IToHiccup } from "@thi.ng/api";

export class IMGUI implements IClear, IToHiccup {
attribs!: any;
Expand Down

0 comments on commit 7921929

Please sign in to comment.