fix line render

This commit is contained in:
mkwiser 2014-09-11 00:20:26 +08:00
parent 9c1ea7566d
commit 599cf0c9a2
5 changed files with 53 additions and 16 deletions

View File

@ -25,7 +25,9 @@ define(
*/
down: function(e) {
var render = this.render;
var camera = this.render.camera;
var result = render.getLayer('cover').getShapeIn(e);
if(result) {
if (this.currentGroup) {
this.currentPoint = lang.clone(result[0]);
@ -48,7 +50,17 @@ define(
}
this.currentGroup = new ShapeGroup(shape, render);
}
// 框选模式
else {
this.selectionBox = {
type: 'dashedrect',
x: camera.x,
y: camera.y
};
render.getLayer('cover').addShape(this.selectionBox);
}
}
},
/**
@ -65,6 +77,12 @@ define(
this.currentGroup.move(camera.mx, camera.my);
}
}
// 框选模式
else {
this.selectionBox.width = camera.x - this.selectionBox.x;
this.selectionBox.height = camera.y - this.selectionBox.y;
render.getLayer('cover').refresh();
}
},
/**
@ -77,6 +95,11 @@ define(
this.currentPoint = null;
}
}
else if(this.selectionBox) {
var coverLayer = this.render.getLayer('cover');
coverLayer.clearShapes()
coverLayer.refresh();
}
},
/**

View File

@ -65,8 +65,6 @@ define(
ctx.translate(0.5, 0.5);
//ctx.translate(-shape.x, -shape.y);
// 横轴线
for(var i = y; i < yMax; i += gap) {
ctx.moveTo(0, i);
@ -114,7 +112,7 @@ define(
// em 框
ctx.beginPath();
ctx.strokeStyle = shape.emColor || '#999';
ctx.strokeStyle = shape.emColor || '#000';
var unitsPerEm = Math.round(shape.unitsPerEm);
ctx.moveTo(x, y - unitsPerEm);

View File

@ -50,8 +50,16 @@ define(
* @param {Object} shape shape数据
*/
draw: function(ctx, shape) {
ctx.moveTo(shape.x + POINT_SIZE, shape.y);
ctx.arc(shape.x, shape.y, POINT_SIZE, 0, Math.PI * 2, true);
ctx.translate(0.5, 0.5);
var x = Math.round(shape.x);
var y = Math.round(shape.y);
ctx.moveTo(x + POINT_SIZE, y);
ctx.arc(x, y, POINT_SIZE, 0, Math.PI * 2, true);
ctx.translate(-0.5, -0.5);
}
};

View File

@ -50,12 +50,16 @@ define(
* @param {Object} shape shape数据
*/
draw: function(ctx, shape) {
var w = shape.width;
var h = shape.height;
dashedLineTo(ctx, shape.x, shape.y, shape.x + w, shape.y);
dashedLineTo(ctx, shape.x + w, shape.y, shape.x + w, shape.y + h);
dashedLineTo(ctx, shape.x + w, shape.y + h, shape.x, shape.y + h);
dashedLineTo(ctx, shape.x, shape.y + h, shape.x, shape.y);
ctx.translate(0.5, 0.5);
var x = Math.round(shape.x);
var y = Math.round(shape.y);
var w = Math.round(shape.width);
var h = Math.round(shape.height);
dashedLineTo(ctx, x, y, x + w, y);
dashedLineTo(ctx, x + w, y, x + w, y + h);
dashedLineTo(ctx, x + w, y + h, x, y + h);
dashedLineTo(ctx, x, y + h, x, y);
ctx.translate(-0.5, -0.5);
}
};

View File

@ -55,13 +55,17 @@ define(
* @param {Object} shape shape数据
*/
draw: function(ctx, shape) {
ctx.translate(0.5, 0.5);
var x = Math.round(shape.x);
var y = Math.round(shape.y);
var w = POINT_SIZE / 2;
var h = POINT_SIZE / 2;
ctx.moveTo(shape.x - w, shape.y - h);
ctx.lineTo(shape.x + w, shape.y - h);
ctx.lineTo(shape.x + w, shape.y + h);
ctx.lineTo(shape.x - w, shape.y + h);
ctx.lineTo(shape.x - w, shape.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);
ctx.translate(-0.5, -0.5);
}
};