Going back to the canvas thing

This commit is contained in:
Lani Aung
2021-12-12 13:49:19 -07:00
parent 720b387dd3
commit 262bce4549
20 changed files with 3623 additions and 537 deletions
+5 -5
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using fxl.codes.kisekae.Entities;
namespace fxl.codes.kisekae.Models
@@ -10,14 +11,13 @@ namespace fxl.codes.kisekae.Models
Mark = celConfig.Mark;
Fix = celConfig.Fix;
ZIndex = zIndex;
Image = Convert.ToBase64String(celConfig.Render.Image);
Image = $"data:image/gif;base64,{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);
foreach (var position in celConfig.Positions) InitialPositions.Add(position.Set, new CoordinateModel(position.X, position.Y));
}
public int Fix { get; set; }
@@ -27,7 +27,7 @@ namespace fxl.codes.kisekae.Models
public double Opacity { get; set; }
public int Width { get; set; }
public int ZIndex { get; set; }
public CoordinateModel[] InitialPositions { get; set; } = new CoordinateModel[10];
public IDictionary<int, CoordinateModel> InitialPositions { get; set; } = new Dictionary<int, CoordinateModel>();
public CoordinateModel Offset { get; set; }
}
}
+1 -11
View File
@@ -1,4 +1,3 @@
using System;
using System.Linq;
using System.Text.Json.Serialization;
using fxl.codes.kisekae.Entities;
@@ -19,16 +18,7 @@ namespace fxl.codes.kisekae.Models
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;
for (var index = 0; index < 10; index++) Sets[index] = configuration.Cels.Any(x => x.Positions.Any(y => y.Set == index));
}
public CelModel[] Cels { get; set; }