Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions OpenDreamRuntime/Objects/DreamIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,6 @@ protected DreamIconOperationBlend(BlendType type, int xOffset, int yOffset) {
_type = type;
_xOffset = xOffset;
_yOffset = yOffset;

if (_type is not BlendType.Overlay and not BlendType.Underlay and not BlendType.Multiply and not BlendType.Add and not BlendType.Subtract)
throw new NotImplementedException($"\"{_type}\" blending is not implemented");
}

public virtual void OnApply(DreamIcon icon) { }
Expand All @@ -324,6 +321,7 @@ protected void BlendPixel(Rgba32[] pixels, int dstPixelPosition, Rgba32 src) {
Rgba32 dst = pixels[dstPixelPosition];

switch (_type) {
case BlendType.And: // Byond for reasons known only to God does And as a copy of Add.
case BlendType.Add: {
pixels[dstPixelPosition].R = (byte)Math.Min(dst.R + src.R, byte.MaxValue);
pixels[dstPixelPosition].G = (byte)Math.Min(dst.G + src.G, byte.MaxValue);
Expand Down Expand Up @@ -371,6 +369,16 @@ protected void BlendPixel(Rgba32[] pixels, int dstPixelPosition, Rgba32 src) {
pixels[dstPixelPosition].A = (byte) (highAlpha + (highAlpha * lowAlpha / 255));
break;
}

case BlendType.Or: {
pixels[dstPixelPosition].R = (byte)(dst.R | src.R);
pixels[dstPixelPosition].G = (byte)(dst.G | src.G);
pixels[dstPixelPosition].B = (byte)(dst.B | src.B);

pixels[dstPixelPosition].A = (byte)(dst.A | src.A);
break;
}

case BlendType.Underlay: {
// Opposite of overlay
(dst, src) = (src, dst);
Expand Down
Loading