File size: 1,944 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import 'calypso/state/editor/init';

/**
 * Returns an object representing the image editor transform
 * @param {Object}  state Global state tree
 * @returns {Object}  image editor transform { degrees, scaleX, scaleY }
 */
export function getImageEditorTransform( state ) {
	return state.editor.imageEditor.transform;
}

/**
 * Returns an object containing the image data loaded in the editor
 * @param  {Object}  state Global state tree
 * @returns {Object}  image data { src, fileName }
 */
export function getImageEditorFileInfo( state ) {
	return state.editor.imageEditor.fileInfo;
}

/**
 * Returns true if there were any changes made to the editor
 * @param  {Object}  state Global state tree
 * @returns {boolean} true if editor has changes
 */
export function imageEditorHasChanges( state ) {
	return state.editor.imageEditor.hasChanges;
}

/**
 * Returns true if image has been loaded.
 * @param  {Object}  state Global state tree
 * @returns {boolean} true if image has been loaded
 */
export function isImageEditorImageLoaded( state ) {
	return ! state.editor.imageEditor.imageIsLoading;
}

/**
 * Returns the bounds of the canvas crop tool
 * @param  {Object} state Global state tree
 * @returns {Object} topBound, leftBound, bottomBound and rightBound of the canvas
 */
export function getImageEditorCropBounds( state ) {
	return state.editor.imageEditor.cropBounds;
}

/**
 * Returns the crop data for the image editor
 * @param  {Object} state Global state tree
 * @returns {Object} topRatio, leftRatio, widthRatio and heightRatio of the crop
 */
export function getImageEditorCrop( state ) {
	return state.editor.imageEditor.crop;
}

/**
 * Returns the crop data for the image editor
 * @param  {Object} state Global state tree
 * @returns {Object} one of the AspectRatios as defined in state/editor/image-editor/constants
 */
export function getImageEditorAspectRatio( state ) {
	return state.editor.imageEditor.aspectRatio;
}