mirror of
https://github.com/GuerillaStudio/souvenir.git
synced 2025-01-21 04:10:21 +00:00
19 lines
348 B
JavaScript
19 lines
348 B
JavaScript
|
export function makeRectangle (x, y, width, height) {
|
||
|
return {
|
||
|
x,
|
||
|
y,
|
||
|
width,
|
||
|
height
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export function crop ({ x, y, width: w, height: h }) {
|
||
|
if (w < h) {
|
||
|
return makeRectangle((h - w) / 2, y, h, h)
|
||
|
} else if (w > h) {
|
||
|
return makeRectangle((w - h) / 2, y, h, h)
|
||
|
} else {
|
||
|
return makeRectangle(x, y, w, h)
|
||
|
}
|
||
|
}
|