Changed the animation to something less... irritating and made it skip when OptimizeForRemoteDesktop is true.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2370 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-12-10 11:53:57 +00:00
commit 88b869499a

View file

@ -40,18 +40,22 @@ namespace Greenshot {
public partial class AboutForm : BaseForm {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(AboutForm));
private Bitmap gBitmap = new Bitmap(90, 90, PixelFormat.Format32bppRgb);
private ColorAnimator backgroundColor;
private ColorAnimator backgroundAnimation;
private List<RectangleAnimator> pixels = new List<RectangleAnimator>();
private List<Color> colorFlow = new List<Color>();
private List<Color> pixelColors = new List<Color>();
private IntAnimator angleAnimator;
//private IntAnimator angleAnimator;
private Random rand = new Random();
private Color backColor = Color.FromArgb(61, 61, 61);
private Color pixelColor = Color.FromArgb(138, 255, 0);
private readonly Color backColor = Color.FromArgb(61, 61, 61);
private readonly Color pixelColor = Color.FromArgb(138, 255, 0);
// Variables used for the color-cycle
private int waitFrames = 0;
private int colorIndex = 0;
private int scrollCount = 0;
private bool hasAnimationsLeft;
// Variables are used to define the location of the dots
private const int w = 13;
private const int p1 = 7;
private const int p2 = p1 + w;
@ -61,6 +65,9 @@ namespace Greenshot {
private const int p6 = p5 + w;
private const int p7 = p6 + w;
/// <summary>
/// The location of every dot in the "G"
/// </summary>
private List<Point> gSpots = new List<Point>() {
// Top row
new Point(p2, p1), // 0
@ -106,11 +113,12 @@ namespace Greenshot {
// 14 15 16 17
// 18 19 20 21 22 23
// The order in which we draw the dots & flow the collors.
List<int> flowOrder = new List<int>() { 4, 3, 2, 1, 0, 5, 6, 7, 8, 9, 10, 14, 15, 18, 19, 20, 21, 22, 23, 16, 17, 13, 12, 11 };
List<int> flowOrder = new List<int>() {
4, 3, 2, 1, 0, 5, 6, 7, 8, 9, 10, 14, 15, 18, 19, 20, 21, 22, 23, 16, 17, 13, 12, 11
};
/// <summary>
/// Constructor
/// </summary>
public AboutForm() {
EnableAnimation = true;
//
@ -132,17 +140,40 @@ namespace Greenshot {
//Random rand = new Random();
// Number of frames the "fade-in" takes
int frames = CalculateFrames(3000);
int frames = CalculateFrames(1400);
// The number of frames the color-cycle waits before it starts
waitFrames = CalculateFrames(5000);
// Every pixel is created after pixelWaitFrames frames, which is increased in the loop.
int pixelWaitFrames = CalculateFrames(100);
// Create pixels
foreach (Point gSpot in gSpots) {
RectangleAnimator pixelAnimation = new RectangleAnimator(new Rectangle(p4, p3, 0, 0), new Rectangle(gSpot.X, gSpot.Y, w-2, w-2), frames, EasingType.Sine, EasingMode.EaseIn);
for (int index = 0; index < gSpots.Count; index++) {
// Read the pixels in the order of the flow
Point gSpot = gSpots[flowOrder[index]];
// Create the animation, first we do nothing (on the final destination)
RectangleAnimator pixelAnimation;
// If the optimize for Terminal Server is set we make the animation without much ado
if (OptimizeForTerminalServer) {
// No animation
pixelAnimation = new RectangleAnimator(new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), 1, EasingType.Cubic, EasingMode.EaseIn);
} else {
// Create the animation, first we do nothing (on the final destination)
pixelAnimation = new RectangleAnimator(new Rectangle(gSpot.X, gSpot.Y, 0, 0), new Rectangle(gSpot.X, gSpot.Y, 0, 0), pixelWaitFrames, EasingType.Cubic, EasingMode.EaseIn);
// And than we size to the wanted size.
pixelAnimation.QueueDestinationLeg(new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), frames);
}
// Increase the wait frames
pixelWaitFrames += CalculateFrames(100);
// Add to the list of to be animated pixels
pixels.Add(pixelAnimation);
// Add a color to the list for this pixel.
pixelColors.Add(pixelColor);
}
// Make sure the frame "loop" knows we have to animate
hasAnimationsLeft = true;
// Pixel Color animation
// Pixel Color cycle colors, here we use a pre-animated loop which stores the values.
ColorAnimator pixelColorAnimator = new ColorAnimator(pixelColor, Color.FromArgb(255, 255, 255), 6, EasingType.Quadratic, EasingMode.EaseIn);
pixelColorAnimator.QueueDestinationLeg(pixelColor, 6, EasingType.Quadratic, EasingMode.EaseOut);
do {
@ -150,10 +181,10 @@ namespace Greenshot {
pixelColorAnimator.Next();
} while (pixelColorAnimator.hasNext);
// color animation
backgroundColor = new ColorAnimator(this.BackColor, backColor, frames, EasingType.Linear, EasingMode.EaseIn);
// color animation for the background
backgroundAnimation = new ColorAnimator(this.BackColor, backColor, frames, EasingType.Linear, EasingMode.EaseIn);
// Angle animation
angleAnimator = new IntAnimator(-30, 20, frames, EasingType.Sine, EasingMode.EaseIn);
// angleAnimator = new IntAnimator(-30, 20, frames, EasingType.Sine, EasingMode.EaseIn);
}
/// <summary>
@ -173,26 +204,40 @@ namespace Greenshot {
}
}
/// <summary>
/// Called from the AnimatingForm, for every frame
/// </summary>
protected override void Animate() {
if (!OptimizeForTerminalServer) {
// Color cycle
if (waitFrames != 0) {
waitFrames--;
// Check if there is something else to do, if not we return so we don't occupy the CPU
if (!hasAnimationsLeft) {
return;
}
} else if (scrollCount < (pixelColors.Count + colorFlow.Count)) {
// Scroll colors, the scrollCount is the amount of pixels + the amount of colors to cycle.
for (int index = pixelColors.Count - 1; index > 0; index--) {
pixelColors[flowOrder[index]] = pixelColors[flowOrder[index-1]];
pixelColors[index] = pixelColors[index - 1];
}
// Keep adding from the colors to cycle until there is nothing left
if (colorIndex < colorFlow.Count) {
pixelColors[flowOrder[0]] = colorFlow[colorIndex++];
pixelColors[0] = colorFlow[colorIndex++];
}
scrollCount++;
} else {
// Reset values, wait X time for the next one
waitFrames = CalculateFrames(rand.Next(40000));
waitFrames = CalculateFrames(3000 + rand.Next(35000));
colorIndex = 0;
scrollCount = 0;
// Check if there is something else to do, if not we return so we don't occupy the CPU
if (!hasAnimationsLeft) {
return;
}
}
} else if (!hasAnimationsLeft) {
return;
}
// Draw the "G"
@ -202,17 +247,22 @@ namespace Greenshot {
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.Clear(backgroundColor.Next());
graphics.Clear(backgroundAnimation.Next());
graphics.TranslateTransform(2, -2);
graphics.RotateTransform(angleAnimator.Next());
//graphics.RotateTransform(angleAnimator.Next());
graphics.RotateTransform(20);
using (SolidBrush brush = new SolidBrush(pixelColor)) {
int index = 0;
// We asume there is nothing to animate in the next Animate loop
hasAnimationsLeft = false;
// Pixels of the G
foreach (RectangleAnimator pixel in pixels) {
brush.Color = pixelColors[index++];
graphics.FillEllipse(brush, pixel.Current);
// If a pixel still has frames left, the hasAnimationsLeft will be true
hasAnimationsLeft = hasAnimationsLeft | pixel.hasNext;
pixel.Next();
}
}