Skip to content

Commit

Permalink
little optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
erik168 committed Jun 24, 2014
1 parent be24850 commit 1770459
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/util/shape/Chain.js
Expand Up @@ -19,6 +19,7 @@ define(function (require) {

Chain.prototype = {
type : 'chain',

/**
* 画刷
* @param ctx 画布句柄
Expand Down
1 change: 1 addition & 0 deletions src/util/shape/Chord.js
Expand Up @@ -43,6 +43,7 @@ define(function (require) {

ChordShape.prototype = {
type : 'chord',

// center, source0, source1, target0, target1, r
buildPath : function (ctx, style) {
var PI2 = Math.PI * 2;
Expand Down
12 changes: 3 additions & 9 deletions src/util/shape/Cross.js
Expand Up @@ -40,6 +40,7 @@ define(function (require) {

Cross.prototype = {
type : 'cross',

/**
* 创建矩形路径
* @param {Context2D} ctx Canvas 2D上下文
Expand All @@ -55,7 +56,6 @@ define(function (require) {
style.yStart = rect.y;
style.yEnd = rect.y + rect.height;
LineShape.prototype.buildPath(ctx, style);
return;
},

/**
Expand All @@ -70,16 +70,10 @@ define(function (require) {
// 快速预判并保留判断矩形
var rect = this.style.__rect = this.style.__rect
|| this.getRect(this.style);
if (x >= rect.x
return x >= rect.x
&& x <= (rect.x + rect.width)
&& y >= rect.y
&& y <= (rect.y + rect.height)
) {
// 矩形内
return true;
}

return false;
&& y <= (rect.y + rect.height);
}
};

Expand Down

0 comments on commit 1770459

Please sign in to comment.