Add Altas class & refactored Atlas editor

This commit is contained in:
miku-666
2025-11-06 20:38:43 +01:00
parent 444924bfd2
commit 9d04e5f2aa
22 changed files with 3032 additions and 2425 deletions

View File

@@ -5,7 +5,9 @@ namespace PckStudio.Core.Extensions
{
public static class AnimationExtensions
{
public static Image CreateAnimationImage(this Animation animation)
public static Image CreateAnimationImage(this Animation animation) => animation.CreateAnimationImage(Color.Black);
public static Image CreateAnimationImage(this Animation animation, Color blendColor)
{
if (animation.FrameCount == 0)
{
@@ -15,7 +17,8 @@ namespace PckStudio.Core.Extensions
var generateor = new AnimatedGifCreator(ms, GameConstants.GameTickInMilliseconds, 0);
foreach (Animation.Frame frame in animation.GetInterpolatedFrames())
{
generateor.AddFrame(frame.Texture, frame.Ticks * GameConstants.GameTickInMilliseconds, GifQuality.Bit8);
Image texture = (blendColor == Color.Black || blendColor == Color.White) ? frame.Texture : frame.Texture.Blend(blendColor, BlendMode.Multiply);
generateor.AddFrame(texture, frame.Ticks * GameConstants.GameTickInMilliseconds, GifQuality.Bit8);
}
ms.Position = 0;
return Image.FromStream(ms);