Files
OpenFloppaClicker/G.cs
T
2026-12-02 22:32:23 -05:00

88 lines
2.5 KiB
C#

using System.Drawing;
using System.Drawing.Drawing2D;
internal static class G
{
public static readonly Color Bg = Color.FromArgb(12, 13, 17);
public static readonly Color Card = Color.FromArgb(21, 22, 29);
public static readonly Color Line = Color.FromArgb(40, 43, 58);
public static readonly Color Acc = Color.FromArgb(90, 140, 255);
public static readonly Color Txt = Color.FromArgb(232, 234, 240);
public static readonly Color Dim = Color.FromArgb(124, 129, 150);
public static readonly Color Ok = Color.FromArgb(72, 207, 142);
public static readonly Font Big = new Font("Segoe UI", 26f, FontStyle.Bold);
public static readonly Font H = new Font("Segoe UI", 11f, FontStyle.Bold);
public static readonly Font Title = new Font("Segoe UI", 15f, FontStyle.Bold);
public static readonly Font N = new Font("Segoe UI", 9.5f);
public static readonly Font S = new Font("Segoe UI", 8.5f);
public static readonly Image Logo = LoadLogo();
private static Image LoadLogo()
{
try
{
return Image.FromStream(typeof(G).Assembly.GetManifestResourceStream("FloppaClicker.Assets.Logo.png"));
}
catch
{
return null;
}
}
public static void Circle(Graphics g, Image img, RectangleF r)
{
if (img == null)
{
return;
}
using GraphicsPath path = RR(r, r.Width);
Region clip = g.Clip;
g.SetClip(path, CombineMode.Intersect);
g.DrawImage(img, r.X, r.Y, r.Width, r.Height);
g.Clip = clip;
}
public static GraphicsPath RR(RectangleF r, float d)
{
GraphicsPath graphicsPath = new GraphicsPath();
graphicsPath.AddArc(r.X, r.Y, d, d, 180f, 90f);
graphicsPath.AddArc(r.Right - d, r.Y, d, d, 270f, 90f);
graphicsPath.AddArc(r.Right - d, r.Bottom - d, d, d, 0f, 90f);
graphicsPath.AddArc(r.X, r.Bottom - d, d, d, 90f, 90f);
graphicsPath.CloseFigure();
return graphicsPath;
}
public static void Fill(Graphics g, RectangleF r, float d, Color c)
{
using GraphicsPath path = RR(r, d);
using SolidBrush brush = new SolidBrush(c);
g.FillPath(brush, path);
}
public static void T(Graphics g, string s, Font f, Color c, float x, float y, StringAlignment a)
{
using SolidBrush brush = new SolidBrush(c);
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = a;
g.DrawString(s, f, brush, x, y, stringFormat);
}
public static Color Mix(Color a, Color b, float t)
{
return Color.FromArgb((int)((float)(int)a.R + (float)(b.R - a.R) * t), (int)((float)(int)a.G + (float)(b.G - a.G) * t), (int)((float)(int)a.B + (float)(b.B - a.B) * t));
}
}