mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
Blink animation update
This commit is contained in:
parent
dafcce6568
commit
e99d931266
3 changed files with 28 additions and 25 deletions
|
@ -68,7 +68,7 @@ public Color CurrentColor
|
||||||
|
|
||||||
#endregion Screen ruler
|
#endregion Screen ruler
|
||||||
|
|
||||||
private GlowTimer glowTimer = new GlowTimer();
|
private ColorBlinkAnimation colorBlinkAnimation = new ColorBlinkAnimation();
|
||||||
|
|
||||||
public RectangleRegion()
|
public RectangleRegion()
|
||||||
{
|
{
|
||||||
|
@ -185,7 +185,6 @@ public override void Prepare()
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
glowTimer.Update();
|
|
||||||
AreaManager.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)
|
if (Config.QuickCrop)
|
||||||
{
|
{
|
||||||
sb.AppendLine("[Q] Multi region mode");
|
sb.AppendLine("[Q] Activate multi region mode");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.AppendLine("[Q] Quick capture mode");
|
sb.AppendLine("[Q] Activate quick capture mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.AppendLine("[Mouse wheel] Change magnifier pixel count");
|
sb.AppendLine("[Mouse wheel] Change magnifier pixel count");
|
||||||
|
|
|
@ -25,53 +25,57 @@ You should have received a copy of the GNU General Public License
|
||||||
|
|
||||||
using ShareX.HelpersLib;
|
using ShareX.HelpersLib;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace ShareX.ScreenCaptureLib
|
namespace ShareX.ScreenCaptureLib
|
||||||
{
|
{
|
||||||
public class GlowTimer
|
public class ColorBlinkAnimation
|
||||||
{
|
{
|
||||||
public float Max = 1;
|
public float Max { get; set; }
|
||||||
public float Min = 0;
|
public float Min { get; set; }
|
||||||
public float Current = 0;
|
public float Current { get; set; }
|
||||||
|
public float Speed { get; set; }
|
||||||
|
public Color FromColor { get; set; }
|
||||||
|
public Color ToColor { get; set; }
|
||||||
|
|
||||||
private Stopwatch timer;
|
private Stopwatch timer;
|
||||||
private TimeSpan previousTime;
|
private TimeSpan previousTime;
|
||||||
private int direction = 1;
|
private int direction;
|
||||||
private float increase = 0.75f;
|
|
||||||
|
|
||||||
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();
|
timer = Stopwatch.StartNew();
|
||||||
|
direction = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update()
|
public Color GetColor()
|
||||||
{
|
{
|
||||||
TimeSpan totalElapsed = timer.Elapsed;
|
TimeSpan totalElapsed = timer.Elapsed;
|
||||||
TimeSpan elapsed = totalElapsed - previousTime;
|
TimeSpan elapsed = totalElapsed - previousTime;
|
||||||
previousTime = totalElapsed;
|
previousTime = totalElapsed;
|
||||||
|
|
||||||
Current += (float)elapsed.TotalSeconds * increase * direction;
|
Current += (float)elapsed.TotalSeconds * Speed * direction;
|
||||||
|
|
||||||
if (Current > Max)
|
if (Current > Max)
|
||||||
{
|
{
|
||||||
Current = Max - (Current - Max);
|
Current = Max; //Max - (Current - Max);
|
||||||
direction = -1;
|
direction = -1;
|
||||||
}
|
}
|
||||||
else if (Current < Min)
|
else if (Current < Min)
|
||||||
{
|
{
|
||||||
Current = Min + (Min - Current);
|
Current = Min; //Min + (Min - Current);
|
||||||
direction = 1;
|
direction = 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Color GetColor()
|
return ColorHelpers.Lerp(FromColor, ToColor, Current);
|
||||||
{
|
|
||||||
return ColorHelpers.Lerp(Color.FromArgb(30, 30, 30), Color.FromArgb(100, 100, 100), Current);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -60,7 +60,7 @@
|
||||||
<Compile Include="MonitorRegion.cs" />
|
<Compile Include="MonitorRegion.cs" />
|
||||||
<Compile Include="MonitorRegionDefaultCreator.cs" />
|
<Compile Include="MonitorRegionDefaultCreator.cs" />
|
||||||
<Compile Include="RectangleAnnotateOptions.cs" />
|
<Compile Include="RectangleAnnotateOptions.cs" />
|
||||||
<Compile Include="RegionHelpers\GlowColorTimer.cs" />
|
<Compile Include="RegionHelpers\ColorBlinkAnimation.cs" />
|
||||||
<Compile Include="RegionHelpers\RegionInfo.cs" />
|
<Compile Include="RegionHelpers\RegionInfo.cs" />
|
||||||
<Compile Include="Screencast\FFmpegOptions.cs" />
|
<Compile Include="Screencast\FFmpegOptions.cs" />
|
||||||
<Compile Include="Screencast\FFmpegHelper.cs" />
|
<Compile Include="Screencast\FFmpegHelper.cs" />
|
||||||
|
|
Loading…
Reference in a new issue