|
@@ -40,7 +40,6 @@ export class SImageItem extends SObjectItem {
|
|
* 构造函数
|
|
* 构造函数
|
|
*
|
|
*
|
|
* @param parent 指向父Item
|
|
* @param parent 指向父Item
|
|
- * @param str 文本内容
|
|
|
|
*/
|
|
*/
|
|
constructor(parent: SGraphItem | null) {
|
|
constructor(parent: SGraphItem | null) {
|
|
super(parent);
|
|
super(parent);
|
|
@@ -53,8 +52,8 @@ export class SImageItem extends SObjectItem {
|
|
*/
|
|
*/
|
|
boundingRect(): SRect {
|
|
boundingRect(): SRect {
|
|
return new SRect(
|
|
return new SRect(
|
|
- 0,
|
|
|
|
- 0,
|
|
|
|
|
|
+ -this.width / 2,
|
|
|
|
+ -this.height / 2,
|
|
this.width,
|
|
this.width,
|
|
this.height
|
|
this.height
|
|
);
|
|
);
|
|
@@ -66,7 +65,7 @@ export class SImageItem extends SObjectItem {
|
|
* @param oldSize 改之前的大小
|
|
* @param oldSize 改之前的大小
|
|
* @param newSize 改之后大小
|
|
* @param newSize 改之后大小
|
|
* */
|
|
* */
|
|
- protected onResize(oldSize: SSize, newSize: SSize) {
|
|
|
|
|
|
+ protected onResize(oldSize: SSize, newSize: SSize): void {
|
|
this.update();
|
|
this.update();
|
|
} // Function onResize()
|
|
} // Function onResize()
|
|
|
|
|
|
@@ -78,15 +77,17 @@ export class SImageItem extends SObjectItem {
|
|
onDraw(painter: SPainter): void {
|
|
onDraw(painter: SPainter): void {
|
|
if (this.img) {
|
|
if (this.img) {
|
|
// 要绘制图片的宽度
|
|
// 要绘制图片的宽度
|
|
- let width: number = 0;
|
|
|
|
|
|
+ let width = 0;
|
|
// 要绘制图片的宽度
|
|
// 要绘制图片的宽度
|
|
- let height: number = 0;
|
|
|
|
|
|
+ let height = 0;
|
|
// 图片item的宽高比
|
|
// 图片item的宽高比
|
|
let itemAspectRatio: number = this.width / this.height;
|
|
let itemAspectRatio: number = this.width / this.height;
|
|
// 原始图片的宽高比
|
|
// 原始图片的宽高比
|
|
- let imgAspectRatio: number = (this.img.width as number) / (this.img.height as number);
|
|
|
|
|
|
+ let imgAspectRatio: number =
|
|
|
|
+ (this.img.width as number) / (this.img.height as number);
|
|
// 原始图片的高宽比
|
|
// 原始图片的高宽比
|
|
- let imgHwRatio: number = (this.img.height as number) / (this.img.width as number);
|
|
|
|
|
|
+ let imgHwRatio: number =
|
|
|
|
+ (this.img.height as number) / (this.img.width as number);
|
|
if (this.showType == SImageShowType.Full) {
|
|
if (this.showType == SImageShowType.Full) {
|
|
width = this.width;
|
|
width = this.width;
|
|
height = this.height;
|
|
height = this.height;
|
|
@@ -102,13 +103,7 @@ export class SImageItem extends SObjectItem {
|
|
height = this.height;
|
|
height = this.height;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- painter.drawImage(
|
|
|
|
- this.img,
|
|
|
|
- 0,
|
|
|
|
- 0,
|
|
|
|
- width,
|
|
|
|
- height
|
|
|
|
- );
|
|
|
|
|
|
+ painter.drawImage(this.img, -width / 2, -height / 2, width, height);
|
|
}
|
|
}
|
|
} // Function onDraw()
|
|
} // Function onDraw()
|
|
-}// Class SImageItem
|
|
|
|
|
|
+} // Class SImageItem
|