From e99d9312660b7b9d4cc38e206c6bdee8e9b3fa41 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 9 Aug 2015 18:11:54 +0300 Subject: [PATCH] Blink animation update --- .../Forms/RectangleRegion.cs | 11 +++-- ...owColorTimer.cs => ColorBlinkAnimation.cs} | 40 ++++++++++--------- .../ShareX.ScreenCaptureLib.csproj | 2 +- 3 files changed, 28 insertions(+), 25 deletions(-) rename ShareX.ScreenCaptureLib/RegionHelpers/{GlowColorTimer.cs => ColorBlinkAnimation.cs} (66%) diff --git a/ShareX.ScreenCaptureLib/Forms/RectangleRegion.cs b/ShareX.ScreenCaptureLib/Forms/RectangleRegion.cs index 5749e38db..86b25032f 100644 --- a/ShareX.ScreenCaptureLib/Forms/RectangleRegion.cs +++ b/ShareX.ScreenCaptureLib/Forms/RectangleRegion.cs @@ -68,7 +68,7 @@ public Color CurrentColor #endregion Screen ruler - private GlowTimer glowTimer = new GlowTimer(); + private ColorBlinkAnimation colorBlinkAnimation = new ColorBlinkAnimation(); public RectangleRegion() { @@ -185,7 +185,6 @@ public override void Prepare() protected override void Update() { base.Update(); - glowTimer.Update(); AreaManager.Update(); } @@ -209,9 +208,9 @@ protected override void Draw(Graphics g) } } - using (Pen glowingBorderPen = new Pen(glowTimer.GetColor())) + using (Pen blinkBorderPen = new Pen(colorBlinkAnimation.GetColor())) { - g.DrawPath(glowingBorderPen, regionDrawPath); + g.DrawPath(blinkBorderPen, regionDrawPath); } /* @@ -408,11 +407,11 @@ protected virtual void WriteTips(StringBuilder sb) if (Config.QuickCrop) { - sb.AppendLine("[Q] Multi region mode"); + sb.AppendLine("[Q] Activate multi region mode"); } else { - sb.AppendLine("[Q] Quick capture mode"); + sb.AppendLine("[Q] Activate quick capture mode"); } sb.AppendLine("[Mouse wheel] Change magnifier pixel count"); diff --git a/ShareX.ScreenCaptureLib/RegionHelpers/GlowColorTimer.cs b/ShareX.ScreenCaptureLib/RegionHelpers/ColorBlinkAnimation.cs similarity index 66% rename from ShareX.ScreenCaptureLib/RegionHelpers/GlowColorTimer.cs rename to ShareX.ScreenCaptureLib/RegionHelpers/ColorBlinkAnimation.cs index 3fefd583c..ee6db99be 100644 --- a/ShareX.ScreenCaptureLib/RegionHelpers/GlowColorTimer.cs +++ b/ShareX.ScreenCaptureLib/RegionHelpers/ColorBlinkAnimation.cs @@ -25,53 +25,57 @@ You should have received a copy of the GNU General Public License using ShareX.HelpersLib; using System; -using System.Collections.Generic; using System.Diagnostics; using System.Drawing; -using System.Linq; -using System.Text; namespace ShareX.ScreenCaptureLib { - public class GlowTimer + public class ColorBlinkAnimation { - public float Max = 1; - public float Min = 0; - public float Current = 0; + public float Max { get; set; } + public float Min { get; set; } + public float Current { get; set; } + public float Speed { get; set; } + public Color FromColor { get; set; } + public Color ToColor { get; set; } private Stopwatch timer; private TimeSpan previousTime; - private int direction = 1; - private float increase = 0.75f; + private int direction; - public GlowTimer() + public ColorBlinkAnimation() { + Max = 1; + Min = 0; + Current = Min; + Speed = 0.75f; + FromColor = Color.FromArgb(30, 30, 30); + ToColor = Color.FromArgb(100, 100, 100); + timer = Stopwatch.StartNew(); + direction = 1; } - public void Update() + public Color GetColor() { TimeSpan totalElapsed = timer.Elapsed; TimeSpan elapsed = totalElapsed - previousTime; previousTime = totalElapsed; - Current += (float)elapsed.TotalSeconds * increase * direction; + Current += (float)elapsed.TotalSeconds * Speed * direction; if (Current > Max) { - Current = Max - (Current - Max); + Current = Max; //Max - (Current - Max); direction = -1; } else if (Current < Min) { - Current = Min + (Min - Current); + Current = Min; //Min + (Min - Current); direction = 1; } - } - public Color GetColor() - { - return ColorHelpers.Lerp(Color.FromArgb(30, 30, 30), Color.FromArgb(100, 100, 100), Current); + return ColorHelpers.Lerp(FromColor, ToColor, Current); } } } \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj b/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj index 7adefb355..3a802ccd5 100644 --- a/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj +++ b/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj @@ -60,7 +60,7 @@ - +