private string ColorCache(RGBA color) { var hash = color.GetHashCode(); if (!Colors.TryGetValue(hash, out string hex)) { hex = string.Format($"rgba({color.R},{color.G},{color.B},{(float)color.A / 256f:f1})"); Colors.Add(hash, hex); } return(hex); }
private Pen GetCachedPen(RGBA color, float thickness) { var key = (long)color.GetHashCode() | ((long)thickness << 32); Pen pen = null; if (!PenCache.TryGetValue(key, out pen)) { pen = new Pen(Color.FromArgb(color.A, color.R, color.G, color.B), thickness); PenCache.Add(key, pen); } return(pen); }
private SolidBrush GetCachedSolidBrush(RGBA color) { var key = color.GetHashCode(); SolidBrush brush = null; if (!SolidBrushCache.TryGetValue(key, out brush)) { brush = new SolidBrush(Color.FromArgb(color.A, color.R, color.G, color.B)); SolidBrushCache.Add(key, brush); } return(brush); }
public override int GetHashCode() { return (RGBA.GetHashCode() ^ RepeatU.GetHashCode() ^ RepeatV.GetHashCode() ^ OffsetU.GetHashCode() ^ OffsetV.GetHashCode() ^ Rotation.GetHashCode() ^ Glow.GetHashCode() ^ Bump.GetHashCode() ^ Shiny.GetHashCode() ^ Fullbright.GetHashCode() ^ MediaFlags.GetHashCode() ^ TexMapType.GetHashCode() ^ TextureID.GetHashCode()); }