forked from Blondazz/KeyOverlay
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathFading.cs
More file actions
27 lines (25 loc) · 894 Bytes
/
Fading.cs
File metadata and controls
27 lines (25 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System.Collections.Generic;
using System.ComponentModel;
using SFML.Graphics;
using SFML.System;
namespace KeyOverlay {
public static class Fading
{
public static List<Sprite> GetBackgroundColorFadingTexture(Color backgroundColor, uint windowWidth,
float ratioY) {
var sprites = new List<Sprite>();
var alpha = 255;
var color = backgroundColor;
for (int i = 0; i < 255; i++)
{
Image img = ratioY>=.5f ? new Image(windowWidth, (uint)(2 * ratioY), color) : new Image(windowWidth, 1, color);
var sprite = new Sprite(new Texture(img));
sprite.Position = new Vector2f(0, img.Size.Y * i);
sprites.Add(sprite);
alpha -= 1;
color.A = (byte)alpha;
}
return sprites;
}
}
}