|
@@ -6,6 +6,7 @@ namespace PixiEditor.AvaloniaUI.Helpers;
|
|
|
public static class StructureHelpers
|
|
public static class StructureHelpers
|
|
|
{
|
|
{
|
|
|
public const int PreviewSize = 48;
|
|
public const int PreviewSize = 48;
|
|
|
|
|
+
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Calculates the size of a scaled-down preview for a given size of layer tight bounds.
|
|
/// Calculates the size of a scaled-down preview for a given size of layer tight bounds.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -13,8 +14,17 @@ public static class StructureHelpers
|
|
|
{
|
|
{
|
|
|
double proportions = tightBoundsSize.Y / (double)tightBoundsSize.X;
|
|
double proportions = tightBoundsSize.Y / (double)tightBoundsSize.X;
|
|
|
const int prSize = PreviewSize;
|
|
const int prSize = PreviewSize;
|
|
|
- return proportions > 1 ?
|
|
|
|
|
- new VecI(Math.Max((int)Math.Round(prSize / proportions), 1), prSize) :
|
|
|
|
|
- new VecI(prSize, Math.Max((int)Math.Round(prSize * proportions), 1));
|
|
|
|
|
|
|
+ return proportions > 1
|
|
|
|
|
+ ? new VecI(Math.Max((int)Math.Round(prSize / proportions), 1), prSize)
|
|
|
|
|
+ : new VecI(prSize, Math.Max((int)Math.Round(prSize * proportions), 1));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static VecI CalculatePreviewSize(VecI tightBoundsSize, int previewSize)
|
|
|
|
|
+ {
|
|
|
|
|
+ double proportions = tightBoundsSize.Y / (double)tightBoundsSize.X;
|
|
|
|
|
+ int prSize = previewSize;
|
|
|
|
|
+ return proportions > 1
|
|
|
|
|
+ ? new VecI(Math.Max((int)Math.Round(prSize / proportions), 1), prSize)
|
|
|
|
|
+ : new VecI(prSize, Math.Max((int)Math.Round(prSize * proportions), 1));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|