Fix opacity not being included in alpha of Fill type when converted from Table<Color> (#3785)

* Fix opacity not being included in alpha of Fill type when converted from Table<Color>

* Avoid unwrap, I guess
This commit is contained in:
Keavon Chambers 2026-02-18 01:21:02 -08:00 committed by GitHub
parent e5827f2b81
commit 5d5993bcca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -2,6 +2,7 @@
pub use crate::gradient::*;
use core_types::Color;
use core_types::color::Alpha;
use core_types::table::Table;
use dyn_any::DynAny;
use glam::DAffine2;
@ -123,7 +124,9 @@ impl From<Option<Color>> for Fill {
impl From<Table<Color>> for Fill {
fn from(color: Table<Color>) -> Fill {
Fill::solid_or_none(color.into())
let alpha = color.get(0).map(|c| c.alpha_blending.opacity).unwrap_or(1.);
let color: Option<Color> = color.into();
Fill::solid_or_none(color.map(|c| c.with_alpha(c.alpha() * alpha)))
}
}