复制插件修改

This commit is contained in:
joylink_zhaoerwei 2024-01-15 16:08:34 +08:00
parent dd9c5b528a
commit 294973738c
4 changed files with 34 additions and 16 deletions

View File

@ -1068,7 +1068,7 @@ class GraphicCopyPlugin {
container;
scene;
keyListeners;
graphicKeyListenercMap;
graphicControlers;
copys;
start;
running = false;
@ -1076,7 +1076,7 @@ class GraphicCopyPlugin {
constructor(scene) {
this.scene = scene;
this.container = new Container();
this.graphicKeyListenercMap = new Map();
this.graphicControlers = [];
this.copys = [];
this.keyListeners = [];
this.keyListeners.push(new KeyListener({
@ -1132,10 +1132,11 @@ class GraphicCopyPlugin {
this.container.addChild(clone);
clone.repaint();
});
const addGraphicTypeKeyListener = this.graphicKeyListenercMap.get(app.selectedGraphics[0].type);
if (addGraphicTypeKeyListener) {
this.keyListeners.push(...addGraphicTypeKeyListener);
}
this.graphicControlers.forEach((graphicControler) => {
if (graphicControler.check()) {
this.keyListeners.push(...graphicControler.controlerList);
}
});
this.scene.canvas.on('mousemove', this.onPointerMove, this);
this.scene.canvas.on('mouseup', this.onFinish, this);
this.scene.canvas.on('rightup', this.cancle, this);
@ -1143,6 +1144,9 @@ class GraphicCopyPlugin {
this.scene.app.addKeyboardListener(kl);
});
}
addGraphicControlers(graphicControlers) {
this.graphicControlers.push(...graphicControlers);
}
clear() {
this.running = false;
this.start = undefined;

View File

@ -2,6 +2,10 @@ import { Container, FederatedPointerEvent, Point } from 'pixi.js';
import { IGraphicScene } from '../app';
import { JlGraphic } from '../core';
import { KeyListener } from './KeyboardPlugin';
interface GraphicControler {
controlerList: KeyListener[];
check: () => boolean;
}
/**
*
*/
@ -9,7 +13,7 @@ export declare class GraphicCopyPlugin {
container: Container;
scene: IGraphicScene;
keyListeners: KeyListener[];
graphicKeyListenercMap: Map<string, KeyListener[]>;
graphicControlers: GraphicControler[];
copys: JlGraphic[];
start?: Point;
running: boolean;
@ -17,9 +21,11 @@ export declare class GraphicCopyPlugin {
constructor(scene: IGraphicScene);
updateMoveLimit(limit?: 'x' | 'y'): void;
init(): void;
addGraphicControlers(graphicControlers: GraphicControler[]): void;
clear(): void;
onPointerMove(e: FederatedPointerEvent): void;
onFinish(): void;
saveCopyGraphic(): void;
cancle(): void;
}
export {};

View File

@ -1,6 +1,6 @@
{
"name": "graphic-pixi",
"version": "0.1.4",
"version": "0.1.6",
"description": "基于pixijs的图形应用、绘制应用框架",
"productName": "Graphic-pixi",
"author": "walker <shengxuqiang@joylink.club>",

View File

@ -3,6 +3,11 @@ import { IGraphicScene } from '../app';
import { JlGraphic } from '../core';
import { KeyListener } from './KeyboardPlugin';
interface GraphicControler {
controlerList: KeyListener[];
check: () => boolean;
}
/**
*
*/
@ -10,7 +15,7 @@ export class GraphicCopyPlugin {
container: Container;
scene: IGraphicScene;
keyListeners: KeyListener[];
graphicKeyListenercMap: Map<string, KeyListener[]>;
graphicControlers: GraphicControler[];
copys: JlGraphic[];
start?: Point;
running = false;
@ -18,7 +23,7 @@ export class GraphicCopyPlugin {
constructor(scene: IGraphicScene) {
this.scene = scene;
this.container = new Container();
this.graphicKeyListenercMap = new Map<string, KeyListener[]>();
this.graphicControlers = [];
this.copys = [];
this.keyListeners = [];
this.keyListeners.push(
@ -78,12 +83,11 @@ export class GraphicCopyPlugin {
this.container.addChild(clone);
clone.repaint();
});
const addGraphicTypeKeyListener = this.graphicKeyListenercMap.get(
app.selectedGraphics[0].type,
);
if (addGraphicTypeKeyListener) {
this.keyListeners.push(...addGraphicTypeKeyListener);
}
this.graphicControlers.forEach((graphicControler) => {
if (graphicControler.check()) {
this.keyListeners.push(...graphicControler.controlerList);
}
});
this.scene.canvas.on('mousemove', this.onPointerMove, this);
this.scene.canvas.on('mouseup', this.onFinish, this);
this.scene.canvas.on('rightup', this.cancle, this);
@ -92,6 +96,10 @@ export class GraphicCopyPlugin {
});
}
addGraphicControlers(graphicControlers: GraphicControler[]) {
this.graphicControlers.push(...graphicControlers);
}
clear(): void {
this.running = false;
this.start = undefined;