123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import { SImageItem, SGraphItem } from "@persagy-web/graph"
- import { SPainter, SColor } from "@persagy-web/draw";
- import { SMouseEvent } from "@persagy-web/base/";
- export class MarkItem extends SImageItem {
-
- data: any;
-
- constructor(parent: SGraphItem | null, data: any) {
- super(parent);
- this.data = data;
- this.width = this.data.width;
- this.height = this.data.height;
-
- this.origin.x = (this.data.width / 2);
- this.origin.y = (this.data.height / 2)
- this.zOrder = 1000;
-
- this.isTransform = false;
- this.url = data.url;
- this.moveTo(this.data.x, this.data.y);
- }
-
- onDraw(painter: SPainter) {
-
-
- if (this.isLoadOver && this.img) {
- painter.translate(-this.origin.x, -this.origin.y);
- if (this.isLoadOver) {
-
- painter.drawImage(this.img, 0, 0, this.imgWidth, this.imgHeight);
- }
-
- if (this.selected) {
- painter.shadow.shadowBlur = 10;
- painter.shadow.shadowColor = new SColor(`#00000033`);
- painter.shadow.shadowOffsetX = 5;
- painter.shadow.shadowOffsetY = 5;
- } else {
- painter.shadow.shadowColor = SColor.Transparent;
- }
- painter.pen.lineWidth = this.lineWidth;
- painter.pen.color = this.strokeColor;
- painter.brush.color = SColor.Transparent;
- painter.drawRect(0, 0, this.width, this.height);
- };
- }
-
- onMouseEnter(event: SMouseEvent): boolean {
- super.onMouseEnter(event)
- this.$emit("onMouseEnter", event);
- return true
- }
-
- onMouseLeave(event: SMouseEvent): boolean {
- super.onMouseLeave(event);
- this.$emit("onMouseLeave", event);
- return true
- }
-
- onMouseDown(event: SMouseEvent) {
- this.$emit("click", event);
- this.$emit('onMouseDown', event)
- return true;
- }
- }
|