-
-
Notifications
You must be signed in to change notification settings - Fork 85
Canvas Backend Blend Support (Issue #165) #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Canvas Backend Blend Support (Issue #165) #193
Conversation
|
hi @noelwelsh , would love to receive your feedback on this! |
noelwelsh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small changes to follow the existing conventions.
|
Hey @noelwelsh , I have added the requested changes! |
noelwelsh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few small changes.
| blendMode: String | ||
| )(drawing: CanvasDrawing[A]): CanvasDrawing[A] = { | ||
| CanvasDrawing { ctx => | ||
| ctx.save() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saving and restoring the canvas state is quite expensive (there is a lot of state). Better to just save the current blend mode (i.e. the value of globalCompositeOperation).
|
@noelwelsh sure ill get back to you! |
This PR adds support for the Blend algebra to the Canvas backend.
Implementation:
Canvas Blend Implementation:
CanvasBlendtrait incanvas/src/main/scala/doodle/canvas/algebra/CanvasBlend.scalaBlendtrait using Canvas'sglobalCompositeOperationblendhelper function to avoid code duplicationHow it works:
FinalizedandRenderablepattern to wrap the original drawing operationTesting:
I noted that the golden test infrastructure uses Java2D (which doesn't support the Blend trait), so I haven't included automated tests.
Based on the discussion in the issue, I understand that:
I'd appreciate feedback on this implementation, particularly on: