protected override void CreateResources() { _sceneBrush = RenderTarget.CreateSolidColorBrush(Color.Black); // Background grid brush var bitmapTarget = RenderTarget.CreateCompatibleRenderTarget(new SizeF(10, 10)); var gridBrush = bitmapTarget.CreateSolidColorBrush(new ColorF(.93f, .94f, .96f)); bitmapTarget.BeginDraw(); bitmapTarget.FillRectangle(RectangleF.FromLTRB(0, 0, 10, 1), gridBrush); bitmapTarget.FillRectangle(RectangleF.FromLTRB(0, 0, 1, 10), gridBrush); bitmapTarget.EndDraw().ThrowIfFailed(); IBitmap bitmap = bitmapTarget.GetBitmap(); _gridPatternBrush = RenderTarget.CreateBitmapBrush(bitmap, new BitmapBrushProperties(ExtendMode.Wrap, ExtendMode.Wrap)); // Gradient brush Span <GradientStop> stops = stackalloc[] { new GradientStop(0.0f, Color.Gold), new GradientStop(0.85f, new ColorF(Color.Orange, 0.8f)), new GradientStop(1.0f, new ColorF(Color.OrangeRed, 0.7f)) }; _radialGradientBrush = RenderTarget.CreateRadialGradientBrush( new RadialGradientBrushProperties(new PointF(330, 330), new PointF(140, 140), 140, 140), RenderTarget.CreateGradienStopCollection(stops)); }
public static IBitmapBrush CreateRef(this IBitmapBrush objectRef) => ((IBitmapBrush)objectRef.CreateRef(typeof(IBitmapBrush)));