利用C#語言,winform技術,仿360安裝動畫
通過觀察可知,360安裝動畫是幾個個圓不停的放大的過程。也就是同心圓半徑不同的放大。
我利用五個圓,做出類似的效果,為了,區分效果,我設定五個圓利用不同的畫筆。
下面是具體的程式碼:
這個五個半徑做為全域性變數
int x1 = 200;
int x2 = 100;
int x3 = 50;
int x4 = 150;
int x5 = 250;
具體的實現放在timer控制元件中
x1 = x1 + 10;
if (x1 > 300) {
x1 = 50;
}
x2 = x2 + 10;
if (x2 > 300)
{
x2 = 50;
}
x3 = x3 + 10;
if (x3 > 300)
{
x3 = 50;
}
x4 = x4 + 10;
if (x4 > 300)
{
x4 = 50;
}
x5 = x5 + 10;
if (x5 > 300) {
x5 = 50;
}
this.Refresh();
Graphics ghs1 = this.CreateGraphics();
Graphics ghs2 = this.CreateGraphics();
Graphics ghs3 = this.CreateGraphics();
Graphics ghs4 = this.CreateGraphics();
Graphics ghs5 = this.CreateGraphics();
Pen myPen1 = new Pen(Color.Firebrick, 2);
Pen myPen2 = new Pen(Color.Yellow, 2);
Pen myPen3 = new Pen(Color.ForestGreen, 2);
Pen myPen4 = new Pen(Color.Fuchsia, 2);
Pen myPen5 = new Pen(Color.Goldenrod, 2);
ghs1.DrawEllipse(myPen1, 400 - x1 / 2, 300 - x1 / 2, x1, x1);
ghs2.DrawEllipse(myPen2, 400 - x2 / 2, 300 - x2 / 2, x2, x2);
ghs3.DrawEllipse(myPen3, 400 - x3 / 2, 300 - x3 / 2, x3, x3);
ghs4.DrawEllipse(myPen4, 400 - x4 / 2, 300 - x4 / 2, x4, x4);
ghs5.DrawEllipse(myPen5, 400 - x5 / 2, 300 - x5 / 2, x5, x5);