Skip to content

Commit

Permalink
improved functional test layout, and started work on drawBufferFunc s…
Browse files Browse the repository at this point in the history
…upport
  • Loading branch information
ericdrowell committed Nov 15, 2012
1 parent bb78dac commit 9f80402
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 82 deletions.
27 changes: 21 additions & 6 deletions src/Shape.js
Expand Up @@ -69,12 +69,14 @@ Kinetic.Shape = (function() {
// set colorKey // set colorKey
var shapes = Kinetic.Global.shapes; var shapes = Kinetic.Global.shapes;
var key; var key;

while(true) { while(true) {
key = Kinetic.Type._getRandomColorKey(); key = Kinetic.Type._getRandomColorKey();
if(key && !( key in shapes)) { if(key && !( key in shapes)) {
break; break;
} }
} }

this.colorKey = key; this.colorKey = key;
shapes[key] = this; shapes[key] = this;


Expand Down Expand Up @@ -141,7 +143,7 @@ Kinetic.Shape = (function() {
} }
}, },
_getFillType: function(fill) { _getFillType: function(fill) {
var type = Kinetic.Type; var type = Kinetic.Type;
if(!fill) { if(!fill) {
return undefined; return undefined;
} }
Expand Down Expand Up @@ -288,7 +290,7 @@ Kinetic.Shape = (function() {
* @methodOf Kinetic.Shape.prototype * @methodOf Kinetic.Shape.prototype
*/ */
applyLineJoin: function(context) { applyLineJoin: function(context) {
var lineJoin = this.attrs.lineJoin; var lineJoin = this.attrs.lineJoin;
if(lineJoin) { if(lineJoin) {
context.lineJoin = lineJoin; context.lineJoin = lineJoin;
} }
Expand All @@ -300,7 +302,7 @@ Kinetic.Shape = (function() {
* @methodOf Kinetic.Shape.prototype * @methodOf Kinetic.Shape.prototype
*/ */
applyLineCap: function(context) { applyLineCap: function(context) {
var lineCap = this.attrs.lineCap; var lineCap = this.attrs.lineCap;
if(lineCap) { if(lineCap) {
context.lineCap = lineCap; context.lineCap = lineCap;
} }
Expand All @@ -316,7 +318,7 @@ Kinetic.Shape = (function() {
* @param {Number} config.opacity * @param {Number} config.opacity
*/ */
setShadow: function(config) { setShadow: function(config) {
var type = Kinetic.Type; var type = Kinetic.Type;
if(config.offset !== undefined) { if(config.offset !== undefined) {
config.offset = type._getXY(config.offset); config.offset = type._getXY(config.offset);
} }
Expand All @@ -330,7 +332,7 @@ Kinetic.Shape = (function() {
* @param {String|Object} fill * @param {String|Object} fill
*/ */
setFill: function(fill) { setFill: function(fill) {
var type = Kinetic.Type; var type = Kinetic.Type;
var oldFill = this.getFill(); var oldFill = this.getFill();
var fillType = this._getFillType(fill); var fillType = this._getFillType(fill);
var oldFillType = this._getFillType(oldFill); var oldFillType = this._getFillType(oldFill);
Expand Down Expand Up @@ -463,7 +465,7 @@ Kinetic.Shape = (function() {
Kinetic.Global.extend(Shape, Kinetic.Node); Kinetic.Global.extend(Shape, Kinetic.Node);


// add getters and setters // add getters and setters
Kinetic.Node.addGettersSetters(Shape, ['stroke', 'lineJoin', 'strokeWidth', 'drawFunc', 'cornerRadius']); Kinetic.Node.addGettersSetters(Shape, ['stroke', 'lineJoin', 'strokeWidth', 'drawFunc', 'drawBufferFunc', 'cornerRadius']);
Kinetic.Node.addGetters(Shape, ['shadow', 'fill']); Kinetic.Node.addGetters(Shape, ['shadow', 'fill']);


/** /**
Expand Down Expand Up @@ -495,6 +497,13 @@ Kinetic.Shape = (function() {
* @param {Function} drawFunc drawing function * @param {Function} drawFunc drawing function
*/ */


/**
* set draw buffer function used for hit detection
* @name setDrawBufferFunc
* @methodOf Kinetic.Shape.prototype
* @param {Function} drawBufferFunc drawing function used for hit detection
*/

/** /**
* set corner radius * set corner radius
* @name setCornerRadius * @name setCornerRadius
Expand Down Expand Up @@ -539,6 +548,12 @@ Kinetic.Shape = (function() {
* @methodOf Kinetic.Shape.prototype * @methodOf Kinetic.Shape.prototype
*/ */


/**
* get draw buffer function
* @name getDrawBufferFunc
* @methodOf Kinetic.Shape.prototype
*/

/** /**
* get shadow object * get shadow object
* @name getShadow * @name getShadow
Expand Down
6 changes: 5 additions & 1 deletion src/shapes/Image.js
Expand Up @@ -19,7 +19,11 @@ Kinetic.Image.prototype = {
_initImage: function(config) { _initImage: function(config) {
this.shapeType = "Image"; this.shapeType = "Image";
config.drawFunc = this.drawFunc; config.drawFunc = this.drawFunc;
config.drawBufferFunc = this.drawBufferFunc;
if(!config.drawBufferFunc) {
config.drawBufferFunc = this.drawBufferFunc;
}

// call super constructor // call super constructor
Kinetic.Shape.call(this, config); Kinetic.Shape.call(this, config);


Expand Down
6 changes: 5 additions & 1 deletion src/shapes/Sprite.js
Expand Up @@ -19,7 +19,11 @@ Kinetic.Sprite.prototype = {
}); });
this.shapeType = "Sprite"; this.shapeType = "Sprite";
config.drawFunc = this.drawFunc; config.drawFunc = this.drawFunc;
config.drawBufferFunc = this.drawBufferFunc;
if(!config.drawBufferFunc) {
config.drawBufferFunc = this.drawBufferFunc;
}

// call super constructor // call super constructor
Kinetic.Shape.call(this, config); Kinetic.Shape.call(this, config);
this.anim = new Kinetic.Animation(); this.anim = new Kinetic.Animation();
Expand Down
9 changes: 1 addition & 8 deletions tests/html/functionalTests.html
Expand Up @@ -3,14 +3,7 @@
<head> <head>
<style> <style>
/* overwrite CSS */ /* overwrite CSS */
.green {
position: absolute;
top: 0px;
}
.row {
position: absolute;
top: 18px;
}
</style> </style>
<link rel="stylesheet" type="text/css"href="../base.css"> <link rel="stylesheet" type="text/css"href="../base.css">
<script src="../../dist/kinetic-current.js"></script> <script src="../../dist/kinetic-current.js"></script>
Expand Down

0 comments on commit 9f80402

Please sign in to comment.