changed drawFunc to sceneFunc and drawHitFunc to hitFunc

This commit is contained in:
Eric Rowell 2014-01-04 23:34:01 -08:00
parent ff952bf958
commit 7e2c6c97f8
20 changed files with 51 additions and 51 deletions

View File

@ -8,8 +8,7 @@ module.exports = function(grunt) {
'src/Factory.js', 'src/Factory.js',
'src/Node.js', 'src/Node.js',
// filters // filters
'src/filters/FilterWrapper.js',
'src/filters/Grayscale.js', 'src/filters/Grayscale.js',
'src/filters/Brighten.js', 'src/filters/Brighten.js',
'src/filters/Invert.js', 'src/filters/Invert.js',
@ -22,12 +21,13 @@ module.exports = function(grunt) {
'src/filters/Posterize.js', 'src/filters/Posterize.js',
'src/filters/Noise.js', 'src/filters/Noise.js',
'src/filters/Pixelate.js', 'src/filters/Pixelate.js',
'src/filters/Polar.js',
'src/filters/Threshold.js', 'src/filters/Threshold.js',
'src/filters/Sepia.js', 'src/filters/Sepia.js',
'src/filters/Solarize.js', 'src/filters/Solarize.js',
'src/filters/Ripple.js', 'src/filters/Ripple.js',
//'src/filters/FilterWrapper.js',
//'src/filters/Polar.js',
// core // core
'src/Animation.js', 'src/Animation.js',
'src/Tween.js', 'src/Tween.js',

View File

@ -236,7 +236,7 @@
var canvas = can || this.getLayer().getCanvas(), var canvas = can || this.getLayer().getCanvas(),
context = canvas.getContext(), context = canvas.getContext(),
cachedCanvas = this._cache.canvas, cachedCanvas = this._cache.canvas,
drawFunc = this.getDrawFunc(), drawFunc = this.sceneFunc(),
hasShadow = this.hasShadow(), hasShadow = this.hasShadow(),
stage, bufferCanvas, bufferContext; stage, bufferCanvas, bufferContext;
@ -293,7 +293,7 @@
drawHit: function(can) { drawHit: function(can) {
var canvas = can || this.getLayer().hitCanvas, var canvas = can || this.getLayer().hitCanvas,
context = canvas.getContext(), context = canvas.getContext(),
drawFunc = this.getDrawHitFunc() || this.getDrawFunc(), drawFunc = this.hitFunc() || this.sceneFunc(),
cachedCanvas = this._cache.canvas, cachedCanvas = this._cache.canvas,
cachedHitCanvas = cachedCanvas && cachedCanvas.hit; cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
@ -475,7 +475,7 @@
* @returns {Number} * @returns {Number}
*/ */
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'drawFunc'); Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'sceneFunc');
/** /**
* set draw function * set draw function
@ -494,7 +494,7 @@
* @returns {Function} * @returns {Function}
*/ */
Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'drawHitFunc'); Kinetic.Factory.addGetterSetter(Kinetic.Shape, 'hitFunc');
/** /**
* set draw hit function used for hit detection * set draw hit function used for hit detection

View File

@ -174,9 +174,9 @@
___init: function(config) { ___init: function(config) {
Kinetic.Shape.call(this, config); Kinetic.Shape.call(this, config);
this.className = 'Tag'; this.className = 'Tag';
this.setDrawFunc(this._drawFunc); this.sceneFunc(this._sceneFunc);
}, },
_drawFunc: function(context) { _sceneFunc: function(context) {
var width = this.getWidth(), var width = this.getWidth(),
height = this.getHeight(), height = this.getHeight(),
pointerDirection = this.getPointerDirection(), pointerDirection = this.getPointerDirection(),

View File

@ -36,9 +36,9 @@
that.dataArray = Kinetic.Path.parsePathData(this.getData()); 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, var ca = this.dataArray,
closedPath = false; closedPath = false;

View File

@ -29,9 +29,9 @@
// call super constructor // call super constructor
Kinetic.Shape.call(this, config); Kinetic.Shape.call(this, config);
this.className = 'RegularPolygon'; this.className = 'RegularPolygon';
this.setDrawFunc(this._drawFunc); this.sceneFunc(this._sceneFunc);
}, },
_drawFunc: function(context) { _sceneFunc: function(context) {
var sides = this.attrs.sides, var sides = this.attrs.sides,
radius = this.attrs.radius, radius = this.attrs.radius,
n, x, y; n, x, y;

View File

@ -31,9 +31,9 @@
// call super constructor // call super constructor
Kinetic.Shape.call(this, config); Kinetic.Shape.call(this, config);
this.className = 'Star'; this.className = 'Star';
this.setDrawFunc(this._drawFunc); this.sceneFunc(this._sceneFunc);
}, },
_drawFunc: function(context) { _sceneFunc: function(context) {
var innerRadius = this.innerRadius(), var innerRadius = this.innerRadius(),
outerRadius = this.outerRadius(), outerRadius = this.outerRadius(),
numPoints = this.numPoints(); numPoints = this.numPoints();

View File

@ -65,9 +65,9 @@
// update text data for certain attr changes // update text data for certain attr changes
this.on('textChange.kinetic textStroke.kinetic textStrokeWidth.kinetic', that._setTextData); this.on('textChange.kinetic textStroke.kinetic textStrokeWidth.kinetic', that._setTextData);
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('font', this._getContextFont());
context.setAttr('textBaseline', 'middle'); context.setAttr('textBaseline', 'middle');
context.setAttr('textAlign', 'left'); context.setAttr('textAlign', 'left');

View File

@ -32,9 +32,9 @@
// call super constructor // call super constructor
Kinetic.Shape.call(this, config); Kinetic.Shape.call(this, config);
this.className = 'Arc'; this.className = 'Arc';
this.setDrawFunc(this._drawFunc); this.sceneFunc(this._sceneFunc);
}, },
_drawFunc: function(context) { _sceneFunc: function(context) {
context.beginPath(); context.beginPath();
context.arc(0, 0, this.getOuterRadius(), 0, this.getAngle(), this.getClockwise()); context.arc(0, 0, this.getOuterRadius(), 0, this.getAngle(), this.getClockwise());
context.arc(0, 0, this.getInnerRadius(), this.getAngle(), 0, !this.getClockwise()); context.arc(0, 0, this.getInnerRadius(), this.getAngle(), 0, !this.getClockwise());

View File

@ -40,9 +40,9 @@
// call super constructor // call super constructor
Kinetic.Shape.call(this, config); Kinetic.Shape.call(this, config);
this.className = CIRCLE; this.className = CIRCLE;
this.setDrawFunc(this._drawFunc); this.sceneFunc(this._sceneFunc);
}, },
_drawFunc: function(context) { _sceneFunc: function(context) {
context.beginPath(); context.beginPath();
context.arc(0, 0, this.getRadius(), 0, PIx2, false); context.arc(0, 0, this.getRadius(), 0, PIx2, false);
context.closePath(); context.closePath();

View File

@ -21,9 +21,9 @@
// call super constructor // call super constructor
Kinetic.Shape.call(this, config); Kinetic.Shape.call(this, config);
this.className = ELLIPSE; this.className = ELLIPSE;
this.setDrawFunc(this._drawFunc); this.sceneFunc(this._sceneFunc);
}, },
_drawFunc: function(context) { _sceneFunc: function(context) {
var r = this.getRadius(); var r = this.getRadius();
context.beginPath(); context.beginPath();

View File

@ -36,13 +36,13 @@
// call super constructor // call super constructor
Kinetic.Shape.call(this, config); Kinetic.Shape.call(this, config);
this.className = IMAGE; this.className = IMAGE;
this.setDrawFunc(this._drawFunc); this.sceneFunc(this._sceneFunc);
this.setDrawHitFunc(this._drawHitFunc); this.hitFunc(this._hitFunc);
}, },
_useBufferCanvas: function() { _useBufferCanvas: function() {
return (this.hasShadow() || this.getAbsoluteOpacity() !== 1) && this.hasStroke(); return (this.hasShadow() || this.getAbsoluteOpacity() !== 1) && this.hasStroke();
}, },
_drawFunc: function(context) { _sceneFunc: function(context) {
var width = this.getWidth(), var width = this.getWidth(),
height = this.getHeight(), height = this.getHeight(),
image = this.getImage(), image = this.getImage(),
@ -69,7 +69,7 @@
context.drawImage.apply(context, params); context.drawImage.apply(context, params);
} }
}, },
_drawHitFunc: function(context) { _hitFunc: function(context) {
var width = this.getWidth(), var width = this.getWidth(),
height = this.getHeight(), height = this.getHeight(),
imageHitRegion = this.imageHitRegion; imageHitRegion = this.imageHitRegion;

View File

@ -35,9 +35,9 @@
this._clearCache('tensionPoints'); this._clearCache('tensionPoints');
}); });
this.setDrawFunc(this._drawFunc); this.sceneFunc(this._sceneFunc);
}, },
_drawFunc: function(context) { _sceneFunc: function(context) {
var points = this.getPoints(), var points = this.getPoints(),
length = points.length, length = points.length,
tension = this.getTension(), tension = this.getTension(),

View File

@ -25,9 +25,9 @@
___init: function(config) { ___init: function(config) {
Kinetic.Shape.call(this, config); Kinetic.Shape.call(this, config);
this.className = 'Rect'; this.className = 'Rect';
this.setDrawFunc(this._drawFunc); this.sceneFunc(this._sceneFunc);
}, },
_drawFunc: function(context) { _sceneFunc: function(context) {
var cornerRadius = this.getCornerRadius(), var cornerRadius = this.getCornerRadius(),
width = this.getWidth(), width = this.getWidth(),
height = this.getHeight(); height = this.getHeight();

View File

@ -32,9 +32,9 @@
// call super constructor // call super constructor
Kinetic.Shape.call(this, config); Kinetic.Shape.call(this, config);
this.className = 'Ring'; this.className = 'Ring';
this.setDrawFunc(this._drawFunc); this.sceneFunc(this._sceneFunc);
}, },
_drawFunc: function(context) { _sceneFunc: function(context) {
context.beginPath(); context.beginPath();
context.arc(0, 0, this.getInnerRadius(), 0, PIx2, false); context.arc(0, 0, this.getInnerRadius(), 0, PIx2, false);
context.moveTo(this.getOuterRadius(), 0); context.moveTo(this.getOuterRadius(), 0);

View File

@ -82,10 +82,10 @@
this.setIndex(0); this.setIndex(0);
}); });
this.setDrawFunc(this._drawFunc); this.sceneFunc(this._sceneFunc);
this.setDrawHitFunc(this._drawHitFunc); this.hitFunc(this._hitFunc);
}, },
_drawFunc: function(context) { _sceneFunc: function(context) {
var anim = this.getAnimation(), var anim = this.getAnimation(),
index = this.getIndex(), index = this.getIndex(),
f = this.getAnimations()[anim][index], 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); 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(), var anim = this.getAnimation(),
index = this.getIndex(), index = this.getIndex(),
f = this.getAnimations()[anim][index]; f = this.getAnimations()[anim][index];

View File

@ -86,10 +86,10 @@
} }
this._setTextData(); this._setTextData();
this.setDrawFunc(this._drawFunc); this.sceneFunc(this._sceneFunc);
this.setDrawHitFunc(this._drawHitFunc); this.hitFunc(this._hitFunc);
}, },
_drawFunc: function(context) { _sceneFunc: function(context) {
var p = this.getPadding(), var p = this.getPadding(),
textHeight = this.getTextHeight(), textHeight = this.getTextHeight(),
lineHeightPx = this.getLineHeight() * textHeight, lineHeightPx = this.getLineHeight() * textHeight,
@ -127,7 +127,7 @@
} }
context.restore(); context.restore();
}, },
_drawHitFunc: function(context) { _hitFunc: function(context) {
var width = this.getWidth(), var width = this.getWidth(),
height = this.getHeight(); height = this.getHeight();

View File

@ -30,9 +30,9 @@
// call super constructor // call super constructor
Kinetic.Shape.call(this, config); Kinetic.Shape.call(this, config);
this.className = 'Wedge'; this.className = 'Wedge';
this.setDrawFunc(this._drawFunc); this.sceneFunc(this._sceneFunc);
}, },
_drawFunc: function(context) { _sceneFunc: function(context) {
context.beginPath(); context.beginPath();
context.arc(0, 0, this.getRadius(), 0, this.getAngle(), this.getClockwise()); context.arc(0, 0, this.getRadius(), 0, this.getAngle(), this.getClockwise());
context.lineTo(0, 0); context.lineTo(0, 0);

View File

@ -933,7 +933,7 @@ suite('MouseEvents', function() {
strokeWidth: 4, strokeWidth: 4,
fill: 'red', fill: 'red',
stroke: 'black', stroke: 'black',
drawHitFunc: function(context) { hitFunc: function(context) {
var _context = context._context; var _context = context._context;
_context.beginPath(); _context.beginPath();
@ -990,7 +990,7 @@ suite('MouseEvents', function() {
// set drawBufferFunc with setter // set drawBufferFunc with setter
circle.setDrawHitFunc(function(context) { circle.hitFunc(function(context) {
var _context = context._context; var _context = context._context;
_context.beginPath(); _context.beginPath();
_context.arc(0, 0, this.getRadius() - 50, 0, Math.PI * 2, true); _context.arc(0, 0, this.getRadius() - 50, 0, Math.PI * 2, true);

View File

@ -2221,7 +2221,7 @@ suite('Node', function() {
var stage = Kinetic.Node.create(json, container); var stage = Kinetic.Node.create(json, container);
stage.find('#myTriangle').each(function(node) { stage.find('#myTriangle').each(function(node) {
node.setDrawFunc(drawTriangle); node.sceneFunc(drawTriangle);
}); });
stage.draw(); stage.draw();

View File

@ -530,11 +530,11 @@ suite('Shape', function() {
rect.strokeWidth(8); rect.strokeWidth(8);
assert.equal(rect.strokeWidth(), 8); assert.equal(rect.strokeWidth(), 8);
rect.drawFunc('function'); rect.sceneFunc('function');
assert.equal(rect.drawFunc(), 'function'); assert.equal(rect.sceneFunc(), 'function');
rect.drawHitFunc('function'); rect.hitFunc('function');
assert.equal(rect.drawHitFunc(), 'function'); assert.equal(rect.hitFunc(), 'function');
rect.dashArray([1]); rect.dashArray([1]);
assert.equal(rect.dashArray()[0], 1); assert.equal(rect.dashArray()[0], 1);