public static ColorLerp ( |
||
from | ||
to | Color | |
speed | float | |
return |
protected override void OnPaint(PaintEventArgs e) { if (uwfHovered || scrollDraging) { scrollDestinationColor = ScrollHoverColor; } else { scrollDestinationColor = ScrollColor; } MathHelper.ColorLerp(scrollDestinationColor, 4, ref scrollCurrentColorA, ref scrollCurrentColorR, ref scrollCurrentColorG, ref scrollCurrentColorB); scrollCurrentColor = Color.FromArgb((int)scrollCurrentColorA, (int)scrollCurrentColorR, (int)scrollCurrentColorR, (int)scrollCurrentColorB); if (scrollOrientation == ScrollOrientation.HorizontalScroll) { int backX = subtractButton.Location.X + subtractButton.Width; e.Graphics.uwfFillRectangle(BackColor, backX, 0, addButton.Location.X - backX, Height); } else { int backY = subtractButton.Location.Y + subtractButton.Height; e.Graphics.uwfFillRectangle(BackColor, 0, backY, Width, addButton.Location.Y - backY); } e.Graphics.uwfFillRectangle(scrollCurrentColor, scrollRect.X, scrollRect.Y, scrollRect.Width, scrollRect.Height); }
protected override void OnPaint(PaintEventArgs e) { if (Hovered) { scrollDestinationColor = ScrollHoverColor; } else { scrollDestinationColor = ScrollColor; } scrollCurrentColor = MathHelper.ColorLerp(scrollCurrentColor, scrollDestinationColor, 4); if (scrollOrientation == ScrollOrientation.HorizontalScroll) { int backX = subtractButton.Location.X + subtractButton.Width; e.Graphics.FillRectangle(BackColor, backX, 0, addButton.Location.X - backX, Height); } else { int backY = subtractButton.Location.Y + subtractButton.Height; e.Graphics.FillRectangle(BackColor, 0, backY, Width, addButton.Location.Y - backY); } e.Graphics.FillRectangle(scrollCurrentColor, scrollRect.X, scrollRect.Y, scrollRect.Width, scrollRect.Height); }
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; // Back. if (Hovered == false || Enabled == false) { currentBackColor = MathHelper.ColorLerp(currentBackColor, BackColor, 5); g.FillRectangle(new SolidBrush(currentBackColor), 0, 0, Width, Height); } else { currentBackColor = MathHelper.ColorLerp(currentBackColor, HoverColor, 5); g.FillRectangle(new SolidBrush(currentBackColor), 0, 0, Width, Height); } // Border. if (Enabled == false) { g.DrawRectangle(new Pen(BorderColor), 0, 0, Width, Height); } else if (Hovered) { g.DrawRectangle(new Pen(BorderHoverColor), 0, 0, Width, Height); } else if (Focused) { g.DrawRectangle(new Pen(BorderSelectColor), 0, 0, Width, Height); } else { g.DrawRectangle(new Pen(BorderColor), 0, 0, Width, Height); } SolidBrush textBrush = new SolidBrush(ForeColor); if (!Enabled) { textBrush.Color = ForeColor + Color.FromArgb(0, 128, 128, 128); } if (Image != null && Image.uTexture != null) { var imageToPaint = Image; var imageColorToPaint = ImageColor; if (Hovered) { if (ImageHover != null) { imageToPaint = ImageHover; } if (ImageHoverColor != null) { imageColorToPaint = ImageHoverColor.Value; } } switch (BackgroundImageLayout) { default: case ImageLayout.None: g.DrawTexture(imageToPaint, 0, 0, Image.Width, Image.Height, imageColorToPaint); break; case ImageLayout.Center: g.DrawTexture(imageToPaint, Width / 2 - Image.Width / 2, Height / 2 - Image.Height / 2, Image.Width, Image.Height, imageColorToPaint); break; case ImageLayout.Stretch: g.DrawTexture(imageToPaint, 0, 0, Width, Height, imageColorToPaint); break; case ImageLayout.Zoom: // TODO: not working. break; } } g.DrawString(Text, Font, textBrush, Padding.Left, Padding.Top, Width - Padding.Left - Padding.Right, Height - Padding.Top - Padding.Bottom, TextAlign); }