UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

24 lines (20 loc) 575 B
import Vector2 from "../../../../core/geom/Vector2.js"; /** * * @param {Vector2} size * @param {AABB2} frame * @param {Vector2} margin * @param {number} x * @param {number} y * @return {Vector2} */ export function position_canvas_to_curve(size, frame, margin, x, y) { const width = size.x; const height = size.y; const u = (x - margin.x) / (width - margin.x * 2); const v = 1 - (y - margin.y) / (height - margin.y * 2); return new Vector2( u * frame.width + frame.x0, v * frame.height + frame.y0 ); }