You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
36 lines
1.0 KiB
/**
|
|
* Copyright 2013 Matthieu Moquet
|
|
* Copyright 2016-2017 LasLabs Inc.
|
|
* License MIT (https://opensource.org/licenses/MIT)
|
|
**/
|
|
|
|
(function() {
|
|
'use strict';
|
|
|
|
Darkroom.Utils = {
|
|
extend: extend,
|
|
computeImageViewPort: computeImageViewPort,
|
|
};
|
|
|
|
// Utility method to easily extend objects.
|
|
function extend(b, a) {
|
|
var prop;
|
|
if (b === undefined) {
|
|
return a;
|
|
}
|
|
|
|
for (prop in a) {
|
|
if (a.hasOwnProperty(prop) && b.hasOwnProperty(prop) === false) {
|
|
b[prop] = a[prop];
|
|
}
|
|
}
|
|
return b;
|
|
}
|
|
|
|
function computeImageViewPort(image) {
|
|
return {
|
|
height: Math.abs(image.getWidth() * (Math.sin(image.getAngle() * Math.PI/180))) + Math.abs(image.getHeight() * (Math.cos(image.getAngle() * Math.PI/180))),
|
|
width: Math.abs(image.getHeight() * (Math.sin(image.getAngle() * Math.PI/180))) + Math.abs(image.getWidth() * (Math.cos(image.getAngle() * Math.PI/180))),
|
|
};
|
|
}
|
|
})();
|