|
@@ -879,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)
|
|
@@ -901,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*coordinate.ratio, -img.height / 2*coordinate.ratio)
|
|
|
+ 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*coordinate.ratio, -geometry.ratio * geometry.height / 2*coordinate.ratio,geometry.ratio * geometry.width / 2*coordinate.ratio, geometry.ratio * geometry.height / 2*coordinate.ratio)
|
|
|
+ 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*coordinate.ratio, -geometry.ratio * geometry.height / 2*coordinate.ratio,geometry.ratio * geometry.width / 2*coordinate.ratio, geometry.ratio * geometry.height / 2*coordinate.ratio)
|
|
|
+ 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)
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -924,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) {
|
|
@@ -932,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)
|
|
|
}
|
|
|
}
|
|
|
|