-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix artboard transparency #3921
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -893,6 +893,18 @@ impl Color { | |||||||||||||||||||||||||||
| [(gamma.red * 255.) as u8, (gamma.green * 255.) as u8, (gamma.blue * 255.) as u8, (gamma.alpha * 255.) as u8] | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// Return the all components as a u8 slice, first component is red, followed by green, followed by blue, followed by alpha. Use this if the [`Color`] is in gamma space. | ||||||||||||||||||||||||||||
| /// # Examples | ||||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||||
| /// use core_types::color::Color; | ||||||||||||||||||||||||||||
| /// let color = Color::from_rgbaf32(0.114, 0.103, 0.98, 0.97).unwrap(); | ||||||||||||||||||||||||||||
| /// // TODO: Add test | ||||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||||
| #[inline(always)] | ||||||||||||||||||||||||||||
| pub fn to_rgba8(&self) -> [u8; 4] { | ||||||||||||||||||||||||||||
| [(self.red * 255.) as u8, (self.green * 255.) as u8, (self.blue * 255.) as u8, (self.alpha * 255.) as u8] | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// Return the all RGB components as a u8 slice, first component is red, followed by green, followed by blue. Use this if the [`Color`] is in linear space. | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
| /// # Examples | ||||||||||||||||||||||||||||
|
|
@@ -907,6 +919,18 @@ impl Color { | |||||||||||||||||||||||||||
| [(gamma.red * 255.) as u8, (gamma.green * 255.) as u8, (gamma.blue * 255.) as u8] | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| /// Return the all RGB components as a u8 slice, first component is red, followed by green, followed by blue. Use this if the [`Color`] is in gamma space. | ||||||||||||||||||||||||||||
| /// # Examples | ||||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||||
| /// use core_types::color::Color; | ||||||||||||||||||||||||||||
| /// let color = Color::from_rgbaf32(0.114, 0.103, 0.98, 0.97).unwrap(); | ||||||||||||||||||||||||||||
| /// // TODO: Add test | ||||||||||||||||||||||||||||
| /// ``` | ||||||||||||||||||||||||||||
|
Comment on lines
+923
to
+928
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to The documentation states this function should be used if the
Suggested change
|
||||||||||||||||||||||||||||
| #[inline(always)] | ||||||||||||||||||||||||||||
| pub fn to_rgb8(&self) -> [u8; 3] { | ||||||||||||||||||||||||||||
| [(self.red * 255.) as u8, (self.green * 255.) as u8, (self.blue * 255.) as u8] | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // https://www.niwa.nu/2013/05/math-behind-colorspace-conversions-rgb-hsl/ | ||||||||||||||||||||||||||||
| /// Convert a [Color] to a hue, saturation, lightness and alpha (all between 0 and 1) | ||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -129,7 +129,7 @@ impl WgpuExecutor { | |||||
| if let Some(target_texture) = output.as_mut() { | ||||||
| target_texture.ensure_size(&self.context.device, size); | ||||||
|
|
||||||
| let [r, g, b, a] = background.unwrap_or(Color::TRANSPARENT).to_rgba8_srgb(); | ||||||
| let [r, g, b, a] = background.unwrap_or(Color::TRANSPARENT).to_rgba8(); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change appears to introduce a color correctness issue. The However, The previous implementation using
Suggested change
|
||||||
| let render_params = RenderParams { | ||||||
| base_color: vello::peniko::Color::from_rgba8(r, g, b, a), | ||||||
| width: size.x, | ||||||
|
|
||||||
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 example for
to_rgba8is misleading and there's a// TODO: Add test.The documentation states this function should be used if the
Coloris in gamma space. However,Color::from_rgbaf32creates aColorin linear space. The example should reflect the correct usage, and the TODO can be resolved by adding an assertion.