mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
changed drawFunc to sceneFunc and drawHitFunc to hitFunc
This commit is contained in:
parent
ff952bf958
commit
7e2c6c97f8
@ -8,8 +8,7 @@ module.exports = function(grunt) {
|
||||
'src/Factory.js',
|
||||
'src/Node.js',
|
||||
|
||||
// filters
|
||||
'src/filters/FilterWrapper.js',
|
||||
// filters
|
||||
'src/filters/Grayscale.js',
|
||||
'src/filters/Brighten.js',
|
||||
'src/filters/Invert.js',
|
||||
@ -22,12 +21,13 @@ module.exports = function(grunt) {
|
||||
'src/filters/Posterize.js',
|
||||
'src/filters/Noise.js',
|
||||
'src/filters/Pixelate.js',
|
||||
'src/filters/Polar.js',
|
||||
'src/filters/Threshold.js',
|
||||
'src/filters/Sepia.js',
|
||||
'src/filters/Solarize.js',
|
||||
'src/filters/Ripple.js',
|
||||
|
||||
//'src/filters/FilterWrapper.js',
|
||||
//'src/filters/Polar.js',
|
||||
|
||||
// core
|
||||
'src/Animation.js',
|
||||
'src/Tween.js',
|
||||
|
@ -236,7 +236,7 @@
|
||||
var canvas = can || this.getLayer().getCanvas(),
|
||||
context = canvas.getContext(),
|
||||
cachedCanvas = this._cache.canvas,
|
||||
drawFunc = this.getDrawFunc(),
|
||||
drawFunc = this.sceneFunc(),
|
||||
hasShadow = this.hasShadow(),
|
||||
stage, bufferCanvas, bufferContext;
|
||||
|
||||
@ -293,7 +293,7 @@
|
||||
drawHit: function(can) {
|
||||
var canvas = can || this.getLayer().hitCanvas,
|
||||
context = canvas.getContext(),
|
||||
drawFunc = this.getDrawHitFunc() || this.getDrawFunc(),
|
||||
drawFunc = this.hitFunc() || this.sceneFunc(),
|
||||
cachedCanvas = this._cache.canvas,
|
||||
cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
|
||||
|
||||
@ -475,7 +475,7 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'drawFunc');
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'sceneFunc');
|
||||
|
||||
/**
|
||||
* set draw function
|
||||
@ -494,7 +494,7 @@
|
||||
* @returns {Function}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'drawHitFunc');
|
||||
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'hitFunc');
|
||||
|
||||
/**
|
||||
* set draw hit function used for hit detection
|
||||
|
@ -174,9 +174,9 @@
|
||||
___init: function(config) {
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Tag';
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
var width = this.getWidth(),
|
||||
height = this.getHeight(),
|
||||
pointerDirection = this.getPointerDirection(),
|
||||
|
@ -36,9 +36,9 @@
|
||||
that.dataArray = Kinetic.Path.parsePathData(this.getData());
|
||||
});
|
||||
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
},
|
||||
_drawFunc: function (context) {
|
||||
_sceneFunc: function(context) {
|
||||
var ca = this.dataArray,
|
||||
closedPath = false;
|
||||
|
||||
|
@ -29,9 +29,9 @@
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'RegularPolygon';
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
var sides = this.attrs.sides,
|
||||
radius = this.attrs.radius,
|
||||
n, x, y;
|
||||
|
@ -31,9 +31,9 @@
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Star';
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
var innerRadius = this.innerRadius(),
|
||||
outerRadius = this.outerRadius(),
|
||||
numPoints = this.numPoints();
|
||||
|
@ -65,9 +65,9 @@
|
||||
// update text data for certain attr changes
|
||||
this.on('textChange.kinetic textStroke.kinetic textStrokeWidth.kinetic', that._setTextData);
|
||||
that._setTextData();
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
context.setAttr('font', this._getContextFont());
|
||||
context.setAttr('textBaseline', 'middle');
|
||||
context.setAttr('textAlign', 'left');
|
||||
|
@ -32,9 +32,9 @@
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Arc';
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
context.beginPath();
|
||||
context.arc(0, 0, this.getOuterRadius(), 0, this.getAngle(), this.getClockwise());
|
||||
context.arc(0, 0, this.getInnerRadius(), this.getAngle(), 0, !this.getClockwise());
|
||||
|
@ -40,9 +40,9 @@
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = CIRCLE;
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
context.beginPath();
|
||||
context.arc(0, 0, this.getRadius(), 0, PIx2, false);
|
||||
context.closePath();
|
||||
|
@ -21,9 +21,9 @@
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = ELLIPSE;
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
var r = this.getRadius();
|
||||
|
||||
context.beginPath();
|
||||
|
@ -36,13 +36,13 @@
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = IMAGE;
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.setDrawHitFunc(this._drawHitFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
this.hitFunc(this._hitFunc);
|
||||
},
|
||||
_useBufferCanvas: function() {
|
||||
return (this.hasShadow() || this.getAbsoluteOpacity() !== 1) && this.hasStroke();
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
var width = this.getWidth(),
|
||||
height = this.getHeight(),
|
||||
image = this.getImage(),
|
||||
@ -69,7 +69,7 @@
|
||||
context.drawImage.apply(context, params);
|
||||
}
|
||||
},
|
||||
_drawHitFunc: function(context) {
|
||||
_hitFunc: function(context) {
|
||||
var width = this.getWidth(),
|
||||
height = this.getHeight(),
|
||||
imageHitRegion = this.imageHitRegion;
|
||||
|
@ -35,9 +35,9 @@
|
||||
this._clearCache('tensionPoints');
|
||||
});
|
||||
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
var points = this.getPoints(),
|
||||
length = points.length,
|
||||
tension = this.getTension(),
|
||||
|
@ -25,9 +25,9 @@
|
||||
___init: function(config) {
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Rect';
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
var cornerRadius = this.getCornerRadius(),
|
||||
width = this.getWidth(),
|
||||
height = this.getHeight();
|
||||
|
@ -32,9 +32,9 @@
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Ring';
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
context.beginPath();
|
||||
context.arc(0, 0, this.getInnerRadius(), 0, PIx2, false);
|
||||
context.moveTo(this.getOuterRadius(), 0);
|
||||
|
@ -82,10 +82,10 @@
|
||||
this.setIndex(0);
|
||||
});
|
||||
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.setDrawHitFunc(this._drawHitFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
this.hitFunc(this._hitFunc);
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
var anim = this.getAnimation(),
|
||||
index = this.getIndex(),
|
||||
f = this.getAnimations()[anim][index],
|
||||
@ -95,7 +95,7 @@
|
||||
context.drawImage(image, f.x, f.y, f.width, f.height, 0, 0, f.width, f.height);
|
||||
}
|
||||
},
|
||||
_drawHitFunc: function(context) {
|
||||
_hitFunc: function(context) {
|
||||
var anim = this.getAnimation(),
|
||||
index = this.getIndex(),
|
||||
f = this.getAnimations()[anim][index];
|
||||
|
@ -86,10 +86,10 @@
|
||||
}
|
||||
|
||||
this._setTextData();
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.setDrawHitFunc(this._drawHitFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
this.hitFunc(this._hitFunc);
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
var p = this.getPadding(),
|
||||
textHeight = this.getTextHeight(),
|
||||
lineHeightPx = this.getLineHeight() * textHeight,
|
||||
@ -127,7 +127,7 @@
|
||||
}
|
||||
context.restore();
|
||||
},
|
||||
_drawHitFunc: function(context) {
|
||||
_hitFunc: function(context) {
|
||||
var width = this.getWidth(),
|
||||
height = this.getHeight();
|
||||
|
||||
|
@ -30,9 +30,9 @@
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Wedge';
|
||||
this.setDrawFunc(this._drawFunc);
|
||||
this.sceneFunc(this._sceneFunc);
|
||||
},
|
||||
_drawFunc: function(context) {
|
||||
_sceneFunc: function(context) {
|
||||
context.beginPath();
|
||||
context.arc(0, 0, this.getRadius(), 0, this.getAngle(), this.getClockwise());
|
||||
context.lineTo(0, 0);
|
||||
|
@ -933,7 +933,7 @@ suite('MouseEvents', function() {
|
||||
strokeWidth: 4,
|
||||
fill: 'red',
|
||||
stroke: 'black',
|
||||
drawHitFunc: function(context) {
|
||||
hitFunc: function(context) {
|
||||
var _context = context._context;
|
||||
|
||||
_context.beginPath();
|
||||
@ -990,7 +990,7 @@ suite('MouseEvents', function() {
|
||||
|
||||
// set drawBufferFunc with setter
|
||||
|
||||
circle.setDrawHitFunc(function(context) {
|
||||
circle.hitFunc(function(context) {
|
||||
var _context = context._context;
|
||||
_context.beginPath();
|
||||
_context.arc(0, 0, this.getRadius() - 50, 0, Math.PI * 2, true);
|
||||
|
@ -2221,7 +2221,7 @@ suite('Node', function() {
|
||||
var stage = Kinetic.Node.create(json, container);
|
||||
|
||||
stage.find('#myTriangle').each(function(node) {
|
||||
node.setDrawFunc(drawTriangle);
|
||||
node.sceneFunc(drawTriangle);
|
||||
});
|
||||
|
||||
stage.draw();
|
||||
|
@ -530,11 +530,11 @@ suite('Shape', function() {
|
||||
rect.strokeWidth(8);
|
||||
assert.equal(rect.strokeWidth(), 8);
|
||||
|
||||
rect.drawFunc('function');
|
||||
assert.equal(rect.drawFunc(), 'function');
|
||||
rect.sceneFunc('function');
|
||||
assert.equal(rect.sceneFunc(), 'function');
|
||||
|
||||
rect.drawHitFunc('function');
|
||||
assert.equal(rect.drawHitFunc(), 'function');
|
||||
rect.hitFunc('function');
|
||||
assert.equal(rect.hitFunc(), 'function');
|
||||
|
||||
rect.dashArray([1]);
|
||||
assert.equal(rect.dashArray()[0], 1);
|
||||
|
Loading…
Reference in New Issue
Block a user