3 Commits

4 changed files with 19 additions and 4 deletions

View File

@@ -95,7 +95,11 @@ public readonly struct ColorRGB(byte r, byte g, byte b) : IEquatable<ColorRGB>
int greenDiff = to.G - from.G;
int blueDiff = to.B - from.B;
return from + new ColorRGB((byte)(redDiff * t), (byte)(greenDiff * t), (byte)(blueDiff * t));
return new(
(byte)(from.R + redDiff * t),
(byte)(from.G + greenDiff * t),
(byte)(from.B + blueDiff * t)
);
}
/// <summary>

View File

@@ -1,4 +1,5 @@
using System;
using Engine.Core.Debug;
namespace Engine.Core;
@@ -125,7 +126,12 @@ public readonly struct ColorRGBA(byte r, byte g, byte b, byte a = 255) : IEquata
int blueDiff = to.B - from.B;
int alphaDiff = to.A - from.A;
return from + new ColorRGBA((byte)(redDiff * t), (byte)(greenDiff * t), (byte)(blueDiff * t), (byte)(alphaDiff * t));
return new(
(byte)(from.R + redDiff * t),
(byte)(from.G + greenDiff * t),
(byte)(from.B + blueDiff * t),
(byte)(from.A + alphaDiff * t)
);
}
/// <summary>

View File

@@ -39,7 +39,7 @@ public class MonoGameTriangleBatch : Behaviour, ITriangleBatch, IFirstFrameUpdat
Vector2 A = triangle.A.ToVector2();
Vector2 B = triangle.B.ToVector2();
Vector2 C = triangle.C.ToVector2();
Color color = colorRGBA.ToColor();
Color color = colorRGBA.ToPreMultipliedColor();
vertices[verticesIndex++] = new(new(A.X, A.Y, 0f), color);
vertices[verticesIndex++] = new(new(B.X, B.Y, 0f), color);
@@ -60,6 +60,8 @@ public class MonoGameTriangleBatch : Behaviour, ITriangleBatch, IFirstFrameUpdat
return;
graphicsDevice.RasterizerState = rasterizerState;
graphicsDevice.BlendState = BlendState.AlphaBlend;
basicEffect.Projection = projection;
basicEffect.View = view;
vertexBuffer.SetData(vertices);
@@ -67,8 +69,10 @@ public class MonoGameTriangleBatch : Behaviour, ITriangleBatch, IFirstFrameUpdat
graphicsDevice.SetVertexBuffer(vertexBuffer);
foreach (EffectPass pass in basicEffect.CurrentTechnique.Passes)
{
pass.Apply();
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, verticesIndex / 3);
}
verticesIndex = 0;
}

Submodule Engine.Serializers/YamlDotNet added at 62048d7abe