-
Notifications
You must be signed in to change notification settings - Fork 143
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
Examples: Replace Color::from_* and Color::new with palette::css where possible #787
base: main
Are you sure you want to change the base?
Conversation
I stumbled onto this by trying to copy the example code into my own project, but discovered it does not compile with the vello version on crates.io. I assume that is a known problem? If so, this is an unfortunate barrier for newcomers :( |
Clippy failed because the import is only used behind the |
Thanks for this! To use the
Hmm, I'm unsure how this change would have an impact there - the palettes used would also not be available on the release on crates.io.
I think that's right. It's the solution we used to import |
How did you find these matching colours? Were they all identical to the CSS counterpart? (if the colours have changed, the snapshot tests will need to be updated) |
Oh, I did not realize the exact values of the example colours mattered for tests, so I just chose the ones from the css list, which matches most closely... |
This change won´t help. I was just making sure, that the issue is known! Mentioning this in the README seems like a good idea, since many people (me included) learn a new crate by adapting it's examples. |
How are the snapshot tests generated? Since they will need to be updated. |
You should use |
Ah, that is what i feared. Some test pass on my machine with the modified colors (due to the leniency in the tests) and are therefore not updated, but since this introduces baseline error into each test, they now are much more sensitive, so are failing on i.e. macos. |
So I should probably regenerate all snapshot test, to ensure this is not a problem in the future (nobody likes sporadic failures) |
Is it okay if I add a flag |
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 problem with updating all the tests is that a lot of them won't have actually changed. I'd suggest either lowering the threshold of similarity temporarily, or just deleting and regenerating the "source" snapshots for the tests you want to keep.
Regenerating the full suite is an operation we effectively never want to use.
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 don't know if it's just me, but this colour scheme looks worse to me. The previous scheme all had a very similar saturation, whereas now the green looks more saturated than the orange and the blue (plus the new white, which also stands out)
Color::from_rgba8(140, 181, 236, 255), | ||
Color::from_rgba8(246, 236, 202, 255), | ||
Color::from_rgba8(201, 147, 206, 255), | ||
Color::from_rgba8(150, 195, 160, 255), | ||
palette::css::SKY_BLUE, | ||
palette::css::LIGHT_SALMON, | ||
palette::css::LAVENDER, | ||
palette::css::PALE_GREEN, |
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.
How did you come to these colours? Given that this was originally the same set of colours as at line 349, it's surprising that three of the four colour names used are different.
Color::from_rgba8(0x10, 0x10, 0x10, 0xff), | ||
Color::from_rgba8(0x80, 0x80, 0x80, 0xff), | ||
Color::from_rgba8(0xc0, 0xc0, 0xc0, 0xff), | ||
Color::from_rgba8(0x10, 0x10, 0x10, 0xff), | ||
Color::from_rgba8(0x80, 0x80, 0x80, 0xff), | ||
Color::from_rgba8(0xc0, 0xc0, 0xc0, 0xff), | ||
Color::from_rgba8(0xe0, 0x10, 0x40, 0xff), | ||
palette::css::BLACK, | ||
palette::css::GRAY, | ||
palette::css::LIGHT_GRAY, | ||
palette::css::BLACK, | ||
palette::css::GRAY, | ||
palette::css::LIGHT_GRAY, | ||
palette::css::DEEP_PINK, |
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.
These need to match the motionmark benchmark
As mentioned in #749, this replaces all uses of
Color::from_*
andColor::new
withpalette::css
constants when possible.This also allowed me to remove the import of
peniko::Color
, in all but one example project.I do not know how to use the
examples/scenes
lib, so it is technically untested, but I tried to match the colors as best as possible, which should be good enough.