named_accessors.mixin.js 10.7 KB
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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
(function() {

  /**
   * Creates accessors (getXXX, setXXX) for a "class", based on "stateProperties" array
   * @static
   * @memberOf fabric.util
   * @param {Object} klass "Class" to create accessors for
   */
  fabric.util.createAccessors = function(klass) {
    var proto = klass.prototype, i, propName,
        capitalizedPropName, setterName, getterName;

    for (i = proto.stateProperties.length; i--; ) {

      propName = proto.stateProperties[i];
      capitalizedPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
      setterName = 'set' + capitalizedPropName;
      getterName = 'get' + capitalizedPropName;

      // using `new Function` for better introspection
      if (!proto[getterName]) {
        proto[getterName] = (function(property) {
          return new Function('return this.get("' + property + '")');
        })(propName);
      }
      if (!proto[setterName]) {
        proto[setterName] = (function(property) {
          return new Function('value', 'return this.set("' + property + '", value)');
        })(propName);
      }
    }
  };

  /** @lends fabric.Text.Prototype */
  /**
   * Retrieves object's fontSize
   * @method getFontSize
   * @memberOf fabric.Text.prototype
   * @return {String} Font size (in pixels)
   */

  /**
   * Sets object's fontSize
   * Does not update the object .width and .height,
   * call .initDimensions() to update the values.
   * @method setFontSize
   * @memberOf fabric.Text.prototype
   * @param {Number} fontSize Font size (in pixels)
   * @return {fabric.Text}
   * @chainable
   */

  /**
   * Retrieves object's fontWeight
   * @method getFontWeight
   * @memberOf fabric.Text.prototype
   * @return {(String|Number)} Font weight
   */

  /**
   * Sets object's fontWeight
   * Does not update the object .width and .height,
   * call .initDimensions() to update the values.
   * @method setFontWeight
   * @memberOf fabric.Text.prototype
   * @param {(Number|String)} fontWeight Font weight
   * @return {fabric.Text}
   * @chainable
   */

  /**
   * Retrieves object's fontFamily
   * @method getFontFamily
   * @memberOf fabric.Text.prototype
   * @return {String} Font family
   */

  /**
   * Sets object's fontFamily
   * Does not update the object .width and .height,
   * call .initDimensions() to update the values.
   * @method setFontFamily
   * @memberOf fabric.Text.prototype
   * @param {String} fontFamily Font family
   * @return {fabric.Text}
   * @chainable
   */

  /**
   * Retrieves object's text
   * @method getText
   * @memberOf fabric.Text.prototype
   * @return {String} text
   */

  /**
   * Sets object's text
   * Does not update the object .width and .height,
   * call .initDimensions() to update the values.
   * @method setText
   * @memberOf fabric.Text.prototype
   * @param {String} text Text
   * @return {fabric.Text}
   * @chainable
   */

  /**
   * Retrieves object's underline
   * @method getUnderline
   * @memberOf fabric.Text.prototype
   * @return {Boolean} underline enabled or disabled
   */

  /**
   * Sets object's underline
   * @method setUnderline
   * @memberOf fabric.Text.prototype
   * @param {Boolean} underline Text decoration
   * @return {fabric.Text}
   * @chainable
   */

  /**
   * Retrieves object's fontStyle
   * @method getFontStyle
   * @memberOf fabric.Text.prototype
   * @return {String} Font style
   */

  /**
   * Sets object's fontStyle
   * Does not update the object .width and .height,
   * call .initDimensions() to update the values.
   * @method setFontStyle
   * @memberOf fabric.Text.prototype
   * @param {String} fontStyle Font style
   * @return {fabric.Text}
   * @chainable
   */

  /**
   * Retrieves object's lineHeight
   * @method getLineHeight
   * @memberOf fabric.Text.prototype
   * @return {Number} Line height
   */

  /**
   * Sets object's lineHeight
   * @method setLineHeight
   * @memberOf fabric.Text.prototype
   * @param {Number} lineHeight Line height
   * @return {fabric.Text}
   * @chainable
   */

  /**
   * Retrieves object's textAlign
   * @method getTextAlign
   * @memberOf fabric.Text.prototype
   * @return {String} Text alignment
   */

  /**
   * Sets object's textAlign
   * @method setTextAlign
   * @memberOf fabric.Text.prototype
   * @param {String} textAlign Text alignment
   * @return {fabric.Text}
   * @chainable
   */

  /**
   * Retrieves object's textBackgroundColor
   * @method getTextBackgroundColor
   * @memberOf fabric.Text.prototype
   * @return {String} Text background color
   */

  /**
   * Sets object's textBackgroundColor
   * @method setTextBackgroundColor
   * @memberOf fabric.Text.prototype
   * @param {String} textBackgroundColor Text background color
   * @return {fabric.Text}
   * @chainable
   */

  /** @lends fabric.Object.Prototype */
  /**
   * Retrieves object's {@link fabric.Object#transformMatrix|transformMatrix}
   * @method getTransformMatrix
   * @memberOf fabric.Object.prototype
   * @return {Array} transformMatrix
   */

  /**
   * Sets object's {@link fabric.Object#transformMatrix|transformMatrix}
   * @method setTransformMatrix
   * @memberOf fabric.Object.prototype
   * @param {Array} transformMatrix
   * @return {fabric.Object} thisArg
   * @chainable
   */

  /**
   * Retrieves object's {@link fabric.Object#visible|visible} state
   * @method getVisible
   * @memberOf fabric.Object.prototype
   * @return {Boolean} True if visible
   */

  /**
   * Sets object's {@link fabric.Object#visible|visible} state
   * @method setVisible
   * @memberOf fabric.Object.prototype
   * @param {Boolean} value visible value
   * @return {fabric.Object} thisArg
   * @chainable
   */

  /**
   * Retrieves object's {@link fabric.Object#shadow|shadow}
   * @method getShadow
   * @memberOf fabric.Object.prototype
   * @return {Object} Shadow instance
   */

  /**
   * Retrieves object's {@link fabric.Object#stroke|stroke}
   * @method getStroke
   * @memberOf fabric.Object.prototype
   * @return {String} stroke value
   */

  /**
   * Sets object's {@link fabric.Object#stroke|stroke}
   * @method setStroke
   * @memberOf fabric.Object.prototype
   * @param {String} value stroke value
   * @return {fabric.Object} thisArg
   * @chainable
   */

  /**
   * Retrieves object's {@link fabric.Object#strokeWidth|strokeWidth}
   * @method getStrokeWidth
   * @memberOf fabric.Object.prototype
   * @return {Number} strokeWidth value
   */

  /**
   * Sets object's {@link fabric.Object#strokeWidth|strokeWidth}
   * @method setStrokeWidth
   * @memberOf fabric.Object.prototype
   * @param {Number} value strokeWidth value
   * @return {fabric.Object} thisArg
   * @chainable
   */

  /**
   * Retrieves object's {@link fabric.Object#originX|originX}
   * @method getOriginX
   * @memberOf fabric.Object.prototype
   * @return {String} originX value
   */

  /**
   * Sets object's {@link fabric.Object#originX|originX}
   * @method setOriginX
   * @memberOf fabric.Object.prototype
   * @param {String} value originX value
   * @return {fabric.Object} thisArg
   * @chainable
   */

  /**
   * Retrieves object's {@link fabric.Object#originY|originY}
   * @method getOriginY
   * @memberOf fabric.Object.prototype
   * @return {String} originY value
   */

  /**
   * Sets object's {@link fabric.Object#originY|originY}
   * @method setOriginY
   * @memberOf fabric.Object.prototype
   * @param {String} value originY value
   * @return {fabric.Object} thisArg
   * @chainable
   */

  /**
   * Retrieves object's {@link fabric.Object#fill|fill}
   * @method getFill
   * @memberOf fabric.Object.prototype
   * @return {String} Fill value
   */

  /**
   * Sets object's {@link fabric.Object#fill|fill}
   * @method setFill
   * @memberOf fabric.Object.prototype
   * @param {String} value Fill value
   * @return {fabric.Object} thisArg
   * @chainable
   */

  /**
   * Retrieves object's {@link fabric.Object#opacity|opacity}
   * @method getOpacity
   * @memberOf fabric.Object.prototype
   * @return {Number} Opacity value (0-1)
   */

  /**
   * Sets object's {@link fabric.Object#opacity|opacity}
   * @method setOpacity
   * @memberOf fabric.Object.prototype
   * @param {Number} value Opacity value (0-1)
   * @return {fabric.Object} thisArg
   * @chainable
   */

  /**
   * Retrieves object's {@link fabric.Object#angle|angle} (in degrees)
   * @method getAngle
   * @memberOf fabric.Object.prototype
   * @return {Number}
   */

  /**
   * Retrieves object's {@link fabric.Object#top|top position}
   * @method getTop
   * @memberOf fabric.Object.prototype
   * @return {Number} Top value (in pixels)
   */

  /**
   * Sets object's {@link fabric.Object#top|top position}
   * @method setTop
   * @memberOf fabric.Object.prototype
   * @param {Number} value Top value (in pixels)
   * @return {fabric.Object} thisArg
   * @chainable
   */

  /**
   * Retrieves object's {@link fabric.Object#left|left position}
   * @method getLeft
   * @memberOf fabric.Object.prototype
   * @return {Number} Left value (in pixels)
   */

  /**
   * Sets object's {@link fabric.Object#left|left position}
   * @method setLeft
   * @memberOf fabric.Object.prototype
   * @param {Number} value Left value (in pixels)
   * @return {fabric.Object} thisArg
   * @chainable
   */

  /**
   * Retrieves object's {@link fabric.Object#scaleX|scaleX} value
   * @method getScaleX
   * @memberOf fabric.Object.prototype
   * @return {Number} scaleX value
   */

  /**
   * Sets object's {@link fabric.Object#scaleX|scaleX} value
   * @method setScaleX
   * @memberOf fabric.Object.prototype
   * @param {Number} value scaleX value
   * @return {fabric.Object} thisArg
   * @chainable
   */

  /**
   * Retrieves object's {@link fabric.Object#scaleY|scaleY} value
   * @method getScaleY
   * @memberOf fabric.Object.prototype
   * @return {Number} scaleY value
   */

  /**
   * Sets object's {@link fabric.Object#scaleY|scaleY} value
   * @method setScaleY
   * @memberOf fabric.Object.prototype
   * @param {Number} value scaleY value
   * @return {fabric.Object} thisArg
   * @chainable
   */

  /**
   * Retrieves object's {@link fabric.Object#flipX|flipX} value
   * @method getFlipX
   * @memberOf fabric.Object.prototype
   * @return {Boolean} flipX value
   */

  /**
   * Sets object's {@link fabric.Object#flipX|flipX} value
   * @method setFlipX
   * @memberOf fabric.Object.prototype
   * @param {Boolean} value flipX value
   * @return {fabric.Object} thisArg
   * @chainable
   */

  /**
   * Retrieves object's {@link fabric.Object#flipY|flipY} value
   * @method getFlipY
   * @memberOf fabric.Object.prototype
   * @return {Boolean} flipY value
   */

  /**
   * Sets object's {@link fabric.Object#flipY|flipY} value
   * @method setFlipY
   * @memberOf fabric.Object.prototype
   * @param {Boolean} value flipY value
   * @return {fabric.Object} thisArg
   * @chainable
   */

})(typeof exports !== 'undefined' ? exports : this);