mirror of
https://github.com/konvajs/konva.git
synced 2026-03-03 16:58:33 +08:00
only lint errors fixes
This commit is contained in:
13
.jshintrc
13
.jshintrc
@@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"curly": true,
|
"curly": true,
|
||||||
"eqeqeq": true,
|
|
||||||
"immed": true,
|
"immed": true,
|
||||||
"latedef": true,
|
"latedef": true,
|
||||||
"newcap": true,
|
"newcap": true,
|
||||||
@@ -10,12 +9,20 @@
|
|||||||
"boss": true,
|
"boss": true,
|
||||||
"eqnull": true,
|
"eqnull": true,
|
||||||
"node": true,
|
"node": true,
|
||||||
"indent": 4,
|
|
||||||
"latedef": true,
|
"latedef": true,
|
||||||
"quotmark": "single",
|
"quotmark": "single",
|
||||||
"unused": true,
|
"unused": true,
|
||||||
|
"trailing" : true,
|
||||||
|
"laxbreak" : true,
|
||||||
"globals": {
|
"globals": {
|
||||||
"Kinetic": false,
|
"Kinetic": false,
|
||||||
"document": false
|
"document": false,
|
||||||
|
"window" : false,
|
||||||
|
"navigator" : false,
|
||||||
|
"define" : false,
|
||||||
|
"Image" : false,
|
||||||
|
"assert" : false,
|
||||||
|
"test": false,
|
||||||
|
"addStage" : false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,6 +58,7 @@ module.exports = function(grunt) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Project configuration.
|
// Project configuration.
|
||||||
|
var lintConf = grunt.file.readJSON('.jshintrc');
|
||||||
var config = {
|
var config = {
|
||||||
pkg: grunt.file.readJSON('package.json'),
|
pkg: grunt.file.readJSON('package.json'),
|
||||||
concat: {
|
concat: {
|
||||||
@@ -180,9 +181,7 @@ module.exports = function(grunt) {
|
|||||||
build: ['dist/*']
|
build: ['dist/*']
|
||||||
},
|
},
|
||||||
jshint: {
|
jshint: {
|
||||||
options: {
|
options: lintConf,
|
||||||
laxbreak: true
|
|
||||||
},
|
|
||||||
all: ['src/**/*.js']
|
all: ['src/**/*.js']
|
||||||
},
|
},
|
||||||
copy: {
|
copy: {
|
||||||
|
|||||||
@@ -5,12 +5,12 @@
|
|||||||
if (window.performance && window.performance.now) {
|
if (window.performance && window.performance.now) {
|
||||||
return function() {
|
return function() {
|
||||||
return window.performance.now();
|
return window.performance.now();
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return function() {
|
return function() {
|
||||||
return new Date().getTime();
|
return new Date().getTime();
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,9 @@
|
|||||||
CLOSE_BRACKET_PAREN = '])',
|
CLOSE_BRACKET_PAREN = '])',
|
||||||
SEMICOLON = ';',
|
SEMICOLON = ';',
|
||||||
DOUBLE_PAREN = '()',
|
DOUBLE_PAREN = '()',
|
||||||
EMPTY_STRING = '',
|
// EMPTY_STRING = '',
|
||||||
EQUALS = '=',
|
EQUALS = '=',
|
||||||
SET = 'set',
|
// SET = 'set',
|
||||||
CONTEXT_METHODS = [
|
CONTEXT_METHODS = [
|
||||||
'arc',
|
'arc',
|
||||||
'arcTo',
|
'arcTo',
|
||||||
@@ -195,8 +195,7 @@
|
|||||||
* @param {Number} [bounds.height]
|
* @param {Number} [bounds.height]
|
||||||
*/
|
*/
|
||||||
clear: function(bounds) {
|
clear: function(bounds) {
|
||||||
var canvas = this.getCanvas(),
|
var canvas = this.getCanvas();
|
||||||
pos, size;
|
|
||||||
|
|
||||||
if (bounds) {
|
if (bounds) {
|
||||||
this.clearRect(bounds.x || 0, bounds.y || 0, bounds.width || 0, bounds.height || 0);
|
this.clearRect(bounds.x || 0, bounds.y || 0, bounds.width || 0, bounds.height || 0);
|
||||||
@@ -387,9 +386,8 @@
|
|||||||
origSetter = this.setAttr,
|
origSetter = this.setAttr,
|
||||||
n, args;
|
n, args;
|
||||||
|
|
||||||
// methods
|
// to prevent creating scope function at each loop
|
||||||
for (n=0; n<len; n++) {
|
var func = function(methodName) {
|
||||||
(function(methodName) {
|
|
||||||
var origMethod = that[methodName],
|
var origMethod = that[methodName],
|
||||||
ret;
|
ret;
|
||||||
|
|
||||||
@@ -404,7 +402,10 @@
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
})(CONTEXT_METHODS[n]);
|
};
|
||||||
|
// methods
|
||||||
|
for (n=0; n<len; n++) {
|
||||||
|
func(CONTEXT_METHODS[n]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// attrs
|
// attrs
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
nodeType, layer;
|
nodeType, layer;
|
||||||
|
|
||||||
if(node) {
|
if(node) {
|
||||||
nodeType = node.nodeType,
|
nodeType = node.nodeType;
|
||||||
layer = node.getLayer();
|
layer = node.getLayer();
|
||||||
dd.anim.stop();
|
dd.anim.stop();
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/*jshint unused:false */
|
||||||
(function() {
|
(function() {
|
||||||
// CONSTANTS
|
// CONSTANTS
|
||||||
var ABSOLUTE_OPACITY = 'absoluteOpacity',
|
var ABSOLUTE_OPACITY = 'absoluteOpacity',
|
||||||
@@ -48,8 +49,7 @@
|
|||||||
this.addOverloadedGetterSetter(constructor, attr);
|
this.addOverloadedGetterSetter(constructor, attr);
|
||||||
},
|
},
|
||||||
addGetter: function(constructor, attr, def) {
|
addGetter: function(constructor, attr, def) {
|
||||||
var that = this,
|
var method = GET + Kinetic.Util._capitalize(attr);
|
||||||
method = GET + Kinetic.Util._capitalize(attr);
|
|
||||||
|
|
||||||
constructor.prototype[method] = function() {
|
constructor.prototype[method] = function() {
|
||||||
var val = this.attrs[attr];
|
var val = this.attrs[attr];
|
||||||
@@ -117,8 +117,7 @@
|
|||||||
this.addOverloadedGetterSetter(constructor, attr);
|
this.addOverloadedGetterSetter(constructor, attr);
|
||||||
},
|
},
|
||||||
addOverloadedGetterSetter: function(constructor, attr) {
|
addOverloadedGetterSetter: function(constructor, attr) {
|
||||||
var that = this,
|
var capitalizedAttr = Kinetic.Util._capitalize(attr),
|
||||||
capitalizedAttr = Kinetic.Util._capitalize(attr),
|
|
||||||
setter = SET + capitalizedAttr,
|
setter = SET + capitalizedAttr,
|
||||||
getter = GET + capitalizedAttr;
|
getter = GET + capitalizedAttr;
|
||||||
|
|
||||||
@@ -132,7 +131,7 @@
|
|||||||
else {
|
else {
|
||||||
return this[getter]();
|
return this[getter]();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
},
|
},
|
||||||
backCompat: function(constructor, methods) {
|
backCompat: function(constructor, methods) {
|
||||||
var key;
|
var key;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* KineticJS JavaScript Framework v@@version
|
* KineticJS JavaScript Framework v@@version
|
||||||
* http://www.kineticjs.com/
|
* http://www.kineticjs.com/
|
||||||
@@ -28,6 +29,7 @@
|
|||||||
/**
|
/**
|
||||||
* @namespace Kinetic
|
* @namespace Kinetic
|
||||||
*/
|
*/
|
||||||
|
/*jshint -W079, -W020*/
|
||||||
var Kinetic = {};
|
var Kinetic = {};
|
||||||
(function() {
|
(function() {
|
||||||
Kinetic = {
|
Kinetic = {
|
||||||
@@ -57,7 +59,7 @@ var Kinetic = {};
|
|||||||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
|
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
|
||||||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
|
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
|
||||||
/(msie) ([\w.]+)/.exec( ua ) ||
|
/(msie) ([\w.]+)/.exec( ua ) ||
|
||||||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
|
ua.indexOf('compatible') < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
|
||||||
[];
|
[];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
16
src/Stage.js
16
src/Stage.js
@@ -1,3 +1,4 @@
|
|||||||
|
/*jshint unused:false */
|
||||||
(function() {
|
(function() {
|
||||||
// CONSTANTS
|
// CONSTANTS
|
||||||
var STAGE = 'Stage',
|
var STAGE = 'Stage',
|
||||||
@@ -336,10 +337,7 @@
|
|||||||
return this.getChildren();
|
return this.getChildren();
|
||||||
},
|
},
|
||||||
_bindContentEvents: function() {
|
_bindContentEvents: function() {
|
||||||
var that = this,
|
for (var n = 0; n < eventsLength; n++) {
|
||||||
n;
|
|
||||||
|
|
||||||
for (n = 0; n < eventsLength; n++) {
|
|
||||||
addEvent(this, EVENTS[n]);
|
addEvent(this, EVENTS[n]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -426,8 +424,7 @@
|
|||||||
},
|
},
|
||||||
_mouseup: function(evt) {
|
_mouseup: function(evt) {
|
||||||
this._setPointerPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
var that = this,
|
var shape = this.getIntersection(this.getPointerPosition()),
|
||||||
shape = this.getIntersection(this.getPointerPosition()),
|
|
||||||
clickStartShape = this.clickStartShape,
|
clickStartShape = this.clickStartShape,
|
||||||
fireDblClick = false;
|
fireDblClick = false;
|
||||||
|
|
||||||
@@ -492,8 +489,7 @@
|
|||||||
},
|
},
|
||||||
_touchend: function(evt) {
|
_touchend: function(evt) {
|
||||||
this._setPointerPosition(evt);
|
this._setPointerPosition(evt);
|
||||||
var that = this,
|
var shape = this.getIntersection(this.getPointerPosition()),
|
||||||
shape = this.getIntersection(this.getPointerPosition());
|
|
||||||
fireDblClick = false;
|
fireDblClick = false;
|
||||||
|
|
||||||
if(Kinetic.inDblClickWindow) {
|
if(Kinetic.inDblClickWindow) {
|
||||||
@@ -555,13 +551,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_setPointerPosition: function(evt) {
|
_setPointerPosition: function(evt) {
|
||||||
var evt = evt ? evt : window.event,
|
var contentPosition = this._getContentPosition(),
|
||||||
contentPosition = this._getContentPosition(),
|
|
||||||
offsetX = evt.offsetX,
|
offsetX = evt.offsetX,
|
||||||
clientX = evt.clientX,
|
clientX = evt.clientX,
|
||||||
x = null,
|
x = null,
|
||||||
y = null,
|
y = null,
|
||||||
touch;
|
touch;
|
||||||
|
evt = evt ? evt : window.event;
|
||||||
|
|
||||||
// touch events
|
// touch events
|
||||||
if(evt.touches !== undefined) {
|
if(evt.touches !== undefined) {
|
||||||
|
|||||||
12
src/Tween.js
12
src/Tween.js
@@ -41,7 +41,7 @@
|
|||||||
duration = config.duration || 1,
|
duration = config.duration || 1,
|
||||||
easing = config.easing || Kinetic.Easings.Linear,
|
easing = config.easing || Kinetic.Easings.Linear,
|
||||||
yoyo = !!config.yoyo,
|
yoyo = !!config.yoyo,
|
||||||
key, tween, start, tweenId;
|
key;
|
||||||
|
|
||||||
this.node = node;
|
this.node = node;
|
||||||
this._id = idCounter++;
|
this._id = idCounter++;
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
_addAttr: function(key, end) {
|
_addAttr: function(key, end) {
|
||||||
var node = this.node,
|
var node = this.node,
|
||||||
nodeId = node._id,
|
nodeId = node._id,
|
||||||
start, diff, tweenId, n, len, startVal, endVal;
|
start, diff, tweenId, n, len;
|
||||||
|
|
||||||
// remove conflict from tween map if it exists
|
// remove conflict from tween map if it exists
|
||||||
tweenId = Kinetic.Tween.tweens[nodeId][key];
|
tweenId = Kinetic.Tween.tweens[nodeId][key];
|
||||||
@@ -123,7 +123,7 @@
|
|||||||
_tweenFunc: function(i) {
|
_tweenFunc: function(i) {
|
||||||
var node = this.node,
|
var node = this.node,
|
||||||
attrs = Kinetic.Tween.attrs[node._id][this._id],
|
attrs = Kinetic.Tween.attrs[node._id][this._id],
|
||||||
key, attr, start, diff, newVal, n, len, startVal, diffVal;
|
key, attr, start, diff, newVal, n, len;
|
||||||
|
|
||||||
for (key in attrs) {
|
for (key in attrs) {
|
||||||
attr = attrs[key];
|
attr = attrs[key];
|
||||||
@@ -390,7 +390,7 @@
|
|||||||
* @function
|
* @function
|
||||||
* @memberof Kinetic.Easings
|
* @memberof Kinetic.Easings
|
||||||
*/
|
*/
|
||||||
'BackEaseIn': function(t, b, c, d, a, p) {
|
'BackEaseIn': function(t, b, c, d) {
|
||||||
var s = 1.70158;
|
var s = 1.70158;
|
||||||
return c * (t /= d) * t * ((s + 1) * t - s) + b;
|
return c * (t /= d) * t * ((s + 1) * t - s) + b;
|
||||||
},
|
},
|
||||||
@@ -399,7 +399,7 @@
|
|||||||
* @function
|
* @function
|
||||||
* @memberof Kinetic.Easings
|
* @memberof Kinetic.Easings
|
||||||
*/
|
*/
|
||||||
'BackEaseOut': function(t, b, c, d, a, p) {
|
'BackEaseOut': function(t, b, c, d) {
|
||||||
var s = 1.70158;
|
var s = 1.70158;
|
||||||
return c * (( t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
|
return c * (( t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
|
||||||
},
|
},
|
||||||
@@ -408,7 +408,7 @@
|
|||||||
* @function
|
* @function
|
||||||
* @memberof Kinetic.Easings
|
* @memberof Kinetic.Easings
|
||||||
*/
|
*/
|
||||||
'BackEaseInOut': function(t, b, c, d, a, p) {
|
'BackEaseInOut': function(t, b, c, d) {
|
||||||
var s = 1.70158;
|
var s = 1.70158;
|
||||||
if((t /= d / 2) < 1) {
|
if((t /= d / 2) < 1) {
|
||||||
return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
|
return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
|
||||||
|
|||||||
22
src/Util.js
22
src/Util.js
@@ -64,25 +64,25 @@
|
|||||||
return collection;
|
return collection;
|
||||||
};
|
};
|
||||||
|
|
||||||
Kinetic.Collection.mapMethods = function(constructor) {
|
// map one method by it's name
|
||||||
var prot = constructor.prototype,
|
Kinetic.Collection._mapMethod = function(methodName) {
|
||||||
key;
|
|
||||||
|
|
||||||
for(key in prot) {
|
|
||||||
// induce scope
|
|
||||||
(function(methodName) {
|
|
||||||
Kinetic.Collection.prototype[methodName] = function() {
|
Kinetic.Collection.prototype[methodName] = function() {
|
||||||
var len = this.length,
|
var len = this.length,
|
||||||
i;
|
i;
|
||||||
|
|
||||||
args = [].slice.call(arguments);
|
var args = [].slice.call(arguments);
|
||||||
for(i = 0; i < len; i++) {
|
for(i = 0; i < len; i++) {
|
||||||
this[i][methodName].apply(this[i], args);
|
this[i][methodName].apply(this[i], args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
})(key);
|
};
|
||||||
|
|
||||||
|
Kinetic.Collection.mapMethods = function(constructor) {
|
||||||
|
var prot = constructor.prototype;
|
||||||
|
for(var methodName in prot) {
|
||||||
|
Kinetic.Collection._mapMethod(methodName);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@
|
|||||||
* arg can be an image object or image data
|
* arg can be an image object or image data
|
||||||
*/
|
*/
|
||||||
_getImage: function(arg, callback) {
|
_getImage: function(arg, callback) {
|
||||||
var imageObj, canvas, context, dataUrl;
|
var imageObj, canvas;
|
||||||
|
|
||||||
// if arg is null or undefined
|
// if arg is null or undefined
|
||||||
if(!arg) {
|
if(!arg) {
|
||||||
@@ -391,7 +391,7 @@
|
|||||||
canvas = document.createElement(CANVAS);
|
canvas = document.createElement(CANVAS);
|
||||||
canvas.width = arg.width;
|
canvas.width = arg.width;
|
||||||
canvas.height = arg.height;
|
canvas.height = arg.height;
|
||||||
_context = canvas.getContext(CONTEXT_2D);
|
var _context = canvas.getContext(CONTEXT_2D);
|
||||||
_context.putImageData(arg, 0, 0);
|
_context.putImageData(arg, 0, 0);
|
||||||
this._getImage(canvas.toDataURL(), callback);
|
this._getImage(canvas.toDataURL(), callback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,8 @@
|
|||||||
451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,
|
451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,
|
||||||
385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,
|
385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,
|
||||||
332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,
|
332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,
|
||||||
289,287,285,282,280,278,275,273,271,269,267,265,263,261,259];
|
289,287,285,282,280,278,275,273,271,269,267,265,263,261,259
|
||||||
|
];
|
||||||
|
|
||||||
var shg_table = [
|
var shg_table = [
|
||||||
9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
|
9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
|
||||||
@@ -86,7 +87,8 @@
|
|||||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 ];
|
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
|
||||||
|
];
|
||||||
|
|
||||||
function filterGaussBlurRGBA( imageData, radius) {
|
function filterGaussBlurRGBA( imageData, radius) {
|
||||||
|
|
||||||
@@ -114,7 +116,9 @@
|
|||||||
|
|
||||||
for ( i = 1; i < div; i++ ) {
|
for ( i = 1; i < div; i++ ) {
|
||||||
stack = stack.next = new BlurStack();
|
stack = stack.next = new BlurStack();
|
||||||
if ( i == radiusPlus1 ) stackEnd = stack;
|
if ( i == radiusPlus1 ){
|
||||||
|
stackEnd = stack;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.next = stackStart;
|
stack.next = stackStart;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
dirY = 0,
|
dirY = 0,
|
||||||
dirX = 0,
|
dirX = 0,
|
||||||
data = imageData.data,
|
data = imageData.data,
|
||||||
invertAlpha = false,
|
|
||||||
w = imageData.width,
|
w = imageData.width,
|
||||||
h = imageData.height,
|
h = imageData.height,
|
||||||
w4 = w*4,
|
w4 = w*4,
|
||||||
@@ -66,8 +65,12 @@
|
|||||||
var offsetY = (y-1)*w4;
|
var offsetY = (y-1)*w4;
|
||||||
|
|
||||||
var otherY = dirY;
|
var otherY = dirY;
|
||||||
if (y + otherY < 1) otherY = 0;
|
if (y + otherY < 1){
|
||||||
if (y + otherY > h) otherY = 0;
|
otherY = 0;
|
||||||
|
}
|
||||||
|
if (y + otherY > h) {
|
||||||
|
otherY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
var offsetYOther = (y-1+otherY)*w*4;
|
var offsetYOther = (y-1+otherY)*w*4;
|
||||||
|
|
||||||
@@ -76,8 +79,12 @@
|
|||||||
var offset = offsetY + (x-1)*4;
|
var offset = offsetY + (x-1)*4;
|
||||||
|
|
||||||
var otherX = dirX;
|
var otherX = dirX;
|
||||||
if (x + otherX < 1) otherX = 0;
|
if (x + otherX < 1){
|
||||||
if (x + otherX > w) otherX = 0;
|
otherX = 0;
|
||||||
|
}
|
||||||
|
if (x + otherX > w) {
|
||||||
|
otherX = 0;
|
||||||
|
}
|
||||||
|
|
||||||
var offsetOther = offsetYOther + (x-1+otherX)*4;
|
var offsetOther = offsetYOther + (x-1+otherX)*4;
|
||||||
|
|
||||||
@@ -163,7 +170,6 @@
|
|||||||
* @param {Boolean} embossBlend
|
* @param {Boolean} embossBlend
|
||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
rMin = data[0], rMax = rMin, r,
|
rMin = data[0], rMax = rMin, r,
|
||||||
gMin = data[1], gMax = gMin, g,
|
gMin = data[1], gMax = gMin, g,
|
||||||
bMin = data[2], bMax = bMin, b,
|
bMin = data[2], bMax = bMin, b,
|
||||||
aMin = data[3], aMax = aMin, a,
|
aMin = data[3], aMax = aMin,
|
||||||
i;
|
i;
|
||||||
|
|
||||||
// If we are not enhancing anything - don't do any computation
|
// If we are not enhancing anything - don't do any computation
|
||||||
@@ -46,8 +46,8 @@
|
|||||||
// 1st Pass - find the min and max for each channel:
|
// 1st Pass - find the min and max for each channel:
|
||||||
for (i = 0; i < nSubPixels; i += 4) {
|
for (i = 0; i < nSubPixels; i += 4) {
|
||||||
r = data[i + 0];
|
r = data[i + 0];
|
||||||
if (r < rMin) { rMin = r; } else
|
if (r < rMin) { rMin = r; }
|
||||||
if (r > rMax) { rMax = r; }
|
else if (r > rMax) { rMax = r; }
|
||||||
g = data[i + 1];
|
g = data[i + 1];
|
||||||
if (g < gMin) { gMin = g; } else
|
if (g < gMin) { gMin = g; } else
|
||||||
if (g > gMax) { gMax = g; }
|
if (g > gMax) { gMax = g; }
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
aMid, aGoalMax,bGoalMin;
|
aMid, aGoalMax,bGoalMin;
|
||||||
|
|
||||||
// If the enhancement is positive - stretch the histogram
|
// If the enhancement is positive - stretch the histogram
|
||||||
if( enhanceAmount > 0 ){
|
if ( enhanceAmount > 0 ){
|
||||||
rGoalMax = rMax + enhanceAmount*(255-rMax);
|
rGoalMax = rMax + enhanceAmount*(255-rMax);
|
||||||
rGoalMin = rMin - enhanceAmount*(rMin-0);
|
rGoalMin = rMin - enhanceAmount*(rMin-0);
|
||||||
gGoalMax = gMax + enhanceAmount*(255-gMax);
|
gGoalMax = gMax + enhanceAmount*(255-gMax);
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
aGoalMax = aMax + enhanceAmount*(255-aMax);
|
aGoalMax = aMax + enhanceAmount*(255-aMax);
|
||||||
aGoalMin = aMin - enhanceAmount*(aMin-0);
|
aGoalMin = aMin - enhanceAmount*(aMin-0);
|
||||||
// If the enhancement is negative - compress the histogram
|
// If the enhancement is negative - compress the histogram
|
||||||
}else{
|
} else {
|
||||||
rMid = (rMax + rMin)*0.5;
|
rMid = (rMax + rMin)*0.5;
|
||||||
rGoalMax = rMax + enhanceAmount*(rMax-rMid);
|
rGoalMax = rMax + enhanceAmount*(rMax-rMid);
|
||||||
rGoalMin = rMin + enhanceAmount*(rMin-rMid);
|
rGoalMin = rMin + enhanceAmount*(rMin-rMid);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/*jshint newcap:false */
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -24,7 +25,7 @@
|
|||||||
ySize = src.height,
|
ySize = src.height,
|
||||||
xMid = opt.polarCenterX || xSize/2,
|
xMid = opt.polarCenterX || xSize/2,
|
||||||
yMid = opt.polarCenterY || ySize/2,
|
yMid = opt.polarCenterY || ySize/2,
|
||||||
i, m, x, y, k, tmp, r=0,g=0,b=0,a=0;
|
i, x, y, r=0,g=0,b=0,a=0;
|
||||||
|
|
||||||
// Find the largest radius
|
// Find the largest radius
|
||||||
var rad, rMax = Math.sqrt( xMid*xMid + yMid*yMid );
|
var rad, rMax = Math.sqrt( xMid*xMid + yMid*yMid );
|
||||||
@@ -42,7 +43,7 @@
|
|||||||
// radians (*PI/180)
|
// radians (*PI/180)
|
||||||
var conversion = 360/tSize*Math.PI/180, sin, cos;
|
var conversion = 360/tSize*Math.PI/180, sin, cos;
|
||||||
|
|
||||||
var x1, x2, x1i, x2i, y1, y2, y1i, y2i, scale;
|
// var x1, x2, x1i, x2i, y1, y2, y1i, y2i, scale;
|
||||||
|
|
||||||
for( theta=0; theta<tSize; theta+=1 ){
|
for( theta=0; theta<tSize; theta+=1 ){
|
||||||
sin = Math.sin(theta*conversion);
|
sin = Math.sin(theta*conversion);
|
||||||
@@ -93,7 +94,7 @@
|
|||||||
ySize = src.height,
|
ySize = src.height,
|
||||||
xMid = opt.polarCenterX || xSize/2,
|
xMid = opt.polarCenterX || xSize/2,
|
||||||
yMid = opt.polarCenterY || ySize/2,
|
yMid = opt.polarCenterY || ySize/2,
|
||||||
i, m, x, y, dx, dy, k, tmp, r=0,g=0,b=0,a=0;
|
i, x, y, dx, dy, r=0,g=0,b=0,a=0;
|
||||||
|
|
||||||
|
|
||||||
// Find the largest radius
|
// Find the largest radius
|
||||||
@@ -112,9 +113,9 @@
|
|||||||
// We need to convert to degrees and we need to make sure
|
// We need to convert to degrees and we need to make sure
|
||||||
// it's between (0-360)
|
// it's between (0-360)
|
||||||
// var conversion = tSize/360*180/Math.PI;
|
// var conversion = tSize/360*180/Math.PI;
|
||||||
var conversion = tSize/360*180/Math.PI;
|
//var conversion = tSize/360*180/Math.PI;
|
||||||
|
|
||||||
var x1, x2, x1i, x2i, y1, y2, y1i, y2i, scale;
|
var x1, y1;
|
||||||
|
|
||||||
for( x=0; x<xSize; x+=1 ){
|
for( x=0; x<xSize; x+=1 ){
|
||||||
for( y=0; y<ySize; y+=1 ){
|
for( y=0; y<ySize; y+=1 ){
|
||||||
@@ -157,6 +158,8 @@
|
|||||||
Kinetic.Filters.Kaleidoscope = function(imageData){
|
Kinetic.Filters.Kaleidoscope = function(imageData){
|
||||||
var xSize = imageData.width,
|
var xSize = imageData.width,
|
||||||
ySize = imageData.height;
|
ySize = imageData.height;
|
||||||
|
|
||||||
|
var x,y,xoff,i, r,g,b,a, srcPos, dstPos;
|
||||||
var power = Math.round( this.kaleidoscopePower() );
|
var power = Math.round( this.kaleidoscopePower() );
|
||||||
var angle = Math.round( this.kaleidoscopeAngle() );
|
var angle = Math.round( this.kaleidoscopeAngle() );
|
||||||
var offset = Math.floor(xSize*(angle%360)/360);
|
var offset = Math.floor(xSize*(angle%360)/360);
|
||||||
@@ -212,7 +215,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Perform the actual effect
|
// Perform the actual effect
|
||||||
var x,y,xoff,i, r,g,b,a, srcPos, dstPos;
|
|
||||||
for( y=0; y<ySize; y+=1 ){
|
for( y=0; y<ySize; y+=1 ){
|
||||||
sectionSize = Math.floor( minSectionSize );
|
sectionSize = Math.floor( minSectionSize );
|
||||||
for( i=0; i<power; i+=1 ){
|
for( i=0; i<power; i+=1 ){
|
||||||
|
|||||||
@@ -14,14 +14,14 @@
|
|||||||
var pixelSize = Math.ceil(this.pixelSize()),
|
var pixelSize = Math.ceil(this.pixelSize()),
|
||||||
width = imageData.width,
|
width = imageData.width,
|
||||||
height = imageData.height,
|
height = imageData.height,
|
||||||
imageData = imageData.data,
|
|
||||||
x, y, i,
|
x, y, i,
|
||||||
pixelsPerBin = pixelSize * pixelSize,
|
//pixelsPerBin = pixelSize * pixelSize,
|
||||||
red, green, blue, alpha,
|
red, green, blue, alpha,
|
||||||
nBinsX = Math.ceil(width / pixelSize),
|
nBinsX = Math.ceil(width / pixelSize),
|
||||||
nBinsY = Math.ceil(height / pixelSize),
|
nBinsY = Math.ceil(height / pixelSize),
|
||||||
xBinStart, xBinEnd, yBinStart, yBinEnd,
|
xBinStart, xBinEnd, yBinStart, yBinEnd,
|
||||||
xBin, yBin, pixelsInBin;
|
xBin, yBin, pixelsInBin;
|
||||||
|
imageData = imageData.data;
|
||||||
|
|
||||||
for (xBin = 0; xBin < nBinsX; xBin += 1) {
|
for (xBin = 0; xBin < nBinsX; xBin += 1) {
|
||||||
for (yBin = 0; yBin < nBinsY; yBin += 1) {
|
for (yBin = 0; yBin < nBinsY; yBin += 1) {
|
||||||
@@ -57,7 +57,6 @@
|
|||||||
red = red / pixelsInBin;
|
red = red / pixelsInBin;
|
||||||
green = green / pixelsInBin;
|
green = green / pixelsInBin;
|
||||||
blue = blue / pixelsInBin;
|
blue = blue / pixelsInBin;
|
||||||
alphas = alpha / pixelsInBin;
|
|
||||||
|
|
||||||
// Draw this bin
|
// Draw this bin
|
||||||
for (x = xBinStart; x < xBinEnd; x += 1) {
|
for (x = xBinStart; x < xBinEnd; x += 1) {
|
||||||
|
|||||||
@@ -24,14 +24,19 @@
|
|||||||
var g = data[offset+1];
|
var g = data[offset+1];
|
||||||
var b = data[offset+2];
|
var b = data[offset+2];
|
||||||
|
|
||||||
if (r > 127) r = 255 - r;
|
if (r > 127) {
|
||||||
if (g > 127) g = 255 - g;
|
r = 255 - r;
|
||||||
if (b > 127) b = 255 - b;
|
}
|
||||||
|
if (g > 127) {
|
||||||
|
g = 255 - g;
|
||||||
|
}
|
||||||
|
if (b > 127) {
|
||||||
|
b = 255 - b;
|
||||||
|
}
|
||||||
|
|
||||||
data[offset] = r;
|
data[offset] = r;
|
||||||
data[offset+1] = g;
|
data[offset+1] = g;
|
||||||
data[offset+2] = b;
|
data[offset+2] = b;
|
||||||
|
|
||||||
} while (--x);
|
} while (--x);
|
||||||
} while (--y);
|
} while (--y);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -107,15 +107,15 @@
|
|||||||
_sync: function() {
|
_sync: function() {
|
||||||
var text = this.getText(),
|
var text = this.getText(),
|
||||||
tag = this.getTag(),
|
tag = this.getTag(),
|
||||||
width, height, pointerDirection, pointerWidth, x, y;
|
width, height, pointerDirection, pointerWidth, x, y, pointerHeight;
|
||||||
|
|
||||||
if (text && tag) {
|
if (text && tag) {
|
||||||
width = text.getWidth(),
|
width = text.getWidth();
|
||||||
height = text.getHeight(),
|
height = text.getHeight();
|
||||||
pointerDirection = tag.getPointerDirection(),
|
pointerDirection = tag.getPointerDirection();
|
||||||
pointerWidth = tag.getPointerWidth(),
|
pointerWidth = tag.getPointerWidth();
|
||||||
pointerHeight = tag.getPointerHeight(),
|
pointerHeight = tag.getPointerHeight();
|
||||||
x = 0,
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
|
|
||||||
switch(pointerDirection) {
|
switch(pointerDirection) {
|
||||||
@@ -183,8 +183,8 @@
|
|||||||
height = this.getHeight(),
|
height = this.getHeight(),
|
||||||
pointerDirection = this.getPointerDirection(),
|
pointerDirection = this.getPointerDirection(),
|
||||||
pointerWidth = this.getPointerWidth(),
|
pointerWidth = this.getPointerWidth(),
|
||||||
pointerHeight = this.getPointerHeight(),
|
pointerHeight = this.getPointerHeight();
|
||||||
cornerRadius = this.getCornerRadius();
|
//cornerRadius = this.getCornerRadius();
|
||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.moveTo(0,0);
|
context.moveTo(0,0);
|
||||||
|
|||||||
@@ -106,8 +106,9 @@
|
|||||||
|
|
||||||
var m = (P2y - P1y) / ((P2x - P1x) + 0.00000001);
|
var m = (P2y - P1y) / ((P2x - P1x) + 0.00000001);
|
||||||
var run = Math.sqrt(dist * dist / (1 + m * m));
|
var run = Math.sqrt(dist * dist / (1 + m * m));
|
||||||
if(P2x < P1x)
|
if(P2x < P1x) {
|
||||||
run *= -1;
|
run *= -1;
|
||||||
|
}
|
||||||
var rise = m * run;
|
var rise = m * run;
|
||||||
var pt;
|
var pt;
|
||||||
|
|
||||||
@@ -137,8 +138,9 @@
|
|||||||
var pRise = this.getLineLength(fromX, fromY, ix, iy);
|
var pRise = this.getLineLength(fromX, fromY, ix, iy);
|
||||||
var pRun = Math.sqrt(dist * dist - pRise * pRise);
|
var pRun = Math.sqrt(dist * dist - pRise * pRise);
|
||||||
run = Math.sqrt(pRun * pRun / (1 + m * m));
|
run = Math.sqrt(pRun * pRun / (1 + m * m));
|
||||||
if(P2x < P1x)
|
if(P2x < P1x) {
|
||||||
run *= -1;
|
run *= -1;
|
||||||
|
}
|
||||||
rise = m * run;
|
rise = m * run;
|
||||||
pt = {
|
pt = {
|
||||||
x: ix + run,
|
x: ix + run,
|
||||||
@@ -268,8 +270,9 @@
|
|||||||
p[i] = parseFloat(p[i]);
|
p[i] = parseFloat(p[i]);
|
||||||
}
|
}
|
||||||
while(p.length > 0) {
|
while(p.length > 0) {
|
||||||
if(isNaN(p[0]))// case for a trailing comma before next command
|
if(isNaN(p[0])) {// case for a trailing comma before next command
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
var cmd = null;
|
var cmd = null;
|
||||||
var points = [];
|
var points = [];
|
||||||
@@ -360,7 +363,8 @@
|
|||||||
points.push(cpx, cpy);
|
points.push(cpx, cpy);
|
||||||
break;
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
ctlPtx = cpx, ctlPty = cpy;
|
ctlPtx = cpx;
|
||||||
|
ctlPty = cpy;
|
||||||
prevCmd = ca[ca.length - 1];
|
prevCmd = ca[ca.length - 1];
|
||||||
if(prevCmd.command === 'C') {
|
if(prevCmd.command === 'C') {
|
||||||
ctlPtx = cpx + (cpx - prevCmd.points[2]);
|
ctlPtx = cpx + (cpx - prevCmd.points[2]);
|
||||||
@@ -373,7 +377,8 @@
|
|||||||
points.push(cpx, cpy);
|
points.push(cpx, cpy);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
ctlPtx = cpx, ctlPty = cpy;
|
ctlPtx = cpx;
|
||||||
|
ctlPty = cpy;
|
||||||
prevCmd = ca[ca.length - 1];
|
prevCmd = ca[ca.length - 1];
|
||||||
if(prevCmd.command === 'C') {
|
if(prevCmd.command === 'C') {
|
||||||
ctlPtx = cpx + (cpx - prevCmd.points[2]);
|
ctlPtx = cpx + (cpx - prevCmd.points[2]);
|
||||||
@@ -399,7 +404,8 @@
|
|||||||
points.push(cpx, cpy);
|
points.push(cpx, cpy);
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
ctlPtx = cpx, ctlPty = cpy;
|
ctlPtx = cpx;
|
||||||
|
ctlPty = cpy;
|
||||||
prevCmd = ca[ca.length - 1];
|
prevCmd = ca[ca.length - 1];
|
||||||
if(prevCmd.command === 'Q') {
|
if(prevCmd.command === 'Q') {
|
||||||
ctlPtx = cpx + (cpx - prevCmd.points[0]);
|
ctlPtx = cpx + (cpx - prevCmd.points[0]);
|
||||||
@@ -411,7 +417,8 @@
|
|||||||
points.push(ctlPtx, ctlPty, cpx, cpy);
|
points.push(ctlPtx, ctlPty, cpx, cpy);
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
ctlPtx = cpx, ctlPty = cpy;
|
ctlPtx = cpx;
|
||||||
|
ctlPty = cpy;
|
||||||
prevCmd = ca[ca.length - 1];
|
prevCmd = ca[ca.length - 1];
|
||||||
if(prevCmd.command === 'Q') {
|
if(prevCmd.command === 'Q') {
|
||||||
ctlPtx = cpx + (cpx - prevCmd.points[0]);
|
ctlPtx = cpx + (cpx - prevCmd.points[0]);
|
||||||
@@ -423,14 +430,27 @@
|
|||||||
points.push(ctlPtx, ctlPty, cpx, cpy);
|
points.push(ctlPtx, ctlPty, cpx, cpy);
|
||||||
break;
|
break;
|
||||||
case 'A':
|
case 'A':
|
||||||
rx = p.shift(), ry = p.shift(), psi = p.shift(), fa = p.shift(), fs = p.shift();
|
rx = p.shift();
|
||||||
x1 = cpx, y1 = cpy; cpx = p.shift(), cpy = p.shift();
|
ry = p.shift();
|
||||||
|
psi = p.shift();
|
||||||
|
fa = p.shift();
|
||||||
|
fs = p.shift();
|
||||||
|
x1 = cpx;
|
||||||
|
y1 = cpy;
|
||||||
|
cpx = p.shift();
|
||||||
|
cpy = p.shift();
|
||||||
cmd = 'A';
|
cmd = 'A';
|
||||||
points = this.convertEndpointToCenterParameterization(x1, y1, cpx, cpy, fa, fs, rx, ry, psi);
|
points = this.convertEndpointToCenterParameterization(x1, y1, cpx, cpy, fa, fs, rx, ry, psi);
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
rx = p.shift(), ry = p.shift(), psi = p.shift(), fa = p.shift(), fs = p.shift();
|
rx = p.shift();
|
||||||
x1 = cpx, y1 = cpy; cpx += p.shift(), cpy += p.shift();
|
ry = p.shift();
|
||||||
|
psi = p.shift();
|
||||||
|
fa = p.shift();
|
||||||
|
fs = p.shift();
|
||||||
|
x1 = cpx;
|
||||||
|
y1 = cpy; cpx += p.shift();
|
||||||
|
cpy += p.shift();
|
||||||
cmd = 'A';
|
cmd = 'A';
|
||||||
points = this.convertEndpointToCenterParameterization(x1, y1, cpx, cpy, fa, fs, rx, ry, psi);
|
points = this.convertEndpointToCenterParameterization(x1, y1, cpx, cpy, fa, fs, rx, ry, psi);
|
||||||
break;
|
break;
|
||||||
@@ -460,7 +480,7 @@
|
|||||||
return ca;
|
return ca;
|
||||||
};
|
};
|
||||||
Kinetic.Path.calcLength = function(x, y, cmd, points) {
|
Kinetic.Path.calcLength = function(x, y, cmd, points) {
|
||||||
var len, p1, p2;
|
var len, p1, p2, t;
|
||||||
var path = Kinetic.Path;
|
var path = Kinetic.Path;
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
@@ -538,7 +558,7 @@
|
|||||||
|
|
||||||
var f = Math.sqrt((((rx * rx) * (ry * ry)) - ((rx * rx) * (yp * yp)) - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp) + (ry * ry) * (xp * xp)));
|
var f = Math.sqrt((((rx * rx) * (ry * ry)) - ((rx * rx) * (yp * yp)) - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp) + (ry * ry) * (xp * xp)));
|
||||||
|
|
||||||
if(fa == fs) {
|
if(fa === fs) {
|
||||||
f *= -1;
|
f *= -1;
|
||||||
}
|
}
|
||||||
if(isNaN(f)) {
|
if(isNaN(f)) {
|
||||||
@@ -574,7 +594,7 @@
|
|||||||
if(fs === 0 && dTheta > 0) {
|
if(fs === 0 && dTheta > 0) {
|
||||||
dTheta = dTheta - 2 * Math.PI;
|
dTheta = dTheta - 2 * Math.PI;
|
||||||
}
|
}
|
||||||
if(fs == 1 && dTheta < 0) {
|
if(fs === 1 && dTheta < 0) {
|
||||||
dTheta = dTheta + 2 * Math.PI;
|
dTheta = dTheta + 2 * Math.PI;
|
||||||
}
|
}
|
||||||
return [cx, cy, rx, ry, theta, dTheta, psi, fs];
|
return [cx, cy, rx, ry, theta, dTheta, psi, fs];
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
// CONSTANTS
|
// CONSTANTS
|
||||||
var IMAGE = 'Image',
|
var IMAGE = 'Image';
|
||||||
SET = 'set';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image constructor
|
* Image constructor
|
||||||
@@ -49,13 +48,12 @@
|
|||||||
crop, cropWidth, cropHeight, params;
|
crop, cropWidth, cropHeight, params;
|
||||||
|
|
||||||
if (image) {
|
if (image) {
|
||||||
crop = this.getCrop(),
|
crop = this.getCrop();
|
||||||
cropWidth = crop.width;
|
cropWidth = crop.width;
|
||||||
cropHeight = crop.height;
|
cropHeight = crop.height;
|
||||||
if (cropWidth && cropHeight) {
|
if (cropWidth && cropHeight) {
|
||||||
params = [image, crop.x, crop.y, cropWidth, cropHeight, 0, 0, width, height];
|
params = [image, crop.x, crop.y, cropWidth, cropHeight, 0, 0, width, height];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
params = [image, 0, 0, width, height];
|
params = [image, 0, 0, width, height];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
Kinetic.Line.prototype = {
|
Kinetic.Line.prototype = {
|
||||||
___init: function(config) {
|
___init: function(config) {
|
||||||
var that = this;
|
|
||||||
// call super constructor
|
// call super constructor
|
||||||
Kinetic.Shape.call(this, config);
|
Kinetic.Shape.call(this, config);
|
||||||
this.className = 'Line';
|
this.className = 'Line';
|
||||||
@@ -43,7 +42,7 @@
|
|||||||
length = points.length,
|
length = points.length,
|
||||||
tension = this.getTension(),
|
tension = this.getTension(),
|
||||||
closed = this.getClosed(),
|
closed = this.getClosed(),
|
||||||
tp, len, n, point;
|
tp, len, n;
|
||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.moveTo(points[0], points[1]);
|
context.moveTo(points[0], points[1]);
|
||||||
@@ -81,7 +80,7 @@
|
|||||||
// open e.g. lines and splines
|
// open e.g. lines and splines
|
||||||
else {
|
else {
|
||||||
context.strokeShape(this);
|
context.strokeShape(this);
|
||||||
};
|
}
|
||||||
},
|
},
|
||||||
getTensionPoints: function() {
|
getTensionPoints: function() {
|
||||||
return this._getCache('tensionPoints', this._getTensionPoints);
|
return this._getCache('tensionPoints', this._getTensionPoints);
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
console.log('test')
|
|
||||||
|
|
||||||
var stage;
|
var stage;
|
||||||
var circlesLayer;
|
var circlesLayer;
|
||||||
var circles;
|
var circles;
|
||||||
@@ -9,7 +7,7 @@
|
|||||||
|
|
||||||
var VERSION = Kinetic.version === '4.7.4' || Kinetic.version === 'dev' ? 'new' : 'old';
|
var VERSION = Kinetic.version === '4.7.4' || Kinetic.version === 'dev' ? 'new' : 'old';
|
||||||
|
|
||||||
window.requestAnimFrame = (function(callback){
|
window.requestAnimFrame = (function(){
|
||||||
return window.requestAnimationFrame ||
|
return window.requestAnimationFrame ||
|
||||||
window.webkitRequestAnimationFrame ||
|
window.webkitRequestAnimationFrame ||
|
||||||
window.mozRequestAnimationFrame ||
|
window.mozRequestAnimationFrame ||
|
||||||
@@ -46,7 +44,7 @@
|
|||||||
colorIndex = 0;
|
colorIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var shape = make_shape('red');
|
var shape = make_shape(color);
|
||||||
circlesLayer.add(shape);
|
circlesLayer.add(shape);
|
||||||
circles.push(shape);
|
circles.push(shape);
|
||||||
}());
|
}());
|
||||||
@@ -66,10 +64,10 @@
|
|||||||
var period = timeDiff/1000; //times per second, our period
|
var period = timeDiff/1000; //times per second, our period
|
||||||
|
|
||||||
for (var i = 0; i < circles.length; i++) {
|
for (var i = 0; i < circles.length; i++) {
|
||||||
var x = Math.random() * width;
|
var x = Math.round(Math.random() * width);
|
||||||
var y = Math.random() * height;
|
var y = Math.round(Math.random() * height);
|
||||||
if (VERSION === 'new') {
|
if (VERSION === 'new') {
|
||||||
circles[i].position({x: x, y: y});
|
circles[i].setPosition({x: x, y: y});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
circles[i].setPosition(x, y);
|
circles[i].setPosition(x, y);
|
||||||
@@ -91,7 +89,8 @@
|
|||||||
fill: color,
|
fill: color,
|
||||||
width: 10,
|
width: 10,
|
||||||
height: 10,
|
height: 10,
|
||||||
transformsEnabled: false
|
transformsEnabled: "position",
|
||||||
|
listening : false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@@ -102,7 +101,7 @@
|
|||||||
// _context.beginPath();
|
// _context.beginPath();
|
||||||
// _context.rect(0, 0, 10, 10);
|
// _context.rect(0, 0, 10, 10);
|
||||||
// _context.closePath();
|
// _context.closePath();
|
||||||
// _context.fillStyle = 'red';
|
// _context.fillStyle = color;
|
||||||
// _context.fill();
|
// _context.fill();
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
@@ -114,7 +113,7 @@
|
|||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.rect(0, 0, 10, 10);
|
context.rect(0, 0, 10, 10);
|
||||||
context.fillStyle = 'red';
|
context.fillStyle = color;
|
||||||
context.fill();
|
context.fill();
|
||||||
context.closePath();
|
context.closePath();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ suite('Sprite', function() {
|
|||||||
};
|
};
|
||||||
imageObj.src = 'assets/scorpion-sprite.png';
|
imageObj.src = 'assets/scorpion-sprite.png';
|
||||||
});
|
});
|
||||||
test("can change frame rate on fly", function(done){
|
test('can change frame rate on fly', function(done){
|
||||||
var imageObj = new Image();
|
var imageObj = new Image();
|
||||||
imageObj.onload = function() {
|
imageObj.onload = function() {
|
||||||
var stage = addStage();
|
var stage = addStage();
|
||||||
@@ -118,6 +118,7 @@ suite('Sprite', function() {
|
|||||||
sprite.frameRate(52);
|
sprite.frameRate(52);
|
||||||
assert.equal(sprite.anim.isRunning(), true);
|
assert.equal(sprite.anim.isRunning(), true);
|
||||||
// for this moment should tick more than 2 times
|
// for this moment should tick more than 2 times
|
||||||
|
// make sure that sprite is not restating after set frame rate
|
||||||
assert.equal(sprite.frameIndex() > 2, true);
|
assert.equal(sprite.frameIndex() > 2, true);
|
||||||
done();
|
done();
|
||||||
}, 68);
|
}, 68);
|
||||||
|
|||||||
Reference in New Issue
Block a user