mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 19:04:02 +00:00
Release God's Eye View as open source
This commit is contained in:
1 parent
a5aaea7e16
commit
880a672b5e
433 files changed
+219893
-23
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import { calculateLogoGaze } from './logoGaze.js';
|
||||
|
||||
const rect = { left: 100, top: 50, width: 80, height: 40 };
|
||||
|
||||
test('logo gaze is neutral when the cursor is centered', () => {
|
||||
assert.deepEqual(calculateLogoGaze(140, 70, rect), { x: 0, y: 0 });
|
||||
});
|
||||
|
||||
test('logo gaze follows direction and caps at the requested offset', () => {
|
||||
const gaze = calculateLogoGaze(1140, 70, rect, 28);
|
||||
assert.ok(Math.abs(gaze.x - 28) < 1e-9);
|
||||
assert.equal(gaze.y, 0);
|
||||
});
|
||||
|
||||
test('logo gaze uses the more visible default travel', () => {
|
||||
const gaze = calculateLogoGaze(1140, 70, rect);
|
||||
assert.ok(Math.abs(gaze.x - 34) < 1e-9);
|
||||
assert.equal(gaze.y, 0);
|
||||
});
|
||||
|
||||
test('logo gaze ramps proportionally inside the full-gaze distance', () => {
|
||||
const gaze = calculateLogoGaze(300, 70, rect, 28);
|
||||
assert.ok(Math.abs(gaze.x - 14) < 1e-9);
|
||||
assert.equal(gaze.y, 0);
|
||||
});
|
||||
|
||||
test('logo gaze preserves diagonal direction while staying bounded', () => {
|
||||
const gaze = calculateLogoGaze(640, 570, rect, 28);
|
||||
assert.ok(Math.abs(Math.hypot(gaze.x, gaze.y) - 28) < 1e-9);
|
||||
assert.ok(gaze.x > 0);
|
||||
assert.ok(gaze.y > 0);
|
||||
});
|
||||
|
||||
test('logo gaze fails closed for invalid geometry', () => {
|
||||
assert.deepEqual(calculateLogoGaze(10, 10, { ...rect, width: 0 }), { x: 0, y: 0 });
|
||||
assert.deepEqual(calculateLogoGaze(Number.NaN, 10, rect), { x: 0, y: 0 });
|
||||
});
|
||||
Reference in new issue
Block a user