Permalink
Browse files

improved functional test layout, and started work on drawBufferFunc s…

…upport
  • Loading branch information...
1 parent bb78dac commit 9f80402dd136000a7fc19c5b291d9bc85572eac9 @ericdrowell committed Nov 15, 2012
Showing with 117 additions and 82 deletions.
  1. +21 −6 src/Shape.js
  2. +5 −1 src/shapes/Image.js
  3. +5 −1 src/shapes/Sprite.js
  4. +1 −8 tests/html/functionalTests.html
  5. +85 −66 tests/js/functionalTests.js
View
@@ -69,12 +69,14 @@ Kinetic.Shape = (function() {
// set colorKey
var shapes = Kinetic.Global.shapes;
var key;
+
while(true) {
key = Kinetic.Type._getRandomColorKey();
if(key && !( key in shapes)) {
break;
}
}
+
this.colorKey = key;
shapes[key] = this;
@@ -141,7 +143,7 @@ Kinetic.Shape = (function() {
}
},
_getFillType: function(fill) {
- var type = Kinetic.Type;
+ var type = Kinetic.Type;
if(!fill) {
return undefined;
}
@@ -288,7 +290,7 @@ Kinetic.Shape = (function() {
* @methodOf Kinetic.Shape.prototype
*/
applyLineJoin: function(context) {
- var lineJoin = this.attrs.lineJoin;
+ var lineJoin = this.attrs.lineJoin;
if(lineJoin) {
context.lineJoin = lineJoin;
}
@@ -300,7 +302,7 @@ Kinetic.Shape = (function() {
* @methodOf Kinetic.Shape.prototype
*/
applyLineCap: function(context) {
- var lineCap = this.attrs.lineCap;
+ var lineCap = this.attrs.lineCap;
if(lineCap) {
context.lineCap = lineCap;
}
@@ -316,7 +318,7 @@ Kinetic.Shape = (function() {
* @param {Number} config.opacity
*/
setShadow: function(config) {
- var type = Kinetic.Type;
+ var type = Kinetic.Type;
if(config.offset !== undefined) {
config.offset = type._getXY(config.offset);
}
@@ -330,7 +332,7 @@ Kinetic.Shape = (function() {
* @param {String|Object} fill
*/
setFill: function(fill) {
- var type = Kinetic.Type;
+ var type = Kinetic.Type;
var oldFill = this.getFill();
var fillType = this._getFillType(fill);
var oldFillType = this._getFillType(oldFill);
@@ -463,7 +465,7 @@ Kinetic.Shape = (function() {
Kinetic.Global.extend(Shape, Kinetic.Node);
// 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']);
/**
@@ -495,6 +497,13 @@ Kinetic.Shape = (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
* @name setCornerRadius
@@ -539,6 +548,12 @@ Kinetic.Shape = (function() {
* @methodOf Kinetic.Shape.prototype
*/
+ /**
+ * get draw buffer function
+ * @name getDrawBufferFunc
+ * @methodOf Kinetic.Shape.prototype
+ */
+
/**
* get shadow object
* @name getShadow
View
@@ -19,7 +19,11 @@ Kinetic.Image.prototype = {
_initImage: function(config) {
this.shapeType = "Image";
config.drawFunc = this.drawFunc;
- config.drawBufferFunc = this.drawBufferFunc;
+
+ if(!config.drawBufferFunc) {
+ config.drawBufferFunc = this.drawBufferFunc;
+ }
+
// call super constructor
Kinetic.Shape.call(this, config);
View
@@ -19,7 +19,11 @@ Kinetic.Sprite.prototype = {
});
this.shapeType = "Sprite";
config.drawFunc = this.drawFunc;
- config.drawBufferFunc = this.drawBufferFunc;
+
+ if(!config.drawBufferFunc) {
+ config.drawBufferFunc = this.drawBufferFunc;
+ }
+
// call super constructor
Kinetic.Shape.call(this, config);
this.anim = new Kinetic.Animation();
@@ -3,14 +3,7 @@
<head>
<style>
/* overwrite CSS */
- .green {
- position: absolute;
- top: 0px;
- }
- .row {
- position: absolute;
- top: 18px;
- }
+
</style>
<link rel="stylesheet" type="text/css"href="../base.css">
<script src="../../dist/kinetic-current.js"></script>
Oops, something went wrong.

0 comments on commit 9f80402

Please sign in to comment.