All files / player-browser/src/view/beatoraja/play generic-lane-rects.ts

92.3% Statements 12/13
50% Branches 1/2
100% Functions 6/6
100% Lines 7/7

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        7x 11x 11x 11x 11x 7x 234x    
import type { BeatorajaNoteRect } from '@be-music/skin-beatoraja';
 
/** A generic keyboard borrows the skin's note-area bounds, never its scratch or fixed key-column assignments. */
export function createGenericLaneRects(rects: readonly BeatorajaNoteRect[], count: number): BeatorajaNoteRect[] {
  Iif (rects.length === 0) return [];
  const left = Math.min(...rects.map((rect) => rect.x));
  const right = Math.max(...rects.map((rect) => rect.x + rect.w));
  const top = Math.min(...rects.map((rect) => rect.y));
  const bottom = Math.max(...rects.map((rect) => rect.y + rect.h));
  const width = (right - left) / count;
  return Array.from({ length: count }, (_, index) => ({ x: left + index * width, y: top, w: width, h: bottom - top }));
}