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