mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
refactor validators
This commit is contained in:
parent
4a6eba726c
commit
5cbfe07e6e
4
konva.min.js
vendored
4
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,7 +1,8 @@
|
||||
import { Util } from './Util';
|
||||
import { SceneContext, HitContext, Context } from './Context';
|
||||
import { glob, getGlobalKonva } from './Global';
|
||||
import { Factory, Validators } from './Factory';
|
||||
import { Factory } from './Factory';
|
||||
import { getNumberValidator } from './Validators';
|
||||
|
||||
// calculate pixel ratio
|
||||
var _pixelRatio;
|
||||
@ -161,12 +162,7 @@ export class Canvas {
|
||||
* // set
|
||||
* canvas.pixelRatio(100);
|
||||
*/
|
||||
Factory.addGetterSetter(
|
||||
Canvas,
|
||||
'pixelRatio',
|
||||
undefined,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Canvas, 'pixelRatio', undefined, getNumberValidator());
|
||||
|
||||
export class SceneCanvas extends Canvas {
|
||||
constructor(config: ICanvasConfig = { width: 0, height: 0 }) {
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Util, Collection } from './Util';
|
||||
import { Factory, Validators } from './Factory';
|
||||
import { Factory } from './Factory';
|
||||
import { Node, ids, names } from './Node';
|
||||
import { DD } from './DragAndDrop';
|
||||
import { getNumberValidator } from './Validators';
|
||||
|
||||
import { GetSet, IRect } from './types';
|
||||
|
||||
@ -500,9 +501,7 @@ export abstract class Container extends Node {
|
||||
shouldDrawHit(canvas?) {
|
||||
var layer = this.getLayer();
|
||||
var layerUnderDrag =
|
||||
DD.isDragging &&
|
||||
DD.anim.getLayers()
|
||||
.indexOf(layer) !== -1;
|
||||
DD.isDragging && DD.anim.getLayers().indexOf(layer) !== -1;
|
||||
return (
|
||||
(canvas && canvas.isCache) ||
|
||||
(layer && layer.hitGraphEnabled() && this.isVisible() && !layerUnderDrag)
|
||||
@ -623,12 +622,7 @@ Factory.addComponentsGetterSetter(Container, 'clip', [
|
||||
* });
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Container,
|
||||
'clipX',
|
||||
undefined,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Container, 'clipX', undefined, getNumberValidator());
|
||||
/**
|
||||
* get/set clip x
|
||||
* @name Konva.Container#clipX
|
||||
@ -643,12 +637,7 @@ Factory.addGetterSetter(
|
||||
* container.clipX(10);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Container,
|
||||
'clipY',
|
||||
undefined,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Container, 'clipY', undefined, getNumberValidator());
|
||||
/**
|
||||
* get/set clip y
|
||||
* @name Konva.Container#clipY
|
||||
@ -667,7 +656,7 @@ Factory.addGetterSetter(
|
||||
Container,
|
||||
'clipWidth',
|
||||
undefined,
|
||||
Validators.getNumberValidator()
|
||||
getNumberValidator()
|
||||
);
|
||||
/**
|
||||
* get/set clip width
|
||||
@ -687,7 +676,7 @@ Factory.addGetterSetter(
|
||||
Container,
|
||||
'clipHeight',
|
||||
undefined,
|
||||
Validators.getNumberValidator()
|
||||
getNumberValidator()
|
||||
);
|
||||
/**
|
||||
* get/set clip height
|
||||
|
163
src/Factory.ts
163
src/Factory.ts
@ -1,6 +1,5 @@
|
||||
import { isUnminified } from './Global';
|
||||
import { Util } from './Util';
|
||||
import Konva from './index';
|
||||
import { getComponentValidator } from './Validators';
|
||||
|
||||
var GET = 'get',
|
||||
SET = 'set';
|
||||
@ -65,7 +64,7 @@ export const Factory = {
|
||||
return ret;
|
||||
};
|
||||
|
||||
var basicValidator = Validators.getComponentValidator(components);
|
||||
var basicValidator = getComponentValidator(components);
|
||||
|
||||
// setter
|
||||
constructor.prototype[setter] = function(val) {
|
||||
@ -157,161 +156,3 @@ export const Factory = {
|
||||
this._filterUpToDate = false;
|
||||
}
|
||||
};
|
||||
|
||||
export const Validators = {
|
||||
/**
|
||||
* @return {number}
|
||||
*/
|
||||
RGBComponent(val) {
|
||||
if (val > 255) {
|
||||
return 255;
|
||||
} else if (val < 0) {
|
||||
return 0;
|
||||
}
|
||||
return Math.round(val);
|
||||
},
|
||||
alphaComponent(val) {
|
||||
if (val > 1) {
|
||||
return 1;
|
||||
} else if (val < 0.0001) {
|
||||
// chrome does not honor alpha values of 0
|
||||
return 0.0001;
|
||||
}
|
||||
|
||||
return val;
|
||||
},
|
||||
_formatValue(val) {
|
||||
if (Util._isString(val)) {
|
||||
return '"' + val + '"';
|
||||
}
|
||||
if (Object.prototype.toString.call(val) === '[object Number]') {
|
||||
return val;
|
||||
}
|
||||
if (Util._isBoolean(val)) {
|
||||
return val;
|
||||
}
|
||||
return Object.prototype.toString.call(val);
|
||||
},
|
||||
getNumberValidator() {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
if (!Util._isNumber(val)) {
|
||||
Util.warn(
|
||||
Validators._formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be a number.'
|
||||
);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
},
|
||||
getNumberOrAutoValidator() {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
var isNumber = Util._isNumber(val);
|
||||
var isAuto = val === 'auto';
|
||||
|
||||
if (!(isNumber || isAuto)) {
|
||||
Util.warn(
|
||||
Validators._formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be a number or "auto".'
|
||||
);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
},
|
||||
getStringValidator() {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
if (!Util._isString(val)) {
|
||||
Util.warn(
|
||||
Validators._formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be a string.'
|
||||
);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
},
|
||||
getFunctionValidator() {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
if (!Util._isFunction(val)) {
|
||||
Util.warn(
|
||||
Validators._formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be a function.'
|
||||
);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
},
|
||||
getNumberArrayValidator() {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
if (!Util._isArray(val)) {
|
||||
Util.warn(
|
||||
Validators._formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be a array of numbers.'
|
||||
);
|
||||
} else {
|
||||
val.forEach(function(item) {
|
||||
if (!Util._isNumber(item)) {
|
||||
Util.warn(
|
||||
'"' +
|
||||
attr +
|
||||
'" attribute has non numeric element ' +
|
||||
item +
|
||||
'. Make sure that all elements are numbers.'
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
},
|
||||
getBooleanValidator() {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
var isBool = val === true || val === false;
|
||||
if (!isBool) {
|
||||
Util.warn(
|
||||
Validators._formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be a boolean.'
|
||||
);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
},
|
||||
getComponentValidator(components) {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
if (!Util.isObject(val)) {
|
||||
Util.warn(
|
||||
Validators._formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be an object with properties ' +
|
||||
components
|
||||
);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Util, Collection } from './Util';
|
||||
import { Factory, Validators } from './Factory';
|
||||
import { Container } from './Container';
|
||||
|
||||
/**
|
||||
* Group constructor. Groups are used to contain shapes or other groups.
|
||||
* @constructor
|
||||
|
10
src/Layer.ts
10
src/Layer.ts
@ -1,9 +1,10 @@
|
||||
import { Util, Collection } from './Util';
|
||||
import { Container } from './Container';
|
||||
import { Factory, Validators } from './Factory';
|
||||
import { Factory } from './Factory';
|
||||
import { BaseLayer } from './BaseLayer';
|
||||
import { HitCanvas } from './Canvas';
|
||||
import { shapes } from './Shape';
|
||||
import { getBooleanValidator } from './Validators';
|
||||
|
||||
import { GetSet } from './types';
|
||||
|
||||
@ -233,12 +234,7 @@ export class Layer extends BaseLayer {
|
||||
hitGraphEnabled: GetSet<boolean, this>;
|
||||
}
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Layer,
|
||||
'hitGraphEnabled',
|
||||
true,
|
||||
Validators.getBooleanValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Layer, 'hitGraphEnabled', true, getBooleanValidator());
|
||||
/**
|
||||
* get/set hitGraphEnabled flag. Disabling the hit graph will greatly increase
|
||||
* draw performance because the hit graph will not be redrawn each time the layer is
|
||||
|
65
src/Node.ts
65
src/Node.ts
@ -1,10 +1,15 @@
|
||||
import { Util, Collection, Transform, RectConf, Point } from './Util';
|
||||
import { Factory, Validators } from './Factory';
|
||||
import { Factory } from './Factory';
|
||||
import { SceneCanvas, HitCanvas } from './Canvas';
|
||||
import { getGlobalKonva } from './Global';
|
||||
import { Container } from './Container';
|
||||
import { GetSet, Vector2d } from './types';
|
||||
import { DD } from './DragAndDrop';
|
||||
import {
|
||||
getNumberValidator,
|
||||
getStringValidator,
|
||||
getBooleanValidator
|
||||
} from './Validators';
|
||||
|
||||
export const ids = {};
|
||||
export const names = {};
|
||||
@ -2412,7 +2417,7 @@ Factory.addGetterSetter(Node, 'position');
|
||||
* });
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Node, 'x', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Node, 'x', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set x position
|
||||
@ -2428,7 +2433,7 @@ Factory.addGetterSetter(Node, 'x', 0, Validators.getNumberValidator());
|
||||
* node.x(5);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Node, 'y', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Node, 'y', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set y position
|
||||
@ -2448,7 +2453,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'globalCompositeOperation',
|
||||
'source-over',
|
||||
Validators.getStringValidator()
|
||||
getStringValidator()
|
||||
);
|
||||
|
||||
/**
|
||||
@ -2464,7 +2469,7 @@ Factory.addGetterSetter(
|
||||
* // set globalCompositeOperation
|
||||
* shape.globalCompositeOperation('source-in');
|
||||
*/
|
||||
Factory.addGetterSetter(Node, 'opacity', 1, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Node, 'opacity', 1, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set opacity. Opacity values range from 0 to 1.
|
||||
@ -2482,7 +2487,7 @@ Factory.addGetterSetter(Node, 'opacity', 1, Validators.getNumberValidator());
|
||||
* node.opacity(0.5);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Node, 'name', '', Validators.getStringValidator());
|
||||
Factory.addGetterSetter(Node, 'name', '', getStringValidator());
|
||||
|
||||
/**
|
||||
* get/set name
|
||||
@ -2501,7 +2506,7 @@ Factory.addGetterSetter(Node, 'name', '', Validators.getStringValidator());
|
||||
* node.name('foo bar');
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Node, 'id', '', Validators.getStringValidator());
|
||||
Factory.addGetterSetter(Node, 'id', '', getStringValidator());
|
||||
|
||||
/**
|
||||
* get/set id. Id is global for whole page.
|
||||
@ -2517,7 +2522,7 @@ Factory.addGetterSetter(Node, 'id', '', Validators.getStringValidator());
|
||||
* node.id('foo');
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Node, 'rotation', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Node, 'rotation', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set rotation in degrees
|
||||
@ -2554,7 +2559,7 @@ Factory.addComponentsGetterSetter(Node, 'scale', ['x', 'y']);
|
||||
* });
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Node, 'scaleX', 1, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Node, 'scaleX', 1, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set scale x
|
||||
@ -2570,7 +2575,7 @@ Factory.addGetterSetter(Node, 'scaleX', 1, Validators.getNumberValidator());
|
||||
* node.scaleX(2);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Node, 'scaleY', 1, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Node, 'scaleY', 1, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set scale y
|
||||
@ -2607,7 +2612,7 @@ Factory.addComponentsGetterSetter(Node, 'skew', ['x', 'y']);
|
||||
* });
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Node, 'skewX', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Node, 'skewX', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set skew x
|
||||
@ -2623,7 +2628,7 @@ Factory.addGetterSetter(Node, 'skewX', 0, Validators.getNumberValidator());
|
||||
* node.skewX(3);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Node, 'skewY', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Node, 'skewY', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set skew y
|
||||
@ -2659,7 +2664,7 @@ Factory.addComponentsGetterSetter(Node, 'offset', ['x', 'y']);
|
||||
* });
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Node, 'offsetX', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Node, 'offsetX', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set offset x
|
||||
@ -2675,7 +2680,7 @@ Factory.addGetterSetter(Node, 'offsetX', 0, Validators.getNumberValidator());
|
||||
* node.offsetX(3);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Node, 'offsetY', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Node, 'offsetY', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set offset y
|
||||
@ -2691,12 +2696,7 @@ Factory.addGetterSetter(Node, 'offsetY', 0, Validators.getNumberValidator());
|
||||
* node.offsetY(3);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Node,
|
||||
'dragDistance',
|
||||
null,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Node, 'dragDistance', null, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set drag distance
|
||||
@ -2715,7 +2715,7 @@ Factory.addGetterSetter(
|
||||
* Konva.dragDistance = 3;
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Node, 'width', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Node, 'width', 0, getNumberValidator());
|
||||
/**
|
||||
* get/set width
|
||||
* @name Konva.Node#width
|
||||
@ -2730,7 +2730,7 @@ Factory.addGetterSetter(Node, 'width', 0, Validators.getNumberValidator());
|
||||
* node.width(100);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Node, 'height', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Node, 'height', 0, getNumberValidator());
|
||||
/**
|
||||
* get/set height
|
||||
* @name Konva.Node#height
|
||||
@ -2795,12 +2795,7 @@ Factory.addGetterSetter(Node, 'listening', 'inherit', function(val) {
|
||||
* shape.preventDefault(false);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Node,
|
||||
'preventDefault',
|
||||
true,
|
||||
Validators.getBooleanValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Node, 'preventDefault', true, getBooleanValidator());
|
||||
|
||||
Factory.addGetterSetter(Node, 'filters', null, function(val) {
|
||||
this._filterUpToDate = false;
|
||||
@ -2861,12 +2856,7 @@ Factory.addGetterSetter(Node, 'visible', 'inherit', function(val) {
|
||||
* node.visible('inherit');
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Node,
|
||||
'transformsEnabled',
|
||||
'all',
|
||||
Validators.getStringValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Node, 'transformsEnabled', 'all', getStringValidator());
|
||||
|
||||
/**
|
||||
* get/set transforms that are enabled. Can be "all", "none", or "position". The default
|
||||
@ -2944,12 +2934,7 @@ Factory.addGetterSetter(Node, 'dragBoundFunc');
|
||||
* // disable drag and drop
|
||||
* node.draggable(false);
|
||||
*/
|
||||
Factory.addGetterSetter(
|
||||
Node,
|
||||
'draggable',
|
||||
false,
|
||||
Validators.getBooleanValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Node, 'draggable', false, getBooleanValidator());
|
||||
|
||||
Factory.backCompat(Node, {
|
||||
rotateDeg: 'rotate',
|
||||
|
123
src/Shape.ts
123
src/Shape.ts
@ -1,6 +1,11 @@
|
||||
import { Util, Collection } from './Util';
|
||||
import { Factory, Validators } from './Factory';
|
||||
import { Factory } from './Factory';
|
||||
import { Node } from './Node';
|
||||
import {
|
||||
getNumberValidator,
|
||||
getStringValidator,
|
||||
getBooleanValidator
|
||||
} from './Validators';
|
||||
|
||||
import { GetSet, Vector2d } from './types';
|
||||
import { Context } from './Context';
|
||||
@ -699,12 +704,7 @@ Shape.prototype._centroid = false;
|
||||
Shape.prototype.nodeType = 'Shape';
|
||||
|
||||
// add getters and setters
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'stroke',
|
||||
undefined,
|
||||
Validators.getStringValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'stroke', undefined, getStringValidator());
|
||||
|
||||
/**
|
||||
* get/set stroke color
|
||||
@ -729,12 +729,7 @@ Factory.addGetterSetter(
|
||||
* shape.stroke('rgba(0,255,0,0.5');
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'strokeWidth',
|
||||
2,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'strokeWidth', 2, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set stroke width
|
||||
@ -750,12 +745,7 @@ Factory.addGetterSetter(
|
||||
* shape.strokeWidth();
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'strokeHitEnabled',
|
||||
true,
|
||||
Validators.getBooleanValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'strokeHitEnabled', true, getBooleanValidator());
|
||||
|
||||
/**
|
||||
* get/set strokeHitEnabled property. Useful for performance optimization.
|
||||
@ -779,7 +769,7 @@ Factory.addGetterSetter(
|
||||
Shape,
|
||||
'perfectDrawEnabled',
|
||||
true,
|
||||
Validators.getBooleanValidator()
|
||||
getBooleanValidator()
|
||||
);
|
||||
|
||||
/**
|
||||
@ -802,7 +792,7 @@ Factory.addGetterSetter(
|
||||
Shape,
|
||||
'shadowForStrokeEnabled',
|
||||
true,
|
||||
Validators.getBooleanValidator()
|
||||
getBooleanValidator()
|
||||
);
|
||||
|
||||
/**
|
||||
@ -918,12 +908,7 @@ Factory.addGetterSetter(Shape, 'dash');
|
||||
* line.dash([10, 20, 0.001, 20]);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'dashOffset',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'dashOffset', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set dash offset for stroke.
|
||||
@ -937,12 +922,7 @@ Factory.addGetterSetter(
|
||||
* line.dashOffset(5);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'shadowColor',
|
||||
undefined,
|
||||
Validators.getStringValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'shadowColor', undefined, getStringValidator());
|
||||
|
||||
/**
|
||||
* get/set shadow color
|
||||
@ -967,12 +947,7 @@ Factory.addGetterSetter(
|
||||
* shape.shadowColor('rgba(0,255,0,0.5');
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'shadowBlur',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'shadowBlur', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set shadow blur
|
||||
@ -988,12 +963,7 @@ Factory.addGetterSetter(
|
||||
* shape.shadowBlur(10);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'shadowOpacity',
|
||||
1,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'shadowOpacity', 1, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set shadow opacity. must be a value between 0 and 1
|
||||
@ -1030,12 +1000,7 @@ Factory.addComponentsGetterSetter(Shape, 'shadowOffset', ['x', 'y']);
|
||||
* });
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'shadowOffsetX',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'shadowOffsetX', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set shadow offset x
|
||||
@ -1051,12 +1016,7 @@ Factory.addGetterSetter(
|
||||
* shape.shadowOffsetX(5);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'shadowOffsetY',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'shadowOffsetY', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set shadow offset y
|
||||
@ -1092,12 +1052,7 @@ Factory.addGetterSetter(Shape, 'fillPatternImage');
|
||||
* imageObj.src = 'path/to/image/jpg';
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'fill',
|
||||
undefined,
|
||||
Validators.getStringValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'fill', undefined, getStringValidator());
|
||||
|
||||
/**
|
||||
* get/set fill color
|
||||
@ -1125,12 +1080,7 @@ Factory.addGetterSetter(
|
||||
* shape.fill(null);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'fillPatternX',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'fillPatternX', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set fill pattern x
|
||||
@ -1145,12 +1095,7 @@ Factory.addGetterSetter(
|
||||
* shape.fillPatternX(20);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'fillPatternY',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'fillPatternY', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set fill pattern y
|
||||
@ -1400,12 +1345,7 @@ Factory.addComponentsGetterSetter(Shape, 'fillPatternOffset', ['x', 'y']);
|
||||
* });
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'fillPatternOffsetX',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'fillPatternOffsetX', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set fill pattern offset x
|
||||
@ -1421,12 +1361,7 @@ Factory.addGetterSetter(
|
||||
* shape.fillPatternOffsetX(20);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'fillPatternOffsetY',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'fillPatternOffsetY', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set fill pattern offset y
|
||||
@ -1463,12 +1398,7 @@ Factory.addComponentsGetterSetter(Shape, 'fillPatternScale', ['x', 'y']);
|
||||
* });
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'fillPatternScaleX',
|
||||
1,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'fillPatternScaleX', 1, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set fill pattern scale x
|
||||
@ -1484,12 +1414,7 @@ Factory.addGetterSetter(
|
||||
* shape.fillPatternScaleX(2);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Shape,
|
||||
'fillPatternScaleY',
|
||||
1,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Shape, 'fillPatternScaleY', 1, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set fill pattern scale y
|
||||
|
157
src/Validators.ts
Normal file
157
src/Validators.ts
Normal file
@ -0,0 +1,157 @@
|
||||
import { isUnminified } from './Global';
|
||||
import { Util } from './Util';
|
||||
|
||||
function _formatValue(val) {
|
||||
if (Util._isString(val)) {
|
||||
return '"' + val + '"';
|
||||
}
|
||||
if (Object.prototype.toString.call(val) === '[object Number]') {
|
||||
return val;
|
||||
}
|
||||
if (Util._isBoolean(val)) {
|
||||
return val;
|
||||
}
|
||||
return Object.prototype.toString.call(val);
|
||||
}
|
||||
|
||||
export function RGBComponent(val) {
|
||||
if (val > 255) {
|
||||
return 255;
|
||||
} else if (val < 0) {
|
||||
return 0;
|
||||
}
|
||||
return Math.round(val);
|
||||
}
|
||||
export function alphaComponent(val) {
|
||||
if (val > 1) {
|
||||
return 1;
|
||||
} else if (val < 0.0001) {
|
||||
// chrome does not honor alpha values of 0
|
||||
return 0.0001;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
export function getNumberValidator() {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
if (!Util._isNumber(val)) {
|
||||
Util.warn(
|
||||
_formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be a number.'
|
||||
);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
}
|
||||
export function getNumberOrAutoValidator() {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
var isNumber = Util._isNumber(val);
|
||||
var isAuto = val === 'auto';
|
||||
|
||||
if (!(isNumber || isAuto)) {
|
||||
Util.warn(
|
||||
_formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be a number or "auto".'
|
||||
);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
}
|
||||
export function getStringValidator() {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
if (!Util._isString(val)) {
|
||||
Util.warn(
|
||||
_formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be a string.'
|
||||
);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
}
|
||||
export function getFunctionValidator() {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
if (!Util._isFunction(val)) {
|
||||
Util.warn(
|
||||
_formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be a function.'
|
||||
);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
}
|
||||
export function getNumberArrayValidator() {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
if (!Util._isArray(val)) {
|
||||
Util.warn(
|
||||
_formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be a array of numbers.'
|
||||
);
|
||||
} else {
|
||||
val.forEach(function(item) {
|
||||
if (!Util._isNumber(item)) {
|
||||
Util.warn(
|
||||
'"' +
|
||||
attr +
|
||||
'" attribute has non numeric element ' +
|
||||
item +
|
||||
'. Make sure that all elements are numbers.'
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
}
|
||||
export function getBooleanValidator() {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
var isBool = val === true || val === false;
|
||||
if (!isBool) {
|
||||
Util.warn(
|
||||
_formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be a boolean.'
|
||||
);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
}
|
||||
export function getComponentValidator(components) {
|
||||
if (isUnminified) {
|
||||
return function(val, attr) {
|
||||
if (!Util.isObject(val)) {
|
||||
Util.warn(
|
||||
_formatValue(val) +
|
||||
' is a not valid value for "' +
|
||||
attr +
|
||||
'" attribute. The value should be an object with properties ' +
|
||||
components
|
||||
);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
/*
|
||||
the Gauss filter
|
||||
master repo: https://github.com/pavelpower/kineticjsGaussFilter
|
||||
@ -838,7 +839,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'blurRadius',
|
||||
0,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node, Filter } from '../Node';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
/**
|
||||
* Brighten Filter.
|
||||
@ -31,7 +32,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'brightness',
|
||||
0,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
/**
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
/**
|
||||
* Contrast Filter.
|
||||
* @function
|
||||
@ -69,6 +70,6 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'contrast',
|
||||
0,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { Util } from '../Util';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
/**
|
||||
* Emboss Filter.
|
||||
* Pixastic Lib - Emboss filter - v0.1.0
|
||||
@ -143,7 +144,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'embossStrength',
|
||||
0.5,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
/**
|
||||
@ -158,7 +159,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'embossWhiteLevel',
|
||||
0.5,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
/**
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
function remap(fromValue, fromMin, fromMax, toMin, toMax) {
|
||||
// Compute the range of the data
|
||||
var fromRange = fromMax - fromMin,
|
||||
@ -145,6 +147,6 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'enhance',
|
||||
0,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
|
@ -1,10 +1,12 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Node,
|
||||
'hue',
|
||||
0,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
/**
|
||||
@ -19,7 +21,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'saturation',
|
||||
0,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
/**
|
||||
@ -34,7 +36,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'luminance',
|
||||
0,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
/**
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
/**
|
||||
* HSV Filter. Adjusts the hue, saturation and value
|
||||
* @function
|
||||
@ -64,7 +66,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'hue',
|
||||
0,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
/**
|
||||
@ -79,7 +81,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'saturation',
|
||||
0,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
/**
|
||||
@ -94,7 +96,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'value',
|
||||
0,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
/**
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { Util } from '../Util';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
/*
|
||||
* ToPolar Filter. Converts image data to polar coordinates. Performs
|
||||
* w*h*4 pixel reads and w*h pixel writes. The r axis is placed along
|
||||
@ -274,7 +276,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'kaleidoscopePower',
|
||||
2,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
|
||||
@ -289,6 +291,6 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'kaleidoscopeAngle',
|
||||
0,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
function pixelAt(idata, x, y) {
|
||||
var idx = (y * idata.width + x) * 4;
|
||||
@ -203,6 +204,6 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'threshold',
|
||||
0,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
/**
|
||||
* Noise Filter. Randomly adds or substracts to the color channels
|
||||
* @function
|
||||
@ -30,7 +32,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'noise',
|
||||
0.2,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
/**
|
||||
|
@ -1,7 +1,9 @@
|
||||
/*eslint-disable max-depth */
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Util } from '../Util';
|
||||
import { Node } from '../Node';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
/**
|
||||
* Pixelate Filter. Averages groups of pixels and redraws
|
||||
* them as larger pixels
|
||||
@ -107,7 +109,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'pixelSize',
|
||||
8,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
/**
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
/**
|
||||
* Posterize Filter. Adjusts the channels so that there are no more
|
||||
* than n different values for that channel. This is also applied
|
||||
@ -32,7 +33,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'levels',
|
||||
0.5,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { RGBComponent } from '../Validators';
|
||||
|
||||
/**
|
||||
* RGB Filter
|
||||
* @function
|
||||
@ -71,13 +73,7 @@ Factory.addGetterSetter(Node, 'green', 0, function(val) {
|
||||
* @returns {Integer}
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Node,
|
||||
'blue',
|
||||
0,
|
||||
Validators.RGBComponent,
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
Factory.addGetterSetter(Node, 'blue', 0, RGBComponent, Factory.afterSetFilter);
|
||||
/**
|
||||
* get/set filter blue value. Use with {@link Konva.Filters.RGB} filter.
|
||||
* @name blue
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { RGBComponent } from '../Validators';
|
||||
|
||||
/**
|
||||
* RGBA Filter
|
||||
* @function
|
||||
@ -72,13 +74,7 @@ Factory.addGetterSetter(Node, 'green', 0, function(val) {
|
||||
* @returns {Integer}
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Node,
|
||||
'blue',
|
||||
0,
|
||||
Validators.RGBComponent,
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
Factory.addGetterSetter(Node, 'blue', 0, RGBComponent, Factory.afterSetFilter);
|
||||
/**
|
||||
* get/set filter blue value. Use with {@link Konva.Filters.RGBA} filter.
|
||||
* @name blue
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
/**
|
||||
* Threshold Filter. Pushes any value above the mid point to
|
||||
* the max and any value below the mid point to the min.
|
||||
@ -30,7 +31,7 @@ Factory.addGetterSetter(
|
||||
Node,
|
||||
'threshold',
|
||||
0.5,
|
||||
Validators.getNumberValidator(),
|
||||
getNumberValidator(),
|
||||
Factory.afterSetFilter
|
||||
);
|
||||
/**
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { Collection } from '../Util';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { getAngle } from '../Global';
|
||||
import { GetSet } from '../types';
|
||||
import { getNumberValidator, getBooleanValidator } from '../Validators';
|
||||
|
||||
/**
|
||||
* Arc constructor
|
||||
@ -64,7 +64,7 @@ Arc.prototype.className = 'Arc';
|
||||
Arc.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
|
||||
|
||||
// add getters setters
|
||||
Factory.addGetterSetter(Arc, 'innerRadius', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Arc, 'innerRadius', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set innerRadius
|
||||
@ -80,7 +80,7 @@ Factory.addGetterSetter(Arc, 'innerRadius', 0, Validators.getNumberValidator());
|
||||
* arc.innerRadius(20);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Arc, 'outerRadius', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Arc, 'outerRadius', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set outerRadius
|
||||
@ -96,7 +96,7 @@ Factory.addGetterSetter(Arc, 'outerRadius', 0, Validators.getNumberValidator());
|
||||
* arc.outerRadius(20);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Arc, 'angle', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Arc, 'angle', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set angle in degrees
|
||||
@ -112,7 +112,7 @@ Factory.addGetterSetter(Arc, 'angle', 0, Validators.getNumberValidator());
|
||||
* arc.angle(20);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Arc, 'clockwise', false);
|
||||
Factory.addGetterSetter(Arc, 'clockwise', false, getBooleanValidator());
|
||||
|
||||
/**
|
||||
* get/set clockwise flag
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Collection } from '../Util';
|
||||
import { Factory } from '../Factory';
|
||||
import { Line } from './Line';
|
||||
import { GetSet } from '../types';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
/**
|
||||
* Arrow constructor
|
||||
@ -122,12 +123,7 @@ Arrow.prototype.className = 'Arrow';
|
||||
* line.pointerLength(15);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Arrow,
|
||||
'pointerLength',
|
||||
10,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Arrow, 'pointerLength', 10, getNumberValidator());
|
||||
/**
|
||||
* get/set pointerWidth
|
||||
* @name Konva.Arrow#pointerWidth
|
||||
@ -143,12 +139,7 @@ Factory.addGetterSetter(
|
||||
* line.pointerWidth(15);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Arrow,
|
||||
'pointerWidth',
|
||||
10,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Arrow, 'pointerWidth', 10, getNumberValidator());
|
||||
/**
|
||||
* get/set pointerAtBeginning
|
||||
* @name Konva.Arrow#pointerAtBeginning
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { Collection } from '../Util';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { GetSet } from '../types';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
/**
|
||||
* Circle constructor
|
||||
@ -66,6 +66,6 @@ Circle.prototype._attrsAffectingSize = ['radius'];
|
||||
* // set radius
|
||||
* circle.radius(10);
|
||||
*/
|
||||
Factory.addGetterSetter(Circle, 'radius', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Circle, 'radius', 0, getNumberValidator());
|
||||
|
||||
Collection.mapMethods(Circle);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { Collection } from '../Util';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
import { GetSet, Vector2d } from '../types';
|
||||
|
||||
@ -81,7 +81,7 @@ Factory.addComponentsGetterSetter(Ellipse, 'radius', ['x', 'y']);
|
||||
* });
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Ellipse, 'radiusX', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Ellipse, 'radiusX', 0, getNumberValidator());
|
||||
/**
|
||||
* get/set radius x
|
||||
* @name Konva.Ellipse#radiusX
|
||||
@ -96,7 +96,7 @@ Factory.addGetterSetter(Ellipse, 'radiusX', 0, Validators.getNumberValidator());
|
||||
* ellipse.radiusX(200);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Ellipse, 'radiusY', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Ellipse, 'radiusY', 0, getNumberValidator());
|
||||
/**
|
||||
* get/set radius y
|
||||
* @name Konva.Ellipse#radiusY
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
import { GetSet, IRect } from '../types';
|
||||
|
||||
@ -170,7 +170,7 @@ Factory.addComponentsGetterSetter(Image, 'crop', ['x', 'y', 'width', 'height']);
|
||||
* });
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Image, 'cropX', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Image, 'cropX', 0, getNumberValidator());
|
||||
/**
|
||||
* get/set crop x
|
||||
* @method
|
||||
@ -185,7 +185,7 @@ Factory.addGetterSetter(Image, 'cropX', 0, Validators.getNumberValidator());
|
||||
* image.cropX(20);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Image, 'cropY', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Image, 'cropY', 0, getNumberValidator());
|
||||
/**
|
||||
* get/set crop y
|
||||
* @name Konva.Image#cropY
|
||||
@ -200,7 +200,7 @@ Factory.addGetterSetter(Image, 'cropY', 0, Validators.getNumberValidator());
|
||||
* image.cropY(20);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Image, 'cropWidth', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Image, 'cropWidth', 0, getNumberValidator());
|
||||
/**
|
||||
* get/set crop width
|
||||
* @name Konva.Image#cropWidth
|
||||
@ -215,12 +215,7 @@ Factory.addGetterSetter(Image, 'cropWidth', 0, Validators.getNumberValidator());
|
||||
* image.cropWidth(20);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Image,
|
||||
'cropHeight',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Image, 'cropHeight', 0, getNumberValidator());
|
||||
/**
|
||||
* get/set crop height
|
||||
* @name Konva.Image#cropHeight
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Collection } from '../Util';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { Group } from '../Group';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
import { GetSet } from '../types';
|
||||
|
||||
@ -333,12 +334,7 @@ Factory.addGetterSetter(Tag, 'pointerDirection', NONE);
|
||||
* @example
|
||||
* tag.pointerWidth(20);
|
||||
*/
|
||||
Factory.addGetterSetter(
|
||||
Tag,
|
||||
'pointerWidth',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Tag, 'pointerWidth', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set pointer height
|
||||
@ -350,12 +346,7 @@ Factory.addGetterSetter(
|
||||
* tag.pointerHeight(20);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Tag,
|
||||
'pointerHeight',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Tag, 'pointerHeight', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set cornerRadius
|
||||
@ -367,11 +358,6 @@ Factory.addGetterSetter(
|
||||
* tag.cornerRadius(20);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Tag,
|
||||
'cornerRadius',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Tag, 'cornerRadius', 0, getNumberValidator());
|
||||
|
||||
Collection.mapMethods(Tag);
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { getNumberValidator, getNumberArrayValidator } from '../Validators';
|
||||
|
||||
import { GetSet } from '../types';
|
||||
|
||||
@ -245,7 +246,7 @@ Factory.addGetterSetter(Line, 'bezier', false);
|
||||
* line.bezier(true);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Line, 'tension', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Line, 'tension', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set tension
|
||||
@ -261,12 +262,7 @@ Factory.addGetterSetter(Line, 'tension', 0, Validators.getNumberValidator());
|
||||
* line.tension(3);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Line,
|
||||
'points',
|
||||
[],
|
||||
Validators.getNumberArrayValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Line, 'points', [], getNumberArrayValidator());
|
||||
/**
|
||||
* get/set points array. Points is a flat array [x1, y1, x2, y2]. It is flat for performance reasons.
|
||||
* @name Konva.Line#points
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Collection } from '../Util';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
import { GetSet } from '../types';
|
||||
|
||||
@ -96,11 +97,6 @@ Rect.prototype.className = 'Rect';
|
||||
* // set corner radius
|
||||
* rect.cornerRadius(10);
|
||||
*/
|
||||
Factory.addGetterSetter(
|
||||
Rect,
|
||||
'cornerRadius',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Rect, 'cornerRadius', 0, getNumberValidator());
|
||||
|
||||
Collection.mapMethods(Rect);
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { GetSet } from '../types';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
/**
|
||||
* RegularPolygon constructor. Examples include triangles, squares, pentagons, hexagons, etc.
|
||||
@ -77,12 +78,7 @@ RegularPolygon.prototype._attrsAffectingSize = ['radius'];
|
||||
* // set radius
|
||||
* shape.radius(10);
|
||||
*/
|
||||
Factory.addGetterSetter(
|
||||
RegularPolygon,
|
||||
'radius',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(RegularPolygon, 'radius', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set sides
|
||||
@ -97,11 +93,6 @@ Factory.addGetterSetter(
|
||||
* // set sides
|
||||
* shape.sides(10);
|
||||
*/
|
||||
Factory.addGetterSetter(
|
||||
RegularPolygon,
|
||||
'sides',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(RegularPolygon, 'sides', 0, getNumberValidator());
|
||||
|
||||
Collection.mapMethods(RegularPolygon);
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { GetSet } from '../types';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
var PIx2 = Math.PI * 2;
|
||||
/**
|
||||
@ -68,12 +69,7 @@ Ring.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
|
||||
* ring.innerRadius(20);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Ring,
|
||||
'innerRadius',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Ring, 'innerRadius', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set outerRadius
|
||||
@ -88,11 +84,6 @@ Factory.addGetterSetter(
|
||||
* // set outer radius
|
||||
* ring.outerRadius(20);
|
||||
*/
|
||||
Factory.addGetterSetter(
|
||||
Ring,
|
||||
'outerRadius',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Ring, 'outerRadius', 0, getNumberValidator());
|
||||
|
||||
Collection.mapMethods(Ring);
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Collection } from '../Util';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { Animation } from '../Animation';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
import { GetSet } from '../types';
|
||||
|
||||
@ -316,12 +317,7 @@ Factory.addGetterSetter(Sprite, 'image');
|
||||
* sprite.image(imageObj);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Sprite,
|
||||
'frameIndex',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Sprite, 'frameIndex', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* set/set animation frame index
|
||||
@ -337,12 +333,7 @@ Factory.addGetterSetter(
|
||||
* sprite.frameIndex(3);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Sprite,
|
||||
'frameRate',
|
||||
17,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Sprite, 'frameRate', 17, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set frame rate in frames per second. Increase this number to make the sprite
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { Collection } from '../Util';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
import { GetSet } from '../types';
|
||||
|
||||
@ -82,7 +82,7 @@ Star.prototype._attrsAffectingSize = ['innerRadius', 'outerRadius'];
|
||||
* // set inner radius
|
||||
* ring.numPoints(20);
|
||||
*/
|
||||
Factory.addGetterSetter(Star, 'numPoints', 5, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Star, 'numPoints', 5, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set innerRadius
|
||||
@ -97,12 +97,7 @@ Factory.addGetterSetter(Star, 'numPoints', 5, Validators.getNumberValidator());
|
||||
* // set inner radius
|
||||
* ring.innerRadius(20);
|
||||
*/
|
||||
Factory.addGetterSetter(
|
||||
Star,
|
||||
'innerRadius',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Star, 'innerRadius', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set outerRadius
|
||||
@ -118,11 +113,6 @@ Factory.addGetterSetter(
|
||||
* ring.outerRadius(20);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Star,
|
||||
'outerRadius',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Star, 'outerRadius', 0, getNumberValidator());
|
||||
|
||||
Collection.mapMethods(Star);
|
||||
|
@ -1,7 +1,12 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { UA } from '../Global';
|
||||
import {
|
||||
getNumberValidator,
|
||||
getStringValidator,
|
||||
getNumberOrAutoValidator
|
||||
} from '../Validators';
|
||||
|
||||
import { GetSet } from '../types';
|
||||
|
||||
@ -543,7 +548,7 @@ Text.prototype._attrsAffectingSize = [
|
||||
* text.width('auto');
|
||||
* text.width() // will return calculated width, and not "auto"
|
||||
*/
|
||||
Factory.overWriteSetter(Text, 'width', Validators.getNumberOrAutoValidator());
|
||||
Factory.overWriteSetter(Text, 'width', getNumberOrAutoValidator());
|
||||
|
||||
/**
|
||||
* get/set the height of the text area, which takes into account multi-line text, line heights, and padding.
|
||||
@ -563,7 +568,7 @@ Factory.overWriteSetter(Text, 'width', Validators.getNumberOrAutoValidator());
|
||||
* text.height() // will return calculated height, and not "auto"
|
||||
*/
|
||||
|
||||
Factory.overWriteSetter(Text, 'height', Validators.getNumberOrAutoValidator());
|
||||
Factory.overWriteSetter(Text, 'height', getNumberOrAutoValidator());
|
||||
|
||||
/**
|
||||
* get/set font family
|
||||
@ -593,7 +598,7 @@ Factory.addGetterSetter(Text, 'fontFamily', 'Arial');
|
||||
* // set font size to 22px
|
||||
* text.fontSize(22);
|
||||
*/
|
||||
Factory.addGetterSetter(Text, 'fontSize', 12, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Text, 'fontSize', 12, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set font style. Can be 'normal', 'italic', or 'bold'. 'normal' is the default.
|
||||
@ -641,7 +646,7 @@ Factory.addGetterSetter(Text, 'fontVariant', NORMAL);
|
||||
* text.padding(10);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Text, 'padding', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Text, 'padding', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set horizontal align of text. Can be 'left', 'center', 'right' or 'justify'
|
||||
@ -692,7 +697,7 @@ Factory.addGetterSetter(Text, 'verticalAlign', TOP);
|
||||
* text.lineHeight(2);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Text, 'lineHeight', 1, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Text, 'lineHeight', 1, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set wrap. Can be "word", "char", or "none". Default is "word".
|
||||
@ -736,12 +741,7 @@ Factory.addGetterSetter(Text, 'ellipsis', false);
|
||||
* @param {Number} letterSpacing
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
Text,
|
||||
'letterSpacing',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Text, 'letterSpacing', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set text
|
||||
@ -757,7 +757,7 @@ Factory.addGetterSetter(
|
||||
* text.text('Hello world!');
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(Text, 'text', '', Validators.getStringValidator());
|
||||
Factory.addGetterSetter(Text, 'text', '', getStringValidator());
|
||||
|
||||
/**
|
||||
* get/set text decoration of a text. Possible values are 'underline', 'line-through' or combination of these values separated by space
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { Path } from './Path';
|
||||
import { Text } from './Text';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
import { GetSet, Vector2d } from '../types';
|
||||
|
||||
@ -585,12 +586,7 @@ Factory.addGetterSetter(TextPath, 'fontFamily', 'Arial');
|
||||
* shape.fontSize(22);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
TextPath,
|
||||
'fontSize',
|
||||
12,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(TextPath, 'fontSize', 12, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set font style. Can be 'normal', 'italic', or 'bold'. 'normal' is the default.
|
||||
@ -640,12 +636,7 @@ Factory.addGetterSetter(TextPath, 'align', 'left');
|
||||
* shape.letterSpacing(2);
|
||||
*/
|
||||
|
||||
Factory.addGetterSetter(
|
||||
TextPath,
|
||||
'letterSpacing',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(TextPath, 'letterSpacing', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set text baselineg. The default is 'middle'. Can be 'top', 'bottom', 'middle', 'alphabetic', 'hanging'
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Factory } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { Shape } from '../Shape';
|
||||
import { Rect } from './Rect';
|
||||
import { Group } from '../Group';
|
||||
import { getAngle, getGlobalKonva } from '../Global';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
import { GetSet, IRect } from '../types';
|
||||
|
||||
@ -894,12 +895,7 @@ Factory.addGetterSetter(Transformer, 'resizeEnabled', true);
|
||||
* // set
|
||||
* transformer.anchorSize(20)
|
||||
*/
|
||||
Factory.addGetterSetter(
|
||||
Transformer,
|
||||
'anchorSize',
|
||||
10,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Transformer, 'anchorSize', 10, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set ability to rotate.
|
||||
@ -948,7 +944,7 @@ Factory.addGetterSetter(
|
||||
Transformer,
|
||||
'rotateAnchorOffset',
|
||||
50,
|
||||
Validators.getNumberValidator()
|
||||
getNumberValidator()
|
||||
);
|
||||
|
||||
/**
|
||||
@ -998,7 +994,7 @@ Factory.addGetterSetter(
|
||||
Transformer,
|
||||
'anchorStrokeWidth',
|
||||
1,
|
||||
Validators.getNumberValidator()
|
||||
getNumberValidator()
|
||||
);
|
||||
|
||||
/**
|
||||
@ -1033,7 +1029,7 @@ Factory.addGetterSetter(
|
||||
Transformer,
|
||||
'anchorCornerRadius',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
getNumberValidator()
|
||||
);
|
||||
|
||||
/**
|
||||
@ -1068,7 +1064,7 @@ Factory.addGetterSetter(
|
||||
Transformer,
|
||||
'borderStrokeWidth',
|
||||
1,
|
||||
Validators.getNumberValidator()
|
||||
getNumberValidator()
|
||||
);
|
||||
|
||||
/**
|
||||
@ -1145,12 +1141,7 @@ Factory.addGetterSetter(Transformer, 'ignoreStroke', false);
|
||||
* // set
|
||||
* transformer.padding(10);
|
||||
*/
|
||||
Factory.addGetterSetter(
|
||||
Transformer,
|
||||
'padding',
|
||||
0,
|
||||
Validators.getNumberValidator()
|
||||
);
|
||||
Factory.addGetterSetter(Transformer, 'padding', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set attached node of the Transformer. Transformer will adapt to its size and listen to its events
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Util, Collection } from '../Util';
|
||||
import { Factory, Validators } from '../Factory';
|
||||
import { Node } from '../Node';
|
||||
import { Collection } from '../Util';
|
||||
import { Factory } from '../Factory';
|
||||
import { Shape } from '../Shape';
|
||||
import { getAngle } from '../Global';
|
||||
import { getNumberValidator } from '../Validators';
|
||||
|
||||
import { GetSet } from '../types';
|
||||
|
||||
@ -78,7 +78,7 @@ Wedge.prototype._attrsAffectingSize = ['radius'];
|
||||
* // set radius
|
||||
* wedge.radius(10);
|
||||
*/
|
||||
Factory.addGetterSetter(Wedge, 'radius', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Wedge, 'radius', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set angle in degrees
|
||||
@ -93,7 +93,7 @@ Factory.addGetterSetter(Wedge, 'radius', 0, Validators.getNumberValidator());
|
||||
* // set angle
|
||||
* wedge.angle(20);
|
||||
*/
|
||||
Factory.addGetterSetter(Wedge, 'angle', 0, Validators.getNumberValidator());
|
||||
Factory.addGetterSetter(Wedge, 'angle', 0, getNumberValidator());
|
||||
|
||||
/**
|
||||
* get/set clockwise flag
|
||||
|
Loading…
Reference in New Issue
Block a user