-
Notifications
You must be signed in to change notification settings - Fork 592
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
Automatically adjust block colors to have a contrast ratio of 4.5 #9973
Conversation
also, should be noted that turning this flag on will fix microsoft/pxt-arcade#4870 |
Also, is there a reason that |
ah, that would be because i missed on start! will fix |
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.
Just a question for my own understanding, otherwise looks good.
@@ -8,6 +8,12 @@ export function initOnStart() { | |||
const onStartDef = pxt.blocks.getBlockDefinition(ts.pxtc.ON_START_TYPE); | |||
Blockly.Blocks[ts.pxtc.ON_START_TYPE] = { | |||
init: function () { | |||
let colorOverride = pxt.appTarget.runtime?.onStartColor; |
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.
So we special-case the onStart block? 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.
on-start is kind of a special builtin block because we give targets a lot of control over where it shows up. For example, in micro:bit it's in the basic category but everywhere else it's in loops. iirc we added this option for cue because they had an on-start that doesn't show up in any category, it was just always on the workspace and couldn't be deleted.
Motivated by: microsoft/pxt-arcade#4870
This PR adds a little code to automatically adjust all block background colors to have a contrast ratio of at least 4.5 with white foreground text. The algorithm I'm using is pretty dumb: I just lower the luminosity until a color with the correct contrast ratio is generated and cache the result.
I placed this behind a feature flag for now because the general consensus is that this makes all the blocks look duller/uglier and creates a breaking change with old screenshots. The goal should be for us to eventually turn this on in all targets; we might have to adjust the base colors of some categories to make them more visually appealing though (arrays is particularly ugly).
Here is an upload target in micro:bit with the feature turned on:
https://makecode.microbit.org/app/36f327a321d404020e3804ed55f5a3567b2e929f-3d8dd326ca