public static long Make(ByteColor color, bool i) { Debug.Assert(Unsafe.SizeOf <bool>() == 1); var ii = (long)Unsafe.As <bool, byte>(ref i); return(ii ^ color.HashCode); }
public static Pen GetPen(ByteColor color, double thickness) { var hashCode = HashCodeMaker.Make(color, thickness); if (_borderPens.TryGetValue(hashCode, out var p)) { return(p); } p = new Pen(GetSolidColorBrush(color), thickness); p.Freeze(); _borderPens.Add(hashCode, p); return(p); }
public static SolidColorBrush GetSolidColorBrush(ByteColor color) { var hashCode = HashCodeMaker.Make(color); if (_solidColorBrushes.TryGetValue(hashCode, out var b)) { return(b); } b = new SolidColorBrush(color.ToColor()); b.Freeze(); _solidColorBrushes.Add(hashCode, b); return(b); }
public static Pen GetCapPen(ByteColor color, double thickness) { var hashCode = HashCodeMaker.Make(color, thickness); if (_capPens.TryGetValue(hashCode, out var p)) { return(p); } p = new Pen(GetSolidColorBrush(color), thickness) { StartLineCap = PenLineCap.Round, EndLineCap = PenLineCap.Round }; p.Freeze(); _capPens.Add(hashCode, p); return(p); }
public static Pen GetDashedPen(ByteColor color, double thickness) { unchecked { var hashCode = HashCodeMaker.Make(color, thickness); if (_dashedPens.TryGetValue(hashCode, out var p)) { return(p); } p = new Pen(GetSolidColorBrush(color), thickness) { DashStyle = DashStyles.Dash }; p.Freeze(); _dashedPens.Add(hashCode, p); return(p); } }
public Pen GetBorderPen(ByteColor color) => Caches.GetPen(color, RoundLayoutValue(FrameworkElementExtensions.BorderWidth));
public static long Make(ByteColor color, double x) { var ix = Unsafe.As <double, long>(ref x); return(ix ^ color.HashCode); }
public static long Make(ByteColor color) { return(color.HashCode); }