|
@@ -250,7 +250,8 @@ export default class Draw {
|
|
|
// this.context.fillText(geometry.value, fontStart1.newpoint2.x, fontStart1.newpoint2.y)
|
|
|
// }
|
|
|
//let count = (2*(i-(fontInfo.textValues.length-1))+1)
|
|
|
- let count = 1 * (fontInfo.textValues.length-i)
|
|
|
+ //let count = 1 * (fontInfo.textValues.length-i)
|
|
|
+ let count = i+1
|
|
|
count = 2* count - fontInfo.textValues.length
|
|
|
this.context.fillText(fontInfo.textValues[i], pt.x - fontWidth1/2, pt.y + dy*count)
|
|
|
}
|
|
@@ -292,7 +293,7 @@ export default class Draw {
|
|
|
drawCell(geometry,width,height){
|
|
|
|
|
|
this.context.save()
|
|
|
- this.context.lineWidth = Style.Table.lineWidth * coordinate.ratio
|
|
|
+ this.context.lineWidth = Style.Table.lineWidth
|
|
|
this.context.strokeStyle = Style.Table.strokeStyle
|
|
|
this.context.fillStyle = Style.Table.fillStyle
|
|
|
|
|
@@ -321,16 +322,13 @@ export default class Draw {
|
|
|
this.context.translate(width, height)
|
|
|
this.context.beginPath()
|
|
|
this.context.moveTo(0,0)
|
|
|
- this.context.lineTo(geometry.width,0)
|
|
|
- this.context.lineTo(geometry.width,geometry.height)
|
|
|
- this.context.lineTo(0,geometry.height)
|
|
|
+ this.context.lineTo(geometry.width* coordinate.ratio,0)
|
|
|
+ this.context.lineTo(geometry.width* coordinate.ratio,geometry.height* coordinate.ratio)
|
|
|
+ this.context.lineTo(0,geometry.height* coordinate.ratio)
|
|
|
this.context.closePath();
|
|
|
this.context.stroke()
|
|
|
|
|
|
- const defaultHeight = 24;
|
|
|
- const defaultWidth = 156;
|
|
|
-
|
|
|
- this.context.font = '12px Microsoft YaHei'
|
|
|
+ this.context.font = 12*coordinate.ratio+'px Microsoft YaHei'
|
|
|
let fontWidth = this.context.measureText(geometry.value).width
|
|
|
//如果是数字或者字母
|
|
|
const patt = /[A-z0-9]/g;
|
|
@@ -342,12 +340,12 @@ export default class Draw {
|
|
|
|
|
|
|
|
|
//let rowCount = Math.ceil(geometry.height/defaultHeight) //分几行写
|
|
|
- let rowCount = Math.ceil(fontWidth/geometry.width) //分几行写,根据要写的文字的长度来判断
|
|
|
+ let rowCount = Math.ceil(fontWidth/(geometry.width* coordinate.ratio)) //分几行写,根据要写的文字的长度来判断
|
|
|
|
|
|
if(rowCount == 1){
|
|
|
this.context.textAlign = "center";
|
|
|
this.context.textBaseline = "middle";
|
|
|
- this.context.fillText(geometry.value, geometry.width/2, geometry.height/2)
|
|
|
+ this.context.fillText(geometry.value, geometry.width/2* coordinate.ratio, geometry.height/2* coordinate.ratio)
|
|
|
}
|
|
|
//大于1行
|
|
|
else{
|
|
@@ -356,7 +354,7 @@ export default class Draw {
|
|
|
this.context.textAlign = "left";
|
|
|
for(let i=0;i<rowCount;++i){
|
|
|
const value = geometry.value.substr(i*rowFontCount,rowFontCount)
|
|
|
- this.context.fillText(value, geometry.width/2 - rowWidth/2, 18+18*i)
|
|
|
+ this.context.fillText(value, (geometry.width/2* coordinate.ratio- rowWidth/2), (18+18*i)* coordinate.ratio)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -460,7 +458,7 @@ export default class Draw {
|
|
|
|
|
|
drawCircleGeo(geometry)
|
|
|
{
|
|
|
- let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom
|
|
|
+ let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom * coordinate.ratio
|
|
|
const twoPi = Math.PI * 2
|
|
|
const pt = coordinate.getScreenXY(geometry.center)
|
|
|
|
|
@@ -543,7 +541,7 @@ export default class Draw {
|
|
|
|
|
|
drawIcon(geometry)
|
|
|
{
|
|
|
- let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom
|
|
|
+ let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom * coordinate.ratio
|
|
|
const twoPi = Math.PI * 2
|
|
|
const pt = coordinate.getScreenXY(geometry.center)
|
|
|
|
|
@@ -626,7 +624,7 @@ export default class Draw {
|
|
|
this.setCanvasStyle(Style.Font)
|
|
|
|
|
|
let fontSize = Math.ceil(radius * 14/20);
|
|
|
- this.context.font = fontSize + Style.Font.font;
|
|
|
+ this.context.font = fontSize + Style.Font.font
|
|
|
let center = coordinate.getScreenXY(geometry.center);
|
|
|
this.context.fillText(geometry.value, center.x , center.y)
|
|
|
this.context.restore()
|
|
@@ -842,17 +840,17 @@ export default class Draw {
|
|
|
this.context.strokeStyle = Style.Focus.Title.strokeStyle
|
|
|
this.context.fillStyle = Style.Focus.Title.fillStyle
|
|
|
}
|
|
|
- //let pt = {}
|
|
|
- //pt.x = (this.context.canvas.width - this.context.measureText(geometry.value).width)/2
|
|
|
- this.context.fillText(geometry.value, this.context.canvas.width/2, geometry.height)
|
|
|
+ //this.context.font = `400 ${geometry.fontSize}px Microsoft YaHei`
|
|
|
+ this.context.font = `${24*coordinate.ratio}px Microsoft YaHei`
|
|
|
+ this.context.fillText(geometry.value, this.context.canvas.width/2, geometry.height*coordinate.ratio)
|
|
|
this.context.restore()
|
|
|
}
|
|
|
|
|
|
drawBgImage(geometry){
|
|
|
if(geometry.src != null){
|
|
|
const pt = {
|
|
|
- x:80,
|
|
|
- y:150
|
|
|
+ x:80*coordinate.ratio,
|
|
|
+ y:150*coordinate.ratio
|
|
|
}
|
|
|
|
|
|
this.context.save()
|
|
@@ -862,16 +860,16 @@ export default class Draw {
|
|
|
img.src = geometry.src;
|
|
|
img.crossOrigin=""
|
|
|
img.onload = function () {
|
|
|
- this.context.drawImage(img, pt.x, pt.y, img.width, img.height)
|
|
|
+ this.context.drawImage(img, pt.x, pt.y, img.width*coordinate.ratio, img.height*coordinate.ratio)
|
|
|
}.bind(this)
|
|
|
geometry.image = img;
|
|
|
}
|
|
|
else{
|
|
|
if(geometry.hasOwnProperty('width')){
|
|
|
- this.context.drawImage(geometry.image, pt.x, pt.y, geometry.width, geometry.height)
|
|
|
+ this.context.drawImage(geometry.image, pt.x, pt.y, geometry.width*coordinate.ratio, geometry.height*coordinate.ratio)
|
|
|
}
|
|
|
else{
|
|
|
- this.context.drawImage(geometry.image, pt.x, pt.y, geometry.image.width, geometry.image.height)
|
|
|
+ this.context.drawImage(geometry.image, pt.x, pt.y, geometry.image.width*coordinate.ratio, geometry.image.height*coordinate.ratio)
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -881,20 +879,14 @@ export default class Draw {
|
|
|
|
|
|
drawCustomImage(geometry){
|
|
|
if(geometry.url != null){
|
|
|
- // const focusItem = stateService.getFocusItem();
|
|
|
- // if (focusItem && focusItem.type == VectorType.CustomImage) {
|
|
|
- // if (geometry.vectorId == focusItem.vectorId) {
|
|
|
-
|
|
|
- // }
|
|
|
- // }
|
|
|
const pt = coordinate.getScreenXY(geometry.center)
|
|
|
this.context.save()
|
|
|
|
|
|
this.context.translate(pt.x, pt.y)
|
|
|
this.context.scale(geometry.scale,geometry.scale)
|
|
|
- this.context.translate(-1*geometry.ratio*geometry.width/4, -1*geometry.ratio*geometry.height/4)
|
|
|
+ this.context.translate(-1*geometry.ratio*geometry.width/2, -1*geometry.ratio*geometry.height/2)
|
|
|
this.context.rotate((geometry.angle / 180) * Math.PI)
|
|
|
- this.context.translate(geometry.ratio*geometry.width/4, geometry.ratio*geometry.height/4)
|
|
|
+ this.context.translate(geometry.ratio*geometry.width/2, geometry.ratio*geometry.height/2)
|
|
|
|
|
|
|
|
|
if(geometry.image == null)
|
|
@@ -903,19 +895,16 @@ export default class Draw {
|
|
|
img.src = geometry.url;
|
|
|
img.crossOrigin=""
|
|
|
img.onload = function () {
|
|
|
- //this.context.drawImage(img, pt.x-img.width/2, pt.y-img.height/2, img.width, img.height)
|
|
|
- this.context.drawImage(img, -img.width / 2, -img.height / 2)
|
|
|
+ this.context.drawImage(img, -img.width*coordinate.ratio, -img.height*coordinate.ratio)
|
|
|
}.bind(this)
|
|
|
geometry.image = img;
|
|
|
}
|
|
|
else{
|
|
|
if(geometry.hasOwnProperty('width')){
|
|
|
- //this.context.drawImage(geometry.image, pt.x-geometry.width/2, pt.y-geometry.height/2, geometry.width, geometry.height)
|
|
|
- this.context.drawImage(geometry.image, -geometry.ratio * geometry.width / 2, -geometry.ratio * geometry.height / 2,geometry.ratio * geometry.width / 2, geometry.ratio * geometry.height / 2)
|
|
|
+ this.context.drawImage(geometry.image, -geometry.ratio * geometry.width*coordinate.ratio, -geometry.ratio * geometry.height*coordinate.ratio,geometry.ratio * geometry.width*coordinate.ratio, geometry.ratio * geometry.height*coordinate.ratio)
|
|
|
}
|
|
|
else{
|
|
|
- //this.context.drawImage(geometry.image, pt.x-geometry.width/2, pt.y-geometry.height/2, geometry.image.width, geometry.image.height)
|
|
|
- this.context.drawImage(geometry.image, -geometry.ratio * geometry.width / 2, -geometry.ratio * geometry.height / 2,geometry.ratio * geometry.width / 2, geometry.ratio * geometry.height / 2)
|
|
|
+ this.context.drawImage(geometry.image, -geometry.ratio * geometry.width*coordinate.ratio, -geometry.ratio * geometry.height*coordinate.ratio,geometry.ratio * geometry.width*coordinate.ratio, geometry.ratio * geometry.height*coordinate.ratio)
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -926,7 +915,7 @@ export default class Draw {
|
|
|
this.context.lineWidth = 2/geometry.scale;
|
|
|
this.context.strokeStyle = Style.Select.Tag.strokeStyle
|
|
|
this.context.fillStyle = Style.Select.Tag.fillStyle
|
|
|
- this.context.strokeRect( -geometry.ratio * geometry.width/2, -geometry.ratio * geometry.height/2, geometry.ratio * geometry.width/2, geometry.ratio * geometry.height/2)
|
|
|
+ this.context.strokeRect( -geometry.ratio * geometry.width, -geometry.ratio * geometry.height, geometry.ratio * geometry.width, geometry.ratio * geometry.height)
|
|
|
}
|
|
|
}
|
|
|
else if (selectItem && selectItem.type == VectorType.CustomImage) {
|
|
@@ -934,7 +923,7 @@ export default class Draw {
|
|
|
this.context.lineWidth = 2/geometry.scale;
|
|
|
this.context.strokeStyle = Style.Select.Tag.strokeStyle
|
|
|
this.context.fillStyle = Style.Select.Tag.fillStyle
|
|
|
- this.context.strokeRect( -geometry.ratio * geometry.width/2, -geometry.ratio * geometry.height/2, geometry.ratio * geometry.width/2, geometry.ratio * geometry.height/2)
|
|
|
+ this.context.strokeRect( -geometry.ratio * geometry.width, -geometry.ratio * geometry.height, geometry.ratio * geometry.width, geometry.ratio * geometry.height)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -995,7 +984,8 @@ export default class Draw {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- this.context.translate(geometry.center.x,geometry.center.y)
|
|
|
+ this.context.translate(geometry.center.x*coordinate.ratio,geometry.center.y*coordinate.ratio)
|
|
|
+ this.context.scale(coordinate.ratio,coordinate.ratio)
|
|
|
this.context.translate(16, 36)
|
|
|
this.context.rotate((geometry.angle)/180 * Math.PI)
|
|
|
this.context.translate(-16, -36)
|
|
@@ -1179,7 +1169,7 @@ export default class Draw {
|
|
|
this.context.rotate((geometry.angle / 180) * Math.PI)
|
|
|
this.context.translate(pt.x - center.x, pt.y - center.y)
|
|
|
|
|
|
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
+ this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
|
|
|
this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
|
|
|
this.context.miterLimit = 4
|
|
@@ -1286,7 +1276,7 @@ export default class Draw {
|
|
|
this.context.translate(center.x, center.y)
|
|
|
this.context.rotate((geometry.angle / 180) * Math.PI)
|
|
|
this.context.translate(pt.x - center.x, pt.y - center.y)
|
|
|
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
|
|
|
+ this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32*coordinate.ratio)
|
|
|
this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
|
|
|
|
|
|
this.context.beginPath();
|
|
@@ -1358,7 +1348,7 @@ export default class Draw {
|
|
|
this.context.translate(center.x, center.y)
|
|
|
this.context.rotate((geometry.angle / 180) * Math.PI)
|
|
|
this.context.translate(pt.x - center.x, pt.y - center.y)
|
|
|
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
+ this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
|
|
|
this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
|
|
|
this.context.beginPath();
|
|
@@ -1469,7 +1459,7 @@ export default class Draw {
|
|
|
this.context.translate(center.x, center.y)
|
|
|
this.context.rotate((geometry.angle / 180) * Math.PI)
|
|
|
this.context.translate(pt.x - center.x, pt.y - center.y)
|
|
|
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
+ this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
|
|
|
this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
|
|
|
this.context.beginPath();
|
|
@@ -1580,7 +1570,7 @@ export default class Draw {
|
|
|
this.context.translate(center.x, center.y)
|
|
|
this.context.rotate((geometry.angle / 180) * Math.PI)
|
|
|
this.context.translate(pt.x - center.x, pt.y - center.y)
|
|
|
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
+ this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
|
|
|
this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
|
|
|
this.context.beginPath();
|
|
@@ -1651,7 +1641,7 @@ export default class Draw {
|
|
|
this.context.translate(center.x, center.y)
|
|
|
this.context.rotate((geometry.angle / 180) * Math.PI)
|
|
|
this.context.translate(pt.x - center.x, pt.y - center.y)
|
|
|
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
+ this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
|
|
|
this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
|
|
|
this.context.beginPath();
|
|
@@ -1722,7 +1712,7 @@ export default class Draw {
|
|
|
this.context.translate(center.x, center.y)
|
|
|
this.context.rotate((geometry.angle / 180) * Math.PI)
|
|
|
this.context.translate(pt.x - center.x, pt.y - center.y)
|
|
|
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
+ this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
|
|
|
this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
|
|
|
this.context.beginPath();
|
|
@@ -1876,7 +1866,7 @@ export default class Draw {
|
|
|
this.context.translate(center.x, center.y)
|
|
|
this.context.rotate((geometry.angle / 180) * Math.PI)
|
|
|
this.context.translate(pt.x - center.x, pt.y - center.y)
|
|
|
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
+ this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
|
|
|
this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
|
|
|
this.context.beginPath();
|
|
@@ -1986,7 +1976,7 @@ export default class Draw {
|
|
|
this.context.translate(center.x, center.y)
|
|
|
this.context.rotate((geometry.angle / 180) * Math.PI)
|
|
|
this.context.translate(pt.x - center.x, pt.y - center.y)
|
|
|
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
+ this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom*coordinate.ratio)
|
|
|
this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
|
|
|
|
|
|
this.context.beginPath();
|