Documentation ApertureHandler.js

This commit is contained in:
Erik Tiekstra
2017-06-12 12:11:40 +02:00
parent 2be5f17127
commit 46222e2726
+19
View File
@@ -1,5 +1,9 @@
'use strict'; 'use strict';
/**
* ApertureHandler takes care of the bars around the image to show what area has been/will be cropped.
* @param {canvas}
*/
function ApertureHandler(canvas) { function ApertureHandler(canvas) {
var _items = {x: [], y: []}; var _items = {x: [], y: []};
@@ -27,6 +31,11 @@ function ApertureHandler(canvas) {
} }
init(); init();
/**
* Applies configuration to the apertures apertures on the viewport
* @param {string} axis
* @param {viewport}
*/
this.apply = function (axis, viewport) { this.apply = function (axis, viewport) {
this.getApertures(axis).forEach(function (o) { this.getApertures(axis).forEach(function (o) {
o.visible = false; o.visible = false;
@@ -56,10 +65,20 @@ function ApertureHandler(canvas) {
canvas.renderAll(); canvas.renderAll();
}; };
/**
* Gets the apertures on specified axis. If no axis is provided, both x and y are returned.
* @param {string} axis
* @returns {Array}
*/
this.getApertures = function (axis) { this.getApertures = function (axis) {
return axis ? _items[axis] : [].concat(_items.x, _items.y); return axis ? _items[axis] : [].concat(_items.x, _items.y);
}; };
/**
* Sets transparency of the apertures depending on the crop status
* @param {boolean} apply
* @returns {ApertureHandler}
*/
this.setTransparent = function (apply) { this.setTransparent = function (apply) {
this.getApertures().forEach(function (o) { this.getApertures().forEach(function (o) {
o.opacity = apply ? 0.7 : 1; o.opacity = apply ? 0.7 : 1;