Skip to content

Commit 78eb2f1

Browse files
Use WithW
1 parent 7309b6e commit 78eb2f1

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/ImageSharp/PixelFormats/PixelBlenders/PorterDuffFunctions.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,7 @@ public static Vector4 Over(Vector4 destination, Vector4 source, Vector4 blend)
278278

279279
// unpremultiply
280280
color /= Vector4.Max(alpha, new(Constants.Epsilon));
281-
color.W = alpha.W;
282-
283-
return color;
281+
return WithW(color, alpha);
284282
}
285283

286284
/// <summary>
@@ -339,9 +337,7 @@ public static Vector4 Atop(Vector4 destination, Vector4 source, Vector4 blend)
339337

340338
// unpremultiply
341339
color /= Vector4.Max(alpha, new(Constants.Epsilon));
342-
color.W = alpha.W;
343-
344-
return color;
340+
return WithW(color, alpha);
345341
}
346342

347343
/// <summary>
@@ -385,9 +381,7 @@ public static Vector4 In(Vector4 destination, Vector4 source)
385381

386382
Vector4 color = source * alpha; // premultiply
387383
color /= Vector4.Max(alpha, new(Constants.Epsilon)); // unpremultiply
388-
color.W = alpha.W;
389-
390-
return color;
384+
return WithW(color, alpha);
391385
}
392386

393387
/// <summary>
@@ -425,9 +419,7 @@ public static Vector4 Out(Vector4 destination, Vector4 source)
425419

426420
Vector4 color = source * alpha; // premultiply
427421
color /= Vector4.Max(alpha, new(Constants.Epsilon)); // unpremultiply
428-
color.W = alpha.W;
429-
430-
return color;
422+
return WithW(color, alpha);
431423
}
432424

433425
/// <summary>
@@ -470,9 +462,7 @@ public static Vector4 Xor(Vector4 destination, Vector4 source)
470462

471463
// unpremultiply
472464
color /= Vector4.Max(alpha, new(Constants.Epsilon));
473-
color.W = alpha.W;
474-
475-
return color;
465+
return WithW(color, alpha);
476466
}
477467

478468
/// <summary>

0 commit comments

Comments
 (0)