Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Bitmap DrawLevelCard(string AvatarURL, ulong MemberID, string DisplayName, string Discriminator, int Level, double ExpNeeded, double CurrentExp, UserStatus Status, Color CustomColor, string BackgroundURL = null)
- {
- Font Levelfont = GetFontName(16);
- Bitmap img = new Bitmap(935, 285);
- if(BackgroundURL == null || BackgroundURL == "") {
- for (var x = 0; x < img.Width; x++)
- {
- for (var y = 0; y < img.Height; y++)
- {
- img.SetPixel(x, y, Color.FromArgb(255, 44, 47, 51));
- }
- }
- }
- else
- {
- using (Graphics gr1 = Graphics.FromImage(img))
- {
- gr1.SmoothingMode = SmoothingMode.AntiAlias;
- gr1.InterpolationMode = InterpolationMode.High;
- gr1.DrawImage(GetBackgroundImage(BackgroundURL, ImageFormat.Png), new Point(0, 0));
- }
- }
- using (Graphics gr = Graphics.FromImage(img))
- {
- gr.SmoothingMode = SmoothingMode.AntiAlias;
- gr.InterpolationMode = InterpolationMode.High;
- GraphicsPath BackgroundCard = RoundedRect(new Rectangle(25, 35, 885, 215),10);
- GraphicsPath BackExpBar = RoundedRect(new Rectangle(261, 183, 632, 42),20);
- GraphicsPath FrontExpBar = RoundedRect(new Rectangle(262, 184, 630, 40),20);
- double ExpRatio = (CurrentExp / ExpNeeded);
- double widthOfExpBar = (630 * ExpRatio);
- Rectangle ExpBarRec = new Rectangle(262, 184, (int)widthOfExpBar, 40);
- GraphicsPath ExpBar = RoundedRect(ExpBarRec, 20);
- RectangleF rectName = new RectangleF(262, 130, 298, 55);
- RectangleF rectDiscriminator = new RectangleF(550, 130, 110, 54);
- if(BackgroundURL != null || BackgroundURL == "")
- {
- gr.FillPath(new SolidBrush(Color.FromArgb(185, 35, 39, 42)), BackgroundCard);
- }
- else
- {
- gr.FillPath(new SolidBrush(Color.FromArgb(100, 35, 39, 42)), BackgroundCard);
- }
- gr.FillPath(new SolidBrush(Color.FromArgb(255, 20, 20, 20)), BackExpBar);
- gr.FillPath(new SolidBrush(Color.FromArgb(255, 72, 75, 78)), FrontExpBar);
- if(CurrentExp != 0)
- {
- gr.FillPath(new SolidBrush(CustomColor), ExpBar);
- }
- gr.DrawImage(GetAvatarImage(AvatarURL, ImageFormat.Png), new Point(39, 57));
- //gr.FillEllipse(Brushes.Red, 39, 57, 173, 173);
- gr.FillEllipse(Brushes.Black, 164, 172, 51, 51);
- var getStatus = new Dictionary<string, Brush>(){
- { "Online", new SolidBrush(Color.FromArgb(255, 67, 181, 129))},
- { "Idle", new SolidBrush(Color.FromArgb(255, 250, 166, 26))},
- { "DoNotDisturb", new SolidBrush(Color.FromArgb(255, 240, 71, 71))},
- { "Offline", new SolidBrush(Color.FromArgb(255, 133, 144, 147))}
- };
- gr.FillEllipse(getStatus[Status.ToString()], 165, 173, 49, 49);
- var measure = gr.MeasureString(DisplayName, GetFontName(36));
- int width = (int)measure.Width;
- int Beginheight = (int)measure.Height;
- int height = Beginheight;
- var measure2 = gr.MeasureString(Discriminator, GetFontName(24));
- int width2 = (int)measure2.Width;
- int Beginheight2 = (int)measure2.Height;
- int height2 = Beginheight2;
- var measure3 = gr.MeasureString(" / " + ExpNeeded + " Exp", Levelfont);
- int width3 = (int)measure3.Width;
- var measure4 = gr.MeasureString(CurrentExp.ToString(), Levelfont);
- int width4 = (int)measure4.Width;
- int i = 0;
- while (width + width2 >= 440)
- {
- i++;
- measure = gr.MeasureString(DisplayName, GetFontName(36-i));
- width = (int)measure.Width;
- height = (int)measure.Height;
- measure2 = gr.MeasureString(Discriminator, GetFontName(24-i));
- width2 = (int)measure2.Width;
- height2 = (int)measure2.Height;
- }
- gr.DrawString(DisplayName, GetFontName(36 - i), Brushes.White, 265, 125 + (Beginheight - height));
- gr.DrawString(Discriminator, GetFontName(24 - i), Brushes.Gray, 250 + (width), 141 + (Beginheight2 - height2));
- gr.DrawString(" / " + ExpNeeded + " Exp", Levelfont, new SolidBrush(Color.FromArgb(255, 72, 75, 78)), 262 + 630 - width3, 154);
- gr.DrawString(CurrentExp.ToString(), Levelfont, new SolidBrush(CustomColor), 262 + 630 - width3-width4, 154);
- }
- img.Save("C:\\Users\\gunzb\\Desktop\\log\\LevelCard_" + MemberID + ".png");
- img.Dispose();
- return img;
- }
Advertisement
Add Comment
Please, Sign In to add comment