Skip to content

Commit

Permalink
improved easing and fixed maximized window position
Browse files Browse the repository at this point in the history
  • Loading branch information
saint11 committed Nov 3, 2024
1 parent 8ed0f1c commit cd8f338
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Murder.Editor/Architect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public override void SetWindowSize(Point screenSize, bool remember)

if (!IsMaximized() && EditorSettings.WindowStartPosition.X > 0 && EditorSettings.WindowStartPosition.Y > 0)
{
Point size = EditorSettings.WindowStartPosition - new Point(-2, 0);
Point size = EditorSettings.WindowStartPosition;
SetWindowPosition(size);
}

Expand All @@ -154,9 +154,9 @@ public override void SetWindowSize(Point screenSize, bool remember)

if (EditorSettings.StartMaximized && GetWindowPosition() is Point startPosition)
{
int titleBar = 32;
int titleBar = 34;

SetWindowPosition(new Point(startPosition.X - 2, titleBar));
SetWindowPosition(new Point(startPosition.X, titleBar));
MaximizeWindow();
}
}
Expand Down
27 changes: 27 additions & 0 deletions src/Murder/Utilities/Ease.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Murder.Diagnostics;
using System;

namespace Murder.Utilities
{
Expand Down Expand Up @@ -474,5 +475,31 @@ public static float JumpArc(float t)
{
return MathF.Sin(Calculator.Clamp01(t) * MathF.PI);
}
// Predefined curve representing the intensity of the flicker effect over time
private static readonly float[] flickerCurve = {
0.0f, 0.2f, 0.5f, 0.8f, 1.0f, 0.7f, 1.0f, 1.0f,0.4f, 0.3f, 0.6f, 0.9f, 0.6f, 0.3f, 0.1f, 0.0f
};

// Method to get the flicker intensity based on a 0-1 range input, with smooth interpolation
public static float FlickerRandom(float t)
{
// Clamp t to be within the 0-1 range
t = Math.Clamp(t, 0.0f, 1.0f);

// Map t to a fractional index in the flickerCurve array
float scaledIndex = t * (flickerCurve.Length - 1);
int lowerIndex = (int)Math.Floor(scaledIndex);
int upperIndex = Math.Min(lowerIndex + 1, flickerCurve.Length - 1);

// Get the two closest values from the curve
float lowerValue = flickerCurve[lowerIndex];
float upperValue = flickerCurve[upperIndex];

// Calculate the fractional part for interpolation
float fractionalPart = scaledIndex - lowerIndex;

// Interpolate between the two values
return Calculator.Lerp(lowerValue, upperValue, fractionalPart);
}
}
}

0 comments on commit cd8f338

Please sign in to comment.