Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielchalmers committed Jul 17, 2024
1 parent 63da7bc commit 011188a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DesktopClock/Properties/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private Settings()
public bool RightAligned { get; set; } = false;

/// <summary>
/// Experimental: Shifts the clock around in order to prevent screen burn-in.
/// Experimental: Shifts the clock periodically in order to reduce screen burn-in.
/// </summary>
public bool BurnInMitigation { get; set; } = false;

Expand Down
2 changes: 1 addition & 1 deletion DesktopClock/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
Margin="0,0,0,12" />

<CheckBox Content="Burn-in Mitigation" IsChecked="{Binding Settings.BurnInMitigation, Mode=TwoWay}" />
<TextBlock Text="Experimental: Shifts the clock around in order to prevent screen burn-in."
<TextBlock Text="Experimental: Shifts the clock periodically in order to reduce screen burn-in."
FontStyle="Italic"
FontSize="10"
Margin="0,0,0,12" />
Expand Down
15 changes: 15 additions & 0 deletions DesktopClock/Utilities/PixelShifter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public class PixelShifter
/// </summary>
public int MaxPixelOffset { get; set; } = 4;

/// <summary>
/// Returns an amount to shift horizontally by while staying within the specified bounds.
/// </summary>
public double ShiftX()
{
double pixelsToMoveBy = GetRandomShift();
Expand All @@ -26,6 +29,9 @@ public double ShiftX()
return pixelsToMoveBy;
}

/// <summary>
/// Returns an amount to shift vertically by while staying within the specified bounds.
/// </summary>
public double ShiftY()
{
double pixelsToMoveBy = GetRandomShift();
Expand All @@ -34,8 +40,17 @@ public double ShiftY()
return pixelsToMoveBy;
}

/// <summary>
/// Returns a random amount to shift by within the specified amount.
/// </summary>
private int GetRandomShift() => _random.Next(-PixelsPerShift, PixelsPerShift + 1);

/// <summary>
/// Returns a capped amount to shift by.
/// </summary>
/// <param name="current">The current total amount of shift that has occurred.</param>
/// <param name="offset">The proposed amount to shift by this time.</param>
/// <param name="max">The bounds to stay within in respect to the total shift.</param>
private double GetFinalShiftAmount(double current, double offset, double max)
{
var newTotal = current + offset;
Expand Down

0 comments on commit 011188a

Please sign in to comment.