mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-03-01 01:57:05 +08:00
feat: 删除graphics元素
This commit is contained in:
parent
209c28a9ff
commit
c6cbdae5d5
@ -36,55 +36,6 @@ export const enum GraphicMode {
|
|||||||
All = 3
|
All = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Graphics extends RenderItem {
|
|
||||||
/** 排序后的子元素 */
|
|
||||||
sortedChildren: RenderItem[] = [];
|
|
||||||
|
|
||||||
/** 是否需要重排 */
|
|
||||||
private needSort: boolean = false;
|
|
||||||
|
|
||||||
protected render(
|
|
||||||
canvas: MotaOffscreenCanvas2D,
|
|
||||||
transform: Transform
|
|
||||||
): void {
|
|
||||||
const ctx = canvas.ctx;
|
|
||||||
this.sortedChildren.forEach(v => {
|
|
||||||
ctx.save();
|
|
||||||
v.renderContent(canvas, transform);
|
|
||||||
ctx.restore();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 为这个Graphics元素添加子元素,要求只能是Graphics元素或基于GraphicItemBase的元素
|
|
||||||
* @param child 要添加的子元素
|
|
||||||
*/
|
|
||||||
appendChild(...child: RenderItem<any>[]): void {
|
|
||||||
child.forEach(v => {
|
|
||||||
// 如果是Graphics或GraphicItemBase实例,则加入子元素列表,否则抛出警告并忽略本次添加
|
|
||||||
if (v instanceof Graphics || v instanceof GraphicItemBase) {
|
|
||||||
} else {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除子元素
|
|
||||||
*/
|
|
||||||
removeChild(...child: RenderItem<any>[]): void {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 申请对子元素按照zIndex进行重排
|
|
||||||
*/
|
|
||||||
requestSort(): void {
|
|
||||||
// 在下一帧渲染前进行排序
|
|
||||||
if (!this.needSort) {
|
|
||||||
this.needSort = true;
|
|
||||||
this.requestBeforeFrame(() => {});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export abstract class GraphicItemBase
|
export abstract class GraphicItemBase
|
||||||
extends RenderItem
|
extends RenderItem
|
||||||
implements IGraphicProperty
|
implements IGraphicProperty
|
||||||
|
@ -18,7 +18,6 @@ import {
|
|||||||
DamageProps,
|
DamageProps,
|
||||||
EllipseProps,
|
EllipseProps,
|
||||||
GL2Props,
|
GL2Props,
|
||||||
GraphicsProps,
|
|
||||||
IconProps,
|
IconProps,
|
||||||
ImageProps,
|
ImageProps,
|
||||||
LayerGroupProps,
|
LayerGroupProps,
|
||||||
@ -88,7 +87,6 @@ declare module 'vue/jsx-runtime' {
|
|||||||
'layer-group': TagDefine<LayerGroupProps, ELayerGroupEvent>;
|
'layer-group': TagDefine<LayerGroupProps, ELayerGroupEvent>;
|
||||||
damage: TagDefine<DamageProps, EDamageEvent>;
|
damage: TagDefine<DamageProps, EDamageEvent>;
|
||||||
animation: TagDefine<AnimateProps, EAnimateEvent>;
|
animation: TagDefine<AnimateProps, EAnimateEvent>;
|
||||||
graphics: TagDefine<GraphicsProps, ERenderItemEvent>;
|
|
||||||
'g-rect': TagDefine<RectProps, ERenderItemEvent>;
|
'g-rect': TagDefine<RectProps, ERenderItemEvent>;
|
||||||
'g-circle': TagDefine<CirclesProps, ERenderItemEvent>;
|
'g-circle': TagDefine<CirclesProps, ERenderItemEvent>;
|
||||||
'g-ellipse': TagDefine<EllipseProps, ERenderItemEvent>;
|
'g-ellipse': TagDefine<EllipseProps, ERenderItemEvent>;
|
||||||
|
@ -11,7 +11,6 @@ import {
|
|||||||
BezierCurve,
|
BezierCurve,
|
||||||
Circle,
|
Circle,
|
||||||
Ellipse,
|
Ellipse,
|
||||||
Graphics,
|
|
||||||
Line,
|
Line,
|
||||||
Path,
|
Path,
|
||||||
QuadraticCurve,
|
QuadraticCurve,
|
||||||
@ -170,7 +169,6 @@ tagMap.register<EDamageEvent, Damage>('damage', (_0, _1, props) => {
|
|||||||
tagMap.register('animation', (_0, _1, props) => {
|
tagMap.register('animation', (_0, _1, props) => {
|
||||||
return new Animate();
|
return new Animate();
|
||||||
});
|
});
|
||||||
tagMap.register('graphics', standardElement(Graphics));
|
|
||||||
tagMap.register('g-rect', standardElement(Rect));
|
tagMap.register('g-rect', standardElement(Rect));
|
||||||
tagMap.register('g-circle', standardElement(Circle));
|
tagMap.register('g-circle', standardElement(Circle));
|
||||||
tagMap.register('g-ellipse', standardElement(Ellipse));
|
tagMap.register('g-ellipse', standardElement(Ellipse));
|
||||||
|
@ -90,8 +90,6 @@ export interface DamageProps extends BaseProps {
|
|||||||
strokeWidth?: number;
|
strokeWidth?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GraphicsProps extends BaseProps {}
|
|
||||||
|
|
||||||
export interface RectProps extends BaseProps {}
|
export interface RectProps extends BaseProps {}
|
||||||
|
|
||||||
export interface CirclesProps extends BaseProps {}
|
export interface CirclesProps extends BaseProps {}
|
||||||
|
Loading…
Reference in New Issue
Block a user