File size: 2,567 Bytes
b456468
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/**
 * Component interface
 * @class
 * @param {string} name - component name
 * @param {Graphics} graphics - Graphics instance
 * @ignore
 */
class Component {
  constructor(name, graphics) {
    /**
     * Component name
     * @type {string}
     */
    this.name = name;

    /**
     * Graphics instance
     * @type {Graphics}
     */
    this.graphics = graphics;
  }

  /**
   * Fire Graphics event
   * @returns {Object} return value
   */
  fire(...args) {
    const context = this.graphics;

    return this.graphics.fire.apply(context, args);
  }

  /**
   * Save image(background) of canvas
   * @param {string} name - Name of image
   * @param {fabric.Image} oImage - Fabric image instance
   */
  setCanvasImage(name, oImage) {
    this.graphics.setCanvasImage(name, oImage);
  }

  /**
   * Returns canvas element of fabric.Canvas[[lower-canvas]]
   * @returns {HTMLCanvasElement}
   */
  getCanvasElement() {
    return this.graphics.getCanvasElement();
  }

  /**
   * Get fabric.Canvas instance
   * @returns {fabric.Canvas}
   */
  getCanvas() {
    return this.graphics.getCanvas();
  }

  /**
   * Get canvasImage (fabric.Image instance)
   * @returns {fabric.Image}
   */
  getCanvasImage() {
    return this.graphics.getCanvasImage();
  }

  /**
   * Get image name
   * @returns {string}
   */
  getImageName() {
    return this.graphics.getImageName();
  }

  /**
   * Get image editor
   * @returns {ImageEditor}
   */
  getEditor() {
    return this.graphics.getEditor();
  }

  /**
   * Return component name
   * @returns {string}
   */
  getName() {
    return this.name;
  }

  /**
   * Set image properties
   * @param {Object} setting - Image properties
   * @param {boolean} [withRendering] - If true, The changed image will be reflected in the canvas
   */
  setImageProperties(setting, withRendering) {
    this.graphics.setImageProperties(setting, withRendering);
  }

  /**
   * Set canvas dimension - css only
   * @param {Object} dimension - Canvas css dimension
   */
  setCanvasCssDimension(dimension) {
    this.graphics.setCanvasCssDimension(dimension);
  }

  /**
   * Set canvas dimension - css only
   * @param {Object} dimension - Canvas backstore dimension
   */
  setCanvasBackstoreDimension(dimension) {
    this.graphics.setCanvasBackstoreDimension(dimension);
  }

  /**
   * Adjust canvas dimension with scaling image
   */
  adjustCanvasDimension() {
    this.graphics.adjustCanvasDimension();
  }

  adjustCanvasDimensionBase() {
    this.graphics.adjustCanvasDimensionBase();
  }
}

export default Component;