复制插件修改
This commit is contained in:
parent
dd9c5b528a
commit
294973738c
16
lib/index.js
16
lib/index.js
@ -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;
|
||||
|
8
lib/plugins/CopyPlugin.d.ts
vendored
8
lib/plugins/CopyPlugin.d.ts
vendored
@ -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 {};
|
||||
|
@ -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>",
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user