diff options
| author | 2024-05-03 13:51:57 +0200 | |
|---|---|---|
| committer | 2024-05-03 13:51:57 +0200 | |
| commit | a94984d681875146d7af9f568bf8713503c1ca96 (patch) | |
| tree | c0a4eef3b5ab5fc3450b21b37df99542c178f6e0 /tiny_skia | |
| parent | 38cf87cb45484c7e52ddf775fb3abd7edbecc652 (diff) | |
| parent | afb4cb99b92a196bf4dd15a09a8f9bd191293fdd (diff) | |
| download | iced-a94984d681875146d7af9f568bf8713503c1ca96.tar.gz iced-a94984d681875146d7af9f568bf8713503c1ca96.tar.bz2 iced-a94984d681875146d7af9f568bf8713503c1ca96.zip  | |
Merge pull request #2424 from iced-rs/feature/image-opacity
Introduce dynamic `opacity` support for `Image` and `Svg`
Diffstat (limited to '')
| -rw-r--r-- | tiny_skia/src/engine.rs | 4 | ||||
| -rw-r--r-- | tiny_skia/src/layer.rs | 4 | ||||
| -rw-r--r-- | tiny_skia/src/lib.rs | 12 | ||||
| -rw-r--r-- | tiny_skia/src/raster.rs | 2 | ||||
| -rw-r--r-- | tiny_skia/src/vector.rs | 6 | 
5 files changed, 26 insertions, 2 deletions
diff --git a/tiny_skia/src/engine.rs b/tiny_skia/src/engine.rs index 544ff614..028b304f 100644 --- a/tiny_skia/src/engine.rs +++ b/tiny_skia/src/engine.rs @@ -551,6 +551,7 @@ impl Engine {                  filter_method,                  bounds,                  rotation, +                opacity,              } => {                  let physical_bounds = *bounds * _transformation; @@ -574,6 +575,7 @@ impl Engine {                      handle,                      *filter_method,                      *bounds, +                    *opacity,                      _pixels,                      transform,                      clip_mask, @@ -585,6 +587,7 @@ impl Engine {                  color,                  bounds,                  rotation, +                opacity,              } => {                  let physical_bounds = *bounds * _transformation; @@ -608,6 +611,7 @@ impl Engine {                      handle,                      *color,                      physical_bounds, +                    *opacity,                      _pixels,                      transform,                      clip_mask, diff --git a/tiny_skia/src/layer.rs b/tiny_skia/src/layer.rs index c907c93c..48fca1d8 100644 --- a/tiny_skia/src/layer.rs +++ b/tiny_skia/src/layer.rs @@ -122,12 +122,14 @@ impl Layer {          bounds: Rectangle,          transformation: Transformation,          rotation: Radians, +        opacity: f32,      ) {          let image = Image::Raster {              handle,              filter_method,              bounds: bounds * transformation,              rotation, +            opacity,          };          self.images.push(image); @@ -140,12 +142,14 @@ impl Layer {          bounds: Rectangle,          transformation: Transformation,          rotation: Radians, +        opacity: f32,      ) {          let svg = Image::Vector {              handle,              color,              bounds: bounds * transformation,              rotation, +            opacity,          };          self.images.push(svg); diff --git a/tiny_skia/src/lib.rs b/tiny_skia/src/lib.rs index e0cbfa0d..1aabff00 100644 --- a/tiny_skia/src/lib.rs +++ b/tiny_skia/src/lib.rs @@ -378,6 +378,7 @@ impl core::image::Renderer for Renderer {          filter_method: core::image::FilterMethod,          bounds: Rectangle,          rotation: core::Radians, +        opacity: f32,      ) {          let (layer, transformation) = self.layers.current_mut();          layer.draw_image( @@ -386,6 +387,7 @@ impl core::image::Renderer for Renderer {              bounds,              transformation,              rotation, +            opacity,          );      }  } @@ -405,9 +407,17 @@ impl core::svg::Renderer for Renderer {          color: Option<Color>,          bounds: Rectangle,          rotation: core::Radians, +        opacity: f32,      ) {          let (layer, transformation) = self.layers.current_mut(); -        layer.draw_svg(handle, color, bounds, transformation, rotation); +        layer.draw_svg( +            handle, +            color, +            bounds, +            transformation, +            rotation, +            opacity, +        );      }  } diff --git a/tiny_skia/src/raster.rs b/tiny_skia/src/raster.rs index 907fce7c..c40f55b2 100644 --- a/tiny_skia/src/raster.rs +++ b/tiny_skia/src/raster.rs @@ -31,6 +31,7 @@ impl Pipeline {          handle: &raster::Handle,          filter_method: raster::FilterMethod,          bounds: Rectangle, +        opacity: f32,          pixels: &mut tiny_skia::PixmapMut<'_>,          transform: tiny_skia::Transform,          clip_mask: Option<&tiny_skia::Mask>, @@ -56,6 +57,7 @@ impl Pipeline {                  image,                  &tiny_skia::PixmapPaint {                      quality, +                    opacity,                      ..Default::default()                  },                  transform, diff --git a/tiny_skia/src/vector.rs b/tiny_skia/src/vector.rs index 8e3463f2..bbe08cb8 100644 --- a/tiny_skia/src/vector.rs +++ b/tiny_skia/src/vector.rs @@ -34,6 +34,7 @@ impl Pipeline {          handle: &Handle,          color: Option<Color>,          bounds: Rectangle, +        opacity: f32,          pixels: &mut tiny_skia::PixmapMut<'_>,          transform: Transform,          clip_mask: Option<&tiny_skia::Mask>, @@ -47,7 +48,10 @@ impl Pipeline {                  bounds.x as i32,                  bounds.y as i32,                  image, -                &tiny_skia::PixmapPaint::default(), +                &tiny_skia::PixmapPaint { +                    opacity, +                    ..tiny_skia::PixmapPaint::default() +                },                  transform,                  clip_mask,              );  | 
