Skip to content

Commit be6d84d

Browse files
committed
Move unused functions to functions.ts
1 parent c261d55 commit be6d84d

2 files changed

Lines changed: 25 additions & 40 deletions

File tree

src/draw.ts

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
1-
import {
2-
combinePatterns,
3-
getBoundariesFromPattern,
4-
getScreenSize,
5-
mapPointToViewportSpace,
6-
} from './functions'
1+
import { combinePatterns, getBoundariesFromPattern, getScreenSize } from './functions'
72
import { Queue } from './queue'
8-
import {
9-
AbsoluteNumber,
10-
AbsolutePattern,
11-
Boundaries,
12-
Pattern,
13-
PatternNumber,
14-
Point,
15-
Size,
16-
State,
17-
ViewportPattern,
18-
} from './types'
3+
import { AbsoluteNumber, AbsolutePattern, Boundaries, State } from './types'
194

205
// -- constants
216

@@ -33,28 +18,6 @@ const MAX_QUEUE_SIZE = 1e6
3318
const MIN_PATTERN_SIZE = 0.0005 // ignore patterns where either side is smaller than this
3419
const DEBUG = true as boolean
3520

36-
// -- helper functions
37-
38-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
39-
const mapPatternToViewportSpace = (pattern: AbsolutePattern, screenSize: Size): ViewportPattern => ({
40-
anchor: mapPointToViewportSpace(pattern.anchor, screenSize),
41-
target: mapPointToViewportSpace(pattern.target, screenSize),
42-
})
43-
44-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
45-
const getPatternPoints = <N extends PatternNumber>(
46-
pattern: Pattern<N>
47-
): [Point<N>, Point<N>, Point<N>, Point<N>] => {
48-
const { xMin, xMax, yMin, yMax } = getBoundariesFromPattern(pattern)
49-
50-
return [
51-
[xMin, yMin], // top left
52-
[xMax, yMin], // top right
53-
[xMax, yMax], // bottom right
54-
[xMin, yMax], // bottom left
55-
]
56-
}
57-
5821
// We'll ignore everything that's a bit outside the viewport.
5922
// This is not really accurate, but should be OK for our purposes.
6023
const VALID_BOUNDARIES: Boundaries<AbsoluteNumber> = {
@@ -224,7 +187,7 @@ export function* drawFrameIncrementally(
224187

225188
const duration = measure(() => {
226189
const start = performance.now()
227-
190+
228191
while (true) {
229192
const iteratorResult = chunkedDrawsIterator.next()
230193

src/functions.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
RelativePoint,
1313
Size,
1414
State,
15+
ViewportPattern,
1516
ViewportPoint
1617
} from './types'
1718

@@ -63,6 +64,27 @@ export const mapPointToViewportSpace = (
6364
return [Math.round(x * viewportWidth), Math.round(y * viewportHeight)] satisfies NumberPair as ViewportPoint
6465
}
6566

67+
68+
// ts-unused-exports:disable-next-line
69+
export const mapPatternToViewportSpace = (pattern: AbsolutePattern, screenSize: Size): ViewportPattern => ({
70+
anchor: mapPointToViewportSpace(pattern.anchor, screenSize),
71+
target: mapPointToViewportSpace(pattern.target, screenSize),
72+
})
73+
74+
// ts-unused-exports:disable-next-line
75+
export const getPatternPoints = <N extends PatternNumber>(
76+
pattern: Pattern<N>
77+
): [Point<N>, Point<N>, Point<N>, Point<N>] => {
78+
const { xMin, xMax, yMin, yMax } = getBoundariesFromPattern(pattern)
79+
80+
return [
81+
[xMin, yMin], // top left
82+
[xMax, yMin], // top right
83+
[xMax, yMax], // bottom right
84+
[xMin, yMax], // bottom left
85+
]
86+
}
87+
6688
// ts-unused-exports:disable-next-line
6789
export const mapPointFromViewportSpace = (
6890
[x, y]: ViewportPoint,

0 commit comments

Comments
 (0)