Skip to content

Commit

Permalink
path support command object
Browse files Browse the repository at this point in the history
  • Loading branch information
leaferjs committed Oct 20, 2024
1 parent 008fc6c commit 45501bf
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/display-module/data/src/BoxData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GroupData } from "./GroupData"

export class BoxData extends GroupData implements IBoxData {

public get __boxStroke(): boolean { return !this.__pathInputed }
public get __boxStroke(): boolean { return !(this as IBoxData).__pathInputed }

// 路径与圆角直接当溢出处理
public get __drawAfterFill(): boolean { return (this as IBoxData).overflow === 'hide' && this.__clipAfterFill && this.__leaf.children.length as unknown as boolean }
Expand Down
2 changes: 1 addition & 1 deletion packages/display-module/data/src/EllipseData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { UIData } from "./UIData"


export class EllipseData extends UIData implements IEllipseData {
get __boxStroke(): boolean { return !this.__pathInputed }
get __boxStroke(): boolean { return !(this as IEllipseData).__pathInputed }
}
2 changes: 1 addition & 1 deletion packages/display-module/data/src/RectData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { UIData } from "./UIData"


export class RectData extends UIData implements IRectData {
get __boxStroke(): boolean { return !this.__pathInputed }
get __boxStroke(): boolean { return !(this as IRectData).__pathInputed }
}
13 changes: 7 additions & 6 deletions packages/display-module/data/src/UIData.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { INumber, IValue, IBoolean, IPathCommandData, IPathString, IPointData } from '@leafer/interface'
import { INumber, IValue, IBoolean, IPathCommandData, IPathString, IPointData, IPathCommandObject } from '@leafer/interface'
import { PathConvert, LeafData, Debug } from '@leafer/core'

import { IShadowEffect, IUI, IUIData, ILeafPaint } from '@leafer-ui/interface'
import { Paint, PaintImage } from '@leafer-ui/external'


const { parse } = PathConvert
const { parse, objectToCanvasData } = PathConvert
const emptyPaint: ILeafPaint = {}
const debug = Debug.get('UIData')
export class UIData extends LeafData implements IUIData {
Expand Down Expand Up @@ -117,13 +117,14 @@ export class UIData extends LeafData implements IUIData {
}


protected setPath(value: IPathCommandData | IPathString) {
if (typeof value === 'string') {
protected setPath(value: IPathCommandData | IPathCommandObject[] | IPathString) {
const isString = typeof value === 'string'
if (isString || (value && typeof value[0] === 'object')) {
this.__setInput('path', value)
this._path = parse(value)
this._path = isString ? parse(value) : objectToCanvasData(value as IPathCommandObject[])
} else {
if (this.__input) this.__removeInput('path')
this._path = value
this._path = value as IPathCommandData
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/display/src/UI.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IEraserType, IValue, IWindingRule, IPathCreator, IFourNumber, IBoundsData, IFlowType, IGap, IFlowWrap, IAxis, IConstraint, IAutoBoxData, IFlowBoxType, IPointGap, IFlowAlign, IFlowAxisAlign, IFindCondition, IAutoSize, IRangeSize, IAlign, IUnitPointData, IObject, IScaleData, IUnitData } from '@leafer/interface'
import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IEraserType, IValue, IWindingRule, IPathCreator, IFourNumber, IBoundsData, IFlowType, IGap, IFlowWrap, IAxis, IConstraint, IAutoBoxData, IFlowBoxType, IPointGap, IFlowAlign, IFlowAxisAlign, IFindCondition, IAutoSize, IRangeSize, IAlign, IUnitPointData, IObject, IScaleData, IUnitData, IPathCommandObject } from '@leafer/interface'
import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, visibleType, sortType, maskType, dataProcessor, registerUI, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType, pen, naturalBoundsType, pathInputType, MathHelper, needPlugin } from '@leafer/core'

import { IUI, IShadowEffect, IBlurEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult, IFill, IStroke, IArrowType, IFindUIMethod, ILeafer, IEditorConfig, IEditorConfigFunction, IEditToolFunction, IKeyframe, IAnimation, IAnimate, IStates, IStateName, ITransition, IAnimateType } from '@leafer-ui/interface'
Expand Down Expand Up @@ -138,7 +138,7 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box

// path
@pathInputType()
public path?: IPathCommandData | IPathString
public path?: IPathCommandData | IPathCommandObject[] | IPathString

@pathType()
public windingRule?: IWindingRule
Expand Down

0 comments on commit 45501bf

Please sign in to comment.