File size: 627 Bytes
9d57416
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
import test from 'node:test';
import assert from 'node:assert/strict';
import {intersects, pointInside} from '../src/layout.ts';
test('label rectangle overlap rejects touching interiors and permits separated text', () => {
  const first = {left: 0, top: 0, right: 20, bottom: 10};
  assert.equal(intersects(first, {left: 21, top: 0, right: 40, bottom: 10}), false);
  assert.equal(intersects(first, {left: 10, top: 0, right: 30, bottom: 10}), true);
  const room: [number, number][] = [[0, 0], [10, 0], [10, 10], [0, 10]];
  assert.equal(pointInside([5, 5], room), true);
  assert.equal(pointInside([15, 5], room), false);
});