This commit is contained in:
33333-33333 2026-06-01 18:27:25 +09:00
commit 2d42f7f487
7 changed files with 4065 additions and 0 deletions

24
js/vector.js Normal file
View file

@ -0,0 +1,24 @@
(function () {
'use strict';
const root = window.PixelIslandModules ||= {};
root.Vec2 = {
add(a, b) {
return { x: a.x + b.x, y: a.y + b.y };
},
sub(a, b) {
return { x: a.x - b.x, y: a.y - b.y };
},
scale(v, amount) {
return { x: v.x * amount, y: v.y * amount };
},
length(v) {
return Math.hypot(v.x, v.y);
},
normalize(v) {
const length = Math.hypot(v.x, v.y) || 1;
return { x: v.x / length, y: v.y / length };
}
};
})();