UNPKG

@thi.ng/matrices

Version:

Matrix & quaternion operations for 2D/3D geometry processing

14 lines (13 loc) 404 B
import { mulM23 } from "./mulm.js"; import { scale23 } from "./scale.js"; import { translation23 } from "./translation.js"; const viewport = (out, left, right, bottom, top) => { const x = (left + right) / 2; const y = (bottom + top) / 2; const w = (right - left) / 2; const h = (top - bottom) / 2; return mulM23(null, translation23(out, [x, y]), scale23([], [w, h])); }; export { viewport };