Skip to content
This repository has been archived by the owner on Sep 8, 2024. It is now read-only.

Commit

Permalink
fix: image blendmode
Browse files Browse the repository at this point in the history
  • Loading branch information
sheepbox8646 committed Jul 3, 2024
1 parent afd2c73 commit c4eed07
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/scene1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ export default nc.createScene(
y: 450
})
.animate(nc.wiggle().withAttr({ duration: 1, count: 8, amplitude: 10, scale: 1.5 }))
.on(nc.keyDown, (_, __) => {
console.log('www')
})
)
2 changes: 2 additions & 0 deletions packages/basic/src/widgets/imageWidget.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { WidgetOptions, WidgetRange } from '@newcar/core'
import { Widget } from '@newcar/core'
import type { Canvas, CanvasKit, Image, Paint } from 'canvaskit-wasm'
import { str2BlendMode } from '@newcar/utils'

export interface ImageWidgetOptions extends WidgetOptions {}

Expand All @@ -25,6 +26,7 @@ export class ImageWidget extends Widget {
this.paint = new ck.Paint()
this.paint.setAlphaf(this.style.transparency.value)
this.paint.setAntiAlias(this.style.antiAlias.value)
this.paint.setBlendMode(str2BlendMode(ck, this.style.blendMode.value))
try {
this.image = ck.MakeImageFromEncoded(this.imageArray)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ export class Widget {
* Add children widgets for the widget.
* @param children The added children.
*/
add(...children: any[]): this {
add(...children: any[] | ((widget: any) => any)[]): this {
// let index = 0
for (const child of children) {
child.parent = this
Expand Down

0 comments on commit c4eed07

Please sign in to comment.