|
@@ -1,5 +1,5 @@
|
|
|
import { SObjectItem } from "./SObjectItem";
|
|
|
-import { SPainter, SRect, SSize, SColor } from "@saga-web/draw/lib";
|
|
|
+import { SPainter, SRect, SSize, SColor, SPoint } from "@saga-web/draw/lib";
|
|
|
import { SImageShowType } from "../enums/SImageShowType";
|
|
|
import { SGraphItem } from "../SGraphItem";
|
|
|
|
|
@@ -128,6 +128,7 @@ export class SImageItem extends SObjectItem {
|
|
|
}
|
|
|
this.imgWidth = width;
|
|
|
this.imgHeight = height;
|
|
|
+ this.origin = new SPoint(this.width / 2, this.height / 2);
|
|
|
} // Function computeImgSize()
|
|
|
|
|
|
/**
|
|
@@ -136,12 +137,7 @@ export class SImageItem extends SObjectItem {
|
|
|
* @return SRect
|
|
|
*/
|
|
|
boundingRect(): SRect {
|
|
|
- return new SRect(
|
|
|
- -this.width / 2,
|
|
|
- -this.height / 2,
|
|
|
- this.width,
|
|
|
- this.height
|
|
|
- );
|
|
|
+ return new SRect(-this.origin.x, -this.origin.y, this.width, this.height);
|
|
|
} // Function boundingRect()
|
|
|
|
|
|
/**
|
|
@@ -161,9 +157,10 @@ export class SImageItem extends SObjectItem {
|
|
|
* @param painter 绘画类
|
|
|
*/
|
|
|
onDraw(painter: SPainter): void {
|
|
|
+ painter.translate(-this.origin.x, -this.origin.y);
|
|
|
if (this.isLoadOver) {
|
|
|
// @ts-ignore
|
|
|
- painter.drawImage(this.img, -this.imgWidth / 2, -this.imgHeight / 2, this.imgWidth, this.imgHeight);
|
|
|
+ painter.drawImage(this.img, 0, 0, this.imgWidth, this.imgHeight);
|
|
|
}
|
|
|
if (this.selected) {
|
|
|
painter.shadow.shadowBlur = 10;
|