Skip to content

Commit

Permalink
update image task
Browse files Browse the repository at this point in the history
  • Loading branch information
leaferjs committed Oct 21, 2023
1 parent 979546b commit d4ec257
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
21 changes: 20 additions & 1 deletion packages/display/src/UI.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, __Number, __Boolean, __String, IPathString, IExportFileType, IPointData, ICursorType, IAround, ILeafDataOptions } from '@leafer/interface'
import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, __Number, __Boolean, __String, IPathString, IExportFileType, IPointData, ICursorType, IAround, ILeafDataOptions, IFindMethod } from '@leafer/interface'
import { Leaf, PathDrawer, surfaceType, dataType, positionType, boundsType, pathType, scaleType, rotationType, opacityType, sortType, maskType, dataProcessor, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType } from '@leafer/core'

import { IUI, IShadowEffect, IBlurEffect, IPaint, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IPaintString, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult } from '@leafer-ui/interface'
Expand Down Expand Up @@ -200,6 +200,8 @@ export class UI extends Leaf implements IUI {
}


// data

@rewrite(Leaf.prototype.reset)
public reset(_data?: IUIInputData): void { }

Expand All @@ -215,6 +217,19 @@ export class UI extends Leaf implements IUI {
public getProxyData(): IUIInputData { return undefined }


// find

public find(condition: number | string | IFindMethod): IUI[] {
return this.leafer ? this.leafer.selector.getBy(condition, this) as IUI[] : []
}

public findOne(condition: number | string | IFindMethod): IUI {
return this.leafer ? this.leafer.selector.getBy(condition, this, true) as IUI : null
}


// path

public getPath(curve?: boolean): IPathCommandData {
const path = this.__.path
if (!path) return []
Expand Down Expand Up @@ -254,6 +269,9 @@ export class UI extends Leaf implements IUI {
@rewrite(PathDrawer.drawPathByData)
public __drawPathByData(_drawer: IPathDrawer, _data: IPathCommandData): void { }


// create

public export(filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult> {
return Export.export(this, filename, options)
}
Expand All @@ -266,6 +284,7 @@ export class UI extends Leaf implements IUI {
return UICreator.get(data.tag || this.prototype.__tag, data, x, y, width, height) as IUI
}


public destroy(): void {
this.fill = this.stroke = null
super.destroy()
Expand Down
3 changes: 2 additions & 1 deletion packages/partner/paint/src/paint/image/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export function checkImage(ui: IUI, canvas: ILeaferCanvas, paint: ILeafPaint, al
if (!paint.patternTask) {
paint.patternTask = ImageManager.patternTasker.add(async () => {
paint.patternTask = null
if (canvas.bounds.hit(ui.__world) && createPattern(ui, paint, canvas.pixelRatio)) ui.forceUpdate('surface')
if (canvas.bounds.hit(ui.__world)) createPattern(ui, paint, canvas.pixelRatio)
ui.forceUpdate('surface')
}, 300)
}
}
Expand Down

0 comments on commit d4ec257

Please sign in to comment.