Math is hard
This commit is contained in:
+19
-7
@@ -5,17 +5,29 @@ namespace fxl.codes.kisekae.Models
|
||||
{
|
||||
public class CelModel
|
||||
{
|
||||
public readonly int Fix;
|
||||
public readonly string Image;
|
||||
public readonly int Mark;
|
||||
public readonly int ZIndex;
|
||||
|
||||
internal CelModel(CelConfig celConfig, Render render, int zIndex)
|
||||
internal CelModel(CelConfig celConfig, int zIndex)
|
||||
{
|
||||
Mark = celConfig.Mark;
|
||||
Fix = celConfig.Fix;
|
||||
ZIndex = zIndex;
|
||||
Image = Convert.ToBase64String(render.Image);
|
||||
Image = Convert.ToBase64String(celConfig.Render.Image);
|
||||
Height = celConfig.Cel.Height;
|
||||
Width = celConfig.Cel.Width;
|
||||
Opacity = (double)(255 - celConfig.Transparency) / 255;
|
||||
|
||||
foreach (var position in celConfig.Positions) InitialPositions[position.Set] = new CoordinateModel(position.X, position.Y);
|
||||
|
||||
Offset = new CoordinateModel(celConfig.Cel.OffsetX, celConfig.Cel.OffsetY);
|
||||
}
|
||||
|
||||
public int Fix { get; set; }
|
||||
public int Height { get; set; }
|
||||
public string Image { get; set; }
|
||||
public int Mark { get; set; }
|
||||
public double Opacity { get; set; }
|
||||
public int Width { get; set; }
|
||||
public int ZIndex { get; set; }
|
||||
public CoordinateModel[] InitialPositions { get; set; } = new CoordinateModel[10];
|
||||
public CoordinateModel Offset { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace fxl.codes.kisekae.Models
|
||||
{
|
||||
public class CoordinateModel
|
||||
{
|
||||
internal CoordinateModel(int x, int y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
}
|
||||
}
|
||||
+25
-10
@@ -1,25 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text.Json.Serialization;
|
||||
using SixLabors.ImageSharp;
|
||||
using Configuration = fxl.codes.kisekae.Entities.Configuration;
|
||||
using fxl.codes.kisekae.Entities;
|
||||
|
||||
namespace fxl.codes.kisekae.Models
|
||||
{
|
||||
public class PlaysetModel
|
||||
{
|
||||
public readonly int Height;
|
||||
public readonly string Name;
|
||||
public readonly int Width;
|
||||
public readonly CelModel[] Cels;
|
||||
|
||||
[JsonIgnore] public Color BorderColor = Color.Black;
|
||||
[JsonIgnore] public readonly string BorderColor;
|
||||
|
||||
internal PlaysetModel(Configuration configuration)
|
||||
{
|
||||
BorderColor = configuration.BackgroundColorHex;
|
||||
|
||||
Name = configuration.Name;
|
||||
Height = configuration.Height;
|
||||
Width = configuration.Width;
|
||||
Cels = new CelModel[0];
|
||||
var totalCels = configuration.Cels.Count;
|
||||
Cels = configuration.Cels.Select((x, index) => new CelModel(x, (totalCels - index) * 10)).ToArray();
|
||||
|
||||
var summation = configuration.Cels.Aggregate(Set.None, (current, cel) => current | cel.Sets);
|
||||
if (summation == Set.None)
|
||||
{
|
||||
Array.Fill(Sets, true);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var value in Enum.GetValues<Set>().Where(x => (x & summation) == x && x != Set.None))
|
||||
if (value == Set.Zero) Sets[0] = true;
|
||||
else Sets[(int)Math.Log2((double)value)] = true;
|
||||
}
|
||||
|
||||
public CelModel[] Cels { get; set; }
|
||||
public int Height { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool[] Sets { get; set; } = new bool[10];
|
||||
public int Width { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user