mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 07:18:04 +08:00
Wrap opacity/blend_mode in alpha_blending struct for graphic elements
This commit is contained in:
@@ -912,14 +912,14 @@ fn opacity_node(color: Color, opacity_multiplier: f32) -> Color {
|
||||
#[node_macro::node_impl(OpacityNode)]
|
||||
fn opacity_node(mut vector_data: VectorData, opacity_multiplier: f32) -> VectorData {
|
||||
let opacity_multiplier = opacity_multiplier / 100.;
|
||||
vector_data.style.opacity *= opacity_multiplier;
|
||||
vector_data.alpha_blending.opacity *= opacity_multiplier;
|
||||
vector_data
|
||||
}
|
||||
|
||||
#[node_macro::node_impl(OpacityNode)]
|
||||
fn opacity_node(mut graphic_group: GraphicGroup, opacity_multiplier: f32) -> GraphicGroup {
|
||||
let opacity_multiplier = opacity_multiplier / 100.;
|
||||
graphic_group.opacity *= opacity_multiplier;
|
||||
graphic_group.alpha_blending.opacity *= opacity_multiplier;
|
||||
graphic_group
|
||||
}
|
||||
|
||||
@@ -930,19 +930,19 @@ pub struct BlendModeNode<BM> {
|
||||
|
||||
#[node_macro::node_fn(BlendModeNode)]
|
||||
fn blend_mode_node(mut vector_data: VectorData, blend_mode: BlendMode) -> VectorData {
|
||||
vector_data.style.blend_mode = blend_mode;
|
||||
vector_data.alpha_blending.blend_mode = blend_mode;
|
||||
vector_data
|
||||
}
|
||||
|
||||
#[node_macro::node_impl(BlendModeNode)]
|
||||
fn blend_mode_node(mut graphic_group: GraphicGroup, blend_mode: BlendMode) -> GraphicGroup {
|
||||
graphic_group.blend_mode = blend_mode;
|
||||
graphic_group.alpha_blending.blend_mode = blend_mode;
|
||||
graphic_group
|
||||
}
|
||||
|
||||
#[node_macro::node_impl(BlendModeNode)]
|
||||
fn blend_mode_node(mut image_frame: ImageFrame<Color>, blend_mode: BlendMode) -> ImageFrame<Color> {
|
||||
image_frame.blend_mode = blend_mode;
|
||||
image_frame.alpha_blending.blend_mode = blend_mode;
|
||||
image_frame
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::discrete_srgb::float_to_srgb_u8;
|
||||
use super::{Color, ImageSlice};
|
||||
use crate::Node;
|
||||
use crate::{AlphaBlending, Node};
|
||||
use alloc::vec::Vec;
|
||||
use core::hash::{Hash, Hasher};
|
||||
use dyn_any::StaticType;
|
||||
@@ -260,7 +260,7 @@ pub struct ImageFrame<P: Pixel> {
|
||||
// positive going right and y axis positive going down, with the origin
|
||||
// being an unspecified quantity.
|
||||
pub transform: DAffine2,
|
||||
pub blend_mode: BlendMode,
|
||||
pub alpha_blending: AlphaBlending,
|
||||
}
|
||||
|
||||
impl<P: Debug + Copy + Pixel> Sample for ImageFrame<P> {
|
||||
@@ -312,7 +312,7 @@ impl<P: Copy + Pixel> ImageFrame<P> {
|
||||
Self {
|
||||
image: Image::empty(),
|
||||
transform: DAffine2::ZERO,
|
||||
blend_mode: BlendMode::Normal,
|
||||
alpha_blending: AlphaBlending::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ impl<P: Copy + Pixel> ImageFrame<P> {
|
||||
Self {
|
||||
image: Image::empty(),
|
||||
transform: DAffine2::IDENTITY,
|
||||
blend_mode: BlendMode::Normal,
|
||||
alpha_blending: AlphaBlending::new(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ impl From<ImageFrame<Color>> for ImageFrame<SRGBA8> {
|
||||
height: image.image.height,
|
||||
},
|
||||
transform: image.transform,
|
||||
blend_mode: BlendMode::Normal,
|
||||
alpha_blending: image.alpha_blending,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -396,7 +396,7 @@ impl From<ImageFrame<SRGBA8>> for ImageFrame<Color> {
|
||||
height: image.image.height,
|
||||
},
|
||||
transform: image.transform,
|
||||
blend_mode: BlendMode::Normal,
|
||||
alpha_blending: image.alpha_blending,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user