Skip to content

Commit

Permalink
fix: BlendMode::Plus should be mapped to "plus" globalCompositeOperat…
Browse files Browse the repository at this point in the history
…ion (#1016)
  • Loading branch information
Brooooooklyn authored Mar 4, 2025
1 parent 319f5b2 commit bd61a90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
10 changes: 2 additions & 8 deletions src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,14 +956,8 @@ impl CanvasRenderingContext2D {
}

#[napi(getter)]
pub fn get_global_composite_operation(&self) -> String {
self
.context
.state
.paint
.get_blend_mode()
.as_str()
.to_owned()
pub fn get_global_composite_operation(&self) -> &str {
self.context.state.paint.get_blend_mode().as_str()
}

#[napi(setter, return_if_invalid)]
Expand Down
6 changes: 3 additions & 3 deletions src/sk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ impl Default for BlendMode {
}

impl BlendMode {
pub fn as_str(&self) -> &str {
pub fn as_str(&self) -> &'static str {
match self {
BlendMode::Clear => "clear",
BlendMode::Color => "color",
Expand All @@ -1237,7 +1237,7 @@ impl BlendMode {
BlendMode::Modulate => "modulate",
BlendMode::Multiply => "multiply",
BlendMode::Overlay => "overlay",
BlendMode::Plus => "plus",
BlendMode::Plus => "lighter",
BlendMode::Saturation => "saturation",
BlendMode::Screen => "screen",
BlendMode::SoftLight => "soft-light",
Expand Down Expand Up @@ -1275,7 +1275,7 @@ impl FromStr for BlendMode {
"modulate" => Ok(BlendMode::Modulate),
"multiply" => Ok(BlendMode::Multiply),
"overlay" => Ok(BlendMode::Overlay),
"plus" => Ok(BlendMode::Plus),
"lighter" => Ok(BlendMode::Plus),
"saturation" => Ok(BlendMode::Saturation),
"screen" => Ok(BlendMode::Screen),
"soft-light" => Ok(BlendMode::SoftLight),
Expand Down

0 comments on commit bd61a90

Please sign in to comment.