private LinearGradientBrush GetCachedLinearGradientBrush(Color color1, Color color2) { long kh = color1.ToArgb(); // high bits long kl = color2.ToArgb(); // low bits var colorKey = (kh << 32) | kl; LinearGradientBrush brush; if (!m_linearGradients.TryGetValue(colorKey, out brush)) { var stops = new GradientStop[2]; stops[0].Color = color1.ToColor4(); stops[0].Position = 0; stops[1].Color = color2.ToColor4(); stops[1].Position = 1; using (var stopCollection = new GradientStopCollection(m_renderTarget, stops, Gamma.StandardRgb, ExtendMode.Clamp)) { var props = new LinearGradientBrushProperties(); brush = new LinearGradientBrush(m_renderTarget, props, stopCollection); } m_linearGradients.Add(colorKey, brush); } return brush; }
/// <summary> /// Clears the drawing area to the specified color</summary> /// <param name="color">The color to which the drawing area is cleared</param> public void Clear(Color color) { m_renderTarget.Clear(color.ToColor4()); }