All files / web/src/components/toys/coordinate-plane coordinatePlaneTicks.ts

0% Statements 0/19
0% Branches 0/1
0% Functions 0/1
0% Lines 0/19

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20                                       
import type { CoordinatePlaneState, TickMark, TickThresholds } from './types'
import { xSlice, ySlice } from './types'
import { DEFAULT_TICK_THRESHOLDS } from '../number-line/types'
import { computeTickMarks } from '../number-line/numberLineTicks'

/**
 * Compute visible tick marks for one axis of the coordinate plane.
 * Thin wrapper around the number line's computeTickMarks, using the
 * appropriate 1D slice of the 2D state.
 */
export function computeAxisTicks(
  state: CoordinatePlaneState,
  axis: 'x' | 'y',
  canvasExtent: number,
  thresholds: TickThresholds = DEFAULT_TICK_THRESHOLDS
): TickMark[] {
  const slice = axis === 'x' ? xSlice(state) : ySlice(state)
  return computeTickMarks(slice, canvasExtent, thresholds)
}