add point size
This commit is contained in:
@@ -61,7 +61,14 @@ define(
|
|||||||
points.forEach(function(p, i) {
|
points.forEach(function(p, i) {
|
||||||
lang.extend(controls[i], p);
|
lang.extend(controls[i], p);
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
controls[i].type = mode == 'rotate' && i <= 4 ? 'cpoint' : 'point';
|
if (mode == 'rotate' && i <= 4) {
|
||||||
|
controls[i].type = 'cpoint';
|
||||||
|
controls[i].size = 3;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
controls[i].type = 'point';
|
||||||
|
controls[i].size = 6;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -23,11 +23,12 @@ define(
|
|||||||
* @param {Object} 矩形区域
|
* @param {Object} 矩形区域
|
||||||
*/
|
*/
|
||||||
getRect: function(shape) {
|
getRect: function(shape) {
|
||||||
|
var size = shape.size || POINT_SIZE;
|
||||||
return {
|
return {
|
||||||
x: shape.x - POINT_SIZE,
|
x: shape.x - size,
|
||||||
y: shape.y - POINT_SIZE,
|
y: shape.y - size,
|
||||||
width: 2 * POINT_SIZE,
|
width: 2 * size,
|
||||||
height: 2 * POINT_SIZE
|
height: 2 * size
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -40,7 +41,8 @@ define(
|
|||||||
* @param {boolean} 是否
|
* @param {boolean} 是否
|
||||||
*/
|
*/
|
||||||
isIn: function(shape, x, y) {
|
isIn: function(shape, x, y) {
|
||||||
return Math.pow(shape.x - x, 2) + Math.pow(shape.y - y, 2) <= Math.pow(POINT_SIZE * 2, 2);
|
var size = shape.size || POINT_SIZE;
|
||||||
|
return Math.pow(shape.x - x, 2) + Math.pow(shape.y - y, 2) <= Math.pow(size * 2, 2);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -50,12 +52,12 @@ define(
|
|||||||
* @param {Object} shape shape数据
|
* @param {Object} shape shape数据
|
||||||
*/
|
*/
|
||||||
draw: function(ctx, shape) {
|
draw: function(ctx, shape) {
|
||||||
|
var size = shape.size || POINT_SIZE;
|
||||||
var x = Math.round(shape.x);
|
var x = Math.round(shape.x);
|
||||||
var y = Math.round(shape.y);
|
var y = Math.round(shape.y);
|
||||||
|
|
||||||
ctx.moveTo(x + POINT_SIZE, y);
|
ctx.moveTo(x + size, y);
|
||||||
ctx.arc(x, y, POINT_SIZE, 0, Math.PI * 2, true);
|
ctx.arc(x, y, size, 0, Math.PI * 2, true);
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,11 +23,12 @@ define(
|
|||||||
* @param {Object} 矩形区域
|
* @param {Object} 矩形区域
|
||||||
*/
|
*/
|
||||||
getRect: function(shape) {
|
getRect: function(shape) {
|
||||||
|
var size = shape.size || POINT_SIZE;
|
||||||
return {
|
return {
|
||||||
x: shape.x - POINT_SIZE / 2 ,
|
x: shape.x - size / 2 ,
|
||||||
y: shape.y - POINT_SIZE / 2,
|
y: shape.y - size / 2,
|
||||||
width: POINT_SIZE,
|
width: size,
|
||||||
height: POINT_SIZE
|
height: size
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -40,8 +41,9 @@ define(
|
|||||||
* @param {boolean} 是否
|
* @param {boolean} 是否
|
||||||
*/
|
*/
|
||||||
isIn: function(shape, x, y) {
|
isIn: function(shape, x, y) {
|
||||||
var w = POINT_SIZE;
|
var size = shape.size || POINT_SIZE;
|
||||||
var h = POINT_SIZE;
|
var w = size;
|
||||||
|
var h = size;
|
||||||
return x <= shape.x + w
|
return x <= shape.x + w
|
||||||
&& x >= shape.x - w
|
&& x >= shape.x - w
|
||||||
&& y <= shape.y + h
|
&& y <= shape.y + h
|
||||||
@@ -58,8 +60,9 @@ define(
|
|||||||
|
|
||||||
var x = Math.round(shape.x);
|
var x = Math.round(shape.x);
|
||||||
var y = Math.round(shape.y);
|
var y = Math.round(shape.y);
|
||||||
var w = POINT_SIZE / 2;
|
var size = shape.size || POINT_SIZE;
|
||||||
var h = POINT_SIZE / 2;
|
var w = size / 2;
|
||||||
|
var h = size / 2;
|
||||||
ctx.moveTo(x - w, y - h);
|
ctx.moveTo(x - w, y - h);
|
||||||
ctx.lineTo(x + w, y - h);
|
ctx.lineTo(x + w, y - h);
|
||||||
ctx.lineTo(x + w, y + h);
|
ctx.lineTo(x + w, y + h);
|
||||||
|
|||||||
Reference in New Issue
Block a user