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