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
Draw colored Background Layer #318
base: develop
Are you sure you want to change the base?
Conversation
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.
Please also check the skybottomlinecalculator there is also a clear call but I can't remember which function it uses
@@ -161,8 +161,13 @@ export class OpenSheetMusicDisplay { | |||
this.drawer.clear(); | |||
this.drawer.resize(width, height); | |||
this.drawer.scale(this.zoom); | |||
|
|||
// clear and fill with background color | |||
this.drawer.clear(0, 0, width, height); |
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.
There are 2 clears. Why?
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.
the first clear actually only removes the SVG children in the SVG backend in this case. I left it in in case the resizing and scaling is slower if we don't remove the SVG children beforehand.
So, clear without arguments behaves like before, clear with position and dimensions makes a colored background (rectangle).
We could separate these methods, of course. But i don't think removing children from a list or drawing a single rectangle costs much performance.
// this somehow works, though. | ||
public background_fillStyle: { fill: string }; | ||
public setBackgroundFillStyle(style: string): void; | ||
public clear(x: number, y: number, width: number, height: number): void; | ||
} |
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.
I really don't like the idea that I need to know my canvas size to clear it.
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.
you only need to know it if you want to fill it with the background color though. with default arguments it behaves as before. Also, canvas.width and canvas.height is often wrong in the canvas backend, too small.
SkyBottomLineCalculator's clear calls will behave as before, because of default arguments. |
Alright rest looks good to me then |
@bneumann so is there anything else i need to review? SkyBottomLineCalculator works as before. |
I can't think of anything else right now. That function is pretty low level but has not really been used before so should not be a biggie |
@bneumann just asking because your review still requests changes. But i've noted your LGTM ;) |
Si señor, problem is I cannot reopen the review on my phone |
Seems like i broke the cursor, so right now this should not be merged. I'm fixing it among other things. |
Currently implemented is an optional background color: osmd.setOptions({pageBackgroundColor: '#FFFFFF'}) this will make the cursor invisible. This PR still has a better compromise, but always changes the look (see above). |
9b4a2fa
to
a64b76e
Compare
We now draw a colored rectangle in VexflowBackend.clear(), which we call in OpenSheetMusicDisplay.render().
This enables directly right-click copying or saving the rendered score when using the Canvas backend, which is pretty convenient. Now we don't have to take a screenshot or edit image transparency anymore.
Previously, the canvas image had a transparent background:
Now it's white by default (saved as engraving rule).
The commits displayed here aren't that relevant, just look at the File changed. I'll squash the messages.