private void _drawGotchi(Graphics gfx, GotchiParams gotchi, GotchiTransform transform) { Bitmap img = gotchi.Image.Bitmap; if (img is null) { return; } // Scale gotchi image so all gotchis are drawn at an appropriate size. int max_w = 75; int max_h = 75; float scale_w = max_w / (float)img.Width; float scale_h = max_h / (float)img.Height; float scale = Math.Min(scale_w, scale_h); int w = (int)(img.Width * scale); int h = (int)(img.Height * scale); // Draw the gotchi's shadow. using (Brush brush = new SolidBrush(Color.FromArgb(40, Color.Black))) { int shadow_w = (int)((float)w * 0.75); gfx.FillEllipse(brush, gotchi.Position.X - (shadow_w / 2), gotchi.Position.Y + h / 2, shadow_w, 10); } // Draw the gotchi. gotchi.Position.X += transform.Offset.X; gotchi.Position.Y += transform.Offset.Y; gfx.TranslateTransform(gotchi.Position.X, gotchi.Position.Y); gfx.RotateTransform(transform.Angle); gfx.TranslateTransform(-gotchi.Position.X, -gotchi.Position.Y); gfx.DrawImage(img, new Rectangle(gotchi.Position.X - (w / 2), gotchi.Position.Y - (h / 2), w, h)); gfx.ResetTransform(); gotchi.Position.X -= transform.Offset.X; gotchi.Position.Y -= transform.Offset.Y; // Draw the emote. _drawEmote(gfx, gotchi.Type, gotchi.Position.X, gotchi.Position.Y + transform.EmoteOffset.Y, w, h); }
// Public methods public void AddGotchi(int x, int y, Bitmap image, GotchiState type) { // Make the background color transparent (if it isn't already). if (!(image is null)) { Color c = image.GetPixel(0, 0); if (c.A > 0) { image.MakeTransparent(image.GetPixel(0, 0)); } } GotchiParams p = new GotchiParams { Position = new Point(x, y), Image = new PossibleOwnershipBitmap(image, false), Type = type }; _gotchi_params.Add(p); }