Documentation ApertureHandler.js
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
'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) {
|
||||
var _items = {x: [], y: []};
|
||||
|
||||
@@ -27,6 +31,11 @@ function ApertureHandler(canvas) {
|
||||
}
|
||||
init();
|
||||
|
||||
/**
|
||||
* Applies configuration to the apertures apertures on the viewport
|
||||
* @param {string} axis
|
||||
* @param {viewport}
|
||||
*/
|
||||
this.apply = function (axis, viewport) {
|
||||
this.getApertures(axis).forEach(function (o) {
|
||||
o.visible = false;
|
||||
@@ -56,10 +65,20 @@ function ApertureHandler(canvas) {
|
||||
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) {
|
||||
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.getApertures().forEach(function (o) {
|
||||
o.opacity = apply ? 0.7 : 1;
|
||||
|
||||
Reference in New Issue
Block a user