@@ -48,8 +48,8 @@ function setAxis(options) {
|
||||
|
||||
function getPointCoordinate(p) {
|
||||
let scale = this.render.camera.scale;
|
||||
let x = Math.round((p.x - this.axis.x) / scale);
|
||||
let y = Math.round(-(p.y - this.axis.y) / scale);
|
||||
let x = Math.floor((p.x - this.axis.x) / scale);
|
||||
let y = Math.floor(-(p.y - this.axis.y) / scale);
|
||||
return {x, y};
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,6 @@ export default class ShapesGroup {
|
||||
|
||||
this.editor.fontLayer.refresh();
|
||||
this.editor.coverLayer.move(mx, my);
|
||||
this.editor.coverLayer.refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -121,7 +121,4 @@ export default function moveTransform(camera, fixX, fixY, enableSorption) {
|
||||
],
|
||||
1, 1, x, y
|
||||
);
|
||||
|
||||
coverLayer.refresh();
|
||||
|
||||
}
|
||||
|
||||
@@ -59,6 +59,4 @@ export default function rotateTransform(point, camera) {
|
||||
boundCenter.x = (boundShape.points[0].x + boundShape.points[2].x) / 2;
|
||||
boundCenter.y = (boundShape.points[0].y + boundShape.points[2].y) / 2;
|
||||
|
||||
|
||||
coverLayer.refresh();
|
||||
}
|
||||
|
||||
@@ -61,6 +61,5 @@ export default function scaleTransform(point, camera) {
|
||||
);
|
||||
pathAdjust(points, 1, 1, matrix[0], matrix[1]);
|
||||
boundShape.points = points;
|
||||
coverLayer.refresh();
|
||||
|
||||
}
|
||||
|
||||
@@ -184,10 +184,6 @@ export default {
|
||||
drag(e) {
|
||||
let camera = this.render.camera;
|
||||
if (this.curPoint) {
|
||||
if (!this.tipTextPoint) {
|
||||
this.tipTextPoint = this.coverLayer.addShape('text',
|
||||
Object.assign({text: ''}, this.options.tipText));
|
||||
}
|
||||
let current = this.curPoint;
|
||||
let reserved = this.curShape.points[current.pointId];
|
||||
|
||||
@@ -218,31 +214,39 @@ export default {
|
||||
|
||||
current.point.x = current.x;
|
||||
current.point.y = current.y;
|
||||
let coord = this.getPointCoordinate(current);
|
||||
this.tipTextPoint.text = coord.x + ',' + coord.y;
|
||||
this.tipTextPoint.x = current.x + 16;
|
||||
this.tipTextPoint.y = current.y + 10;
|
||||
this.coverLayer.refresh();
|
||||
// 更新tip text
|
||||
{
|
||||
if (!this.tipTextPoint) {
|
||||
this.tipTextPoint = this.coverLayer.addShape('text',
|
||||
Object.assign({text: ''}, this.options.tipText));
|
||||
}
|
||||
let coord = this.getPointCoordinate(current);
|
||||
this.tipTextPoint.text = coord.x + ',' + coord.y;
|
||||
this.tipTextPoint.x = e.x + 16;
|
||||
this.tipTextPoint.y = e.y + 16;
|
||||
this.coverLayer.refresh();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
dragend() {
|
||||
// remove tip text
|
||||
if (this.tipTextPoint) {
|
||||
this.coverLayer.removeShape(this.tipTextPoint);
|
||||
this.tipTextPoint = null;
|
||||
this.coverLayer.refresh();
|
||||
}
|
||||
|
||||
if (this.curPoint) {
|
||||
let reserved = this.curShape.points[this.curPoint.pointId];
|
||||
reserved.x = this.curPoint.x;
|
||||
reserved.y = this.curPoint.y;
|
||||
|
||||
if (this.sorption.isEnable()) {
|
||||
this.sorption.clear();
|
||||
}
|
||||
|
||||
this.fontLayer.refresh();
|
||||
}
|
||||
|
||||
this.fire('change');
|
||||
},
|
||||
|
||||
|
||||
@@ -71,6 +71,41 @@ function onContextMenu(e) {
|
||||
}
|
||||
}
|
||||
|
||||
function getTipTextPointCoord(pos, boundPoints) {
|
||||
switch (pos) {
|
||||
case 1:
|
||||
return boundPoints[0];
|
||||
case 2:
|
||||
return boundPoints[1];
|
||||
case 3:
|
||||
return boundPoints[2];
|
||||
case 4:
|
||||
return boundPoints[3];
|
||||
case 5:
|
||||
return {
|
||||
x: (boundPoints[0].x + boundPoints[1].x) / 2,
|
||||
y: (boundPoints[0].y + boundPoints[1].y) / 2
|
||||
};
|
||||
case 6:
|
||||
return {
|
||||
x: (boundPoints[1].x + boundPoints[2].x) / 2,
|
||||
y: (boundPoints[1].y + boundPoints[2].y) / 2
|
||||
};
|
||||
case 7:
|
||||
return {
|
||||
x: (boundPoints[2].x + boundPoints[3].x) / 2,
|
||||
y: (boundPoints[2].y + boundPoints[3].y) / 2
|
||||
};
|
||||
case 8:
|
||||
return {
|
||||
x: (boundPoints[0].x + boundPoints[3].x) / 2,
|
||||
y: (boundPoints[0].y + boundPoints[3].y) / 2
|
||||
};
|
||||
}
|
||||
|
||||
// 右下角
|
||||
return boundPoints[3];
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
@@ -153,11 +188,34 @@ export default {
|
||||
drag(e) {
|
||||
if (this.currentGroup) {
|
||||
this.currentGroup.transform(this.currentPoint, this.render.camera, e);
|
||||
|
||||
// tip text point
|
||||
if (this.currentGroup.mode === 'scale' || this.currentGroup.mode === 'rotate') {
|
||||
if (!this.tipTextPoint) {
|
||||
this.tipTextPoint = this.coverLayer.addShape('text',
|
||||
Object.assign({text: ''}, this.options.tipText));
|
||||
}
|
||||
|
||||
let currentPointCoord = getTipTextPointCoord(
|
||||
this.currentPoint ? this.currentPoint.pos : 9,
|
||||
this.coverLayer.getShape('bound').points);
|
||||
let coord = this.getPointCoordinate(currentPointCoord);
|
||||
this.tipTextPoint.text = coord.x + ',' + coord.y;
|
||||
this.tipTextPoint.x = e.x + 16;
|
||||
this.tipTextPoint.y = e.y + 16;
|
||||
}
|
||||
this.coverLayer.refresh();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
dragend(e) {
|
||||
// remove tip text
|
||||
if (this.tipTextPoint) {
|
||||
this.coverLayer.removeShape(this.tipTextPoint);
|
||||
this.tipTextPoint = null;
|
||||
this.coverLayer.refresh();
|
||||
}
|
||||
|
||||
if (this.currentPoint) {
|
||||
this.currentGroup.finishTransform(this.currentPoint, this.render.camera, e);
|
||||
@@ -247,6 +305,7 @@ export default {
|
||||
// 移动
|
||||
if (stepMap[e.key]) {
|
||||
this.currentGroup.move(stepMap[e.key][0], stepMap[e.key][1]);
|
||||
this.coverLayer.refresh();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -22,12 +22,14 @@ export default {
|
||||
// 辅助线
|
||||
referenceline: {
|
||||
style: {
|
||||
strokeColor: '#746AFE'
|
||||
strokeColor: '#746AFE',
|
||||
fillColor: 'blue'
|
||||
}
|
||||
},
|
||||
|
||||
// 提示文本
|
||||
tipText: {
|
||||
id: 'tip-text',
|
||||
fillColor: 'blue',
|
||||
x: 30,
|
||||
y: 36
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
import core from 'fonteditor-core/main';
|
||||
import resolvettf from './util/resolvettf';
|
||||
import config from 'fonteditor-core/ttf/data/default';
|
||||
import exportRender from '../template/export-render';
|
||||
import download from './util/download';
|
||||
import JSZip from 'JSZip';
|
||||
|
||||
Reference in New Issue
Block a user