@leafer/display-module
Advanced tools
| import { ILeaf, ILeaferCanvas, IRenderOptions, IBranchRenderModule } from '@leafer/interface' | ||
| export const BranchRender: IBranchRenderModule = { | ||
| __updateChange(): void { | ||
| const { __layout: layout } = this | ||
| if (layout.childrenSortChanged) { | ||
| this.__updateSortChildren() | ||
| layout.childrenSortChanged = false | ||
| } | ||
| this.__.__checkSingle() | ||
| }, | ||
| __render(canvas: ILeaferCanvas, options: IRenderOptions): void { | ||
| if (this.__worldOpacity) { | ||
| if (this.__.__single) { | ||
| canvas.resetTransform() | ||
| const tempCanvas = canvas.getSameCanvas() | ||
| this.__renderBranch(tempCanvas, options) | ||
| canvas.opacity = this.__worldOpacity | ||
| canvas.copyWorld(tempCanvas, this.__world, this.__world, this.__.isEraser ? 'destination-out' : this.__.blendMode) | ||
| tempCanvas.recycle() | ||
| } else { | ||
| this.__renderBranch(canvas, options) | ||
| } | ||
| } | ||
| }, | ||
| __renderBranch(canvas: ILeaferCanvas, options: IRenderOptions): void { | ||
| let child: ILeaf | ||
| const { children } = this | ||
| if (this.__hasMask && children.length > 1) { | ||
| let mask: boolean | ||
| let maskCanvas = canvas.getSameCanvas() | ||
| let contentCanvas = canvas.getSameCanvas() | ||
| for (let i = 0, len = children.length; i < len; i++) { | ||
| child = children[i] | ||
| if (child.isMask) { | ||
| if (mask) { | ||
| this.__renderMask(canvas, contentCanvas, maskCanvas) | ||
| maskCanvas.clear() | ||
| contentCanvas.clear() | ||
| } else { | ||
| mask = true | ||
| } | ||
| child.__render(maskCanvas, options) | ||
| continue | ||
| } | ||
| child.__render(contentCanvas, options) | ||
| } | ||
| this.__renderMask(canvas, contentCanvas, maskCanvas) | ||
| maskCanvas.recycle() | ||
| contentCanvas.recycle() | ||
| } else { | ||
| const { bounds, hideBounds } = options | ||
| for (let i = 0, len = children.length; i < len; i++) { | ||
| child = children[i] | ||
| if (bounds && !bounds.hit(child.__world, options.matrix)) continue | ||
| if (hideBounds && hideBounds.includes(child.__world, options.matrix)) continue | ||
| child.__render(canvas, options) | ||
| } | ||
| } | ||
| } | ||
| } |
+4
-4
| { | ||
| "name": "@leafer/display-module", | ||
| "version": "1.0.0-beta.4", | ||
| "version": "1.0.0-beta.5", | ||
| "description": "@leafer/display-module", | ||
@@ -22,8 +22,8 @@ "author": "Chao (Leafer) Wan", | ||
| "dependencies": { | ||
| "@leafer/event": "1.0.0-beta.4", | ||
| "@leafer/math": "1.0.0-beta.4" | ||
| "@leafer/event": "1.0.0-beta.5", | ||
| "@leafer/math": "1.0.0-beta.5" | ||
| }, | ||
| "devDependencies": { | ||
| "@leafer/interface": "1.0.0-beta.4" | ||
| "@leafer/interface": "1.0.0-beta.5" | ||
| } | ||
| } |
+1
-0
@@ -9,1 +9,2 @@ export { LeafEventer } from './LeafEventer' | ||
| export { BranchRender } from './BranchRender' |
@@ -10,5 +10,8 @@ import { IEventListener, IEventListenerOptions, IEventListenerMap, IEventListenerItem, IEventListenerId, IEvent, IObject, IEventTarget, ILeafEventerModule } from '@leafer/interface' | ||
| if (options) { | ||
| const isBoolean = typeof options === 'boolean' | ||
| capture = isBoolean ? options : options.capture | ||
| once = isBoolean ? false : options.once | ||
| if (typeof options === 'boolean') { | ||
| capture = options | ||
| } else { | ||
| capture = options.capture | ||
| once = options.once | ||
| } | ||
| } | ||
@@ -15,0 +18,0 @@ |
+5
-0
@@ -6,2 +6,6 @@ import { ILeaf, ILeaferCanvas, ILeafMaskModule } from '@leafer/interface' | ||
| __updateEraser(value?: boolean): void { | ||
| this.__hasEraser = value ? true : this.children.some(item => item.__.isEraser) | ||
| }, | ||
| __updateMask(value?: boolean): void { | ||
@@ -15,2 +19,3 @@ this.__hasMask = value ? true : this.children.some(item => item.__.isMask) | ||
| canvas.resetTransform() | ||
| canvas.opacity = this.__worldOpacity | ||
| canvas.copyWorld(content) | ||
@@ -17,0 +22,0 @@ }, |
+11
-1
@@ -10,3 +10,13 @@ import { ILeaferCanvas, IRenderOptions, ILeafRenderModule } from '@leafer/interface' | ||
| canvas.opacity = this.__worldOpacity | ||
| this.__draw(canvas, options) | ||
| if (this.__.__single) { | ||
| const tempCanvas = canvas.getSameCanvas(true) | ||
| this.__draw(tempCanvas, options) | ||
| canvas.copyWorldToInner(tempCanvas, this.__world, this.__layout.renderBounds, this.__.isEraser ? 'destination-out' : this.__.blendMode) | ||
| tempCanvas.recycle() | ||
| } else { | ||
| this.__draw(canvas, options) | ||
| } | ||
| } | ||
@@ -13,0 +23,0 @@ }, |
18502
20.56%12
9.09%405
21.99%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated