/// <summary> /// Draws a geometry. /// </summary> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> public void DrawGeometry(IBrush brush, IPen pen, IGeometryImpl geometry) { if (brush != null) { using (var d2dBrush = CreateBrush(brush, geometry.Bounds.Size)) { if (d2dBrush.PlatformBrush != null) { var impl = (GeometryImpl)geometry; _deviceContext.FillGeometry(impl.Geometry, d2dBrush.PlatformBrush); } } } if (pen != null) { using (var d2dBrush = CreateBrush(pen.Brush, geometry.GetRenderBounds(pen).Size)) using (var d2dStroke = pen.ToDirect2DStrokeStyle(_deviceContext)) { if (d2dBrush.PlatformBrush != null) { var impl = (GeometryImpl)geometry; _deviceContext.DrawGeometry(impl.Geometry, d2dBrush.PlatformBrush, (float)pen.Thickness, d2dStroke); } } } }
/// <summary> /// Initializes a new instance of the <see cref="GeometryNode"/> class. /// </summary> /// <param name="transform">The transform.</param> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> /// <param name="aux">Auxiliary data required to draw the brush.</param> public GeometryNode(Matrix transform, IBrush?brush, IPen?pen, IGeometryImpl geometry, IDisposable?aux) : base(geometry.GetRenderBounds(pen).CalculateBoundsWithLineCaps(pen), transform, aux) { Transform = transform; Brush = brush?.ToImmutable(); Pen = pen?.ToImmutable(); Geometry = geometry; }
/// <summary> /// Initializes a new instance of the <see cref="GeometryNode"/> class. /// </summary> /// <param name="transform">The transform.</param> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> /// <param name="childScenes">Child scenes for drawing visual brushes.</param> public GeometryNode(Matrix transform, IBrush brush, IPen pen, IGeometryImpl geometry, IDictionary <IVisual, Scene> childScenes = null) : base(geometry.GetRenderBounds(pen), transform) { Transform = transform; Brush = brush?.ToImmutable(); Pen = pen?.ToImmutable(); Geometry = geometry; ChildScenes = childScenes; }
/// <summary> /// Initializes a new instance of the <see cref="GeometryNode"/> class. /// </summary> /// <param name="transform">The transform.</param> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="geometry">The geometry.</param> /// <param name="childScenes">Child scenes for drawing visual brushes.</param> public GeometryNode( Matrix transform, IBrush brush, Pen pen, IGeometryImpl geometry, IDictionary <IVisual, Scene> childScenes = null) { Bounds = geometry.GetRenderBounds(pen?.Thickness ?? 0).TransformToAABB(transform); Transform = transform; Brush = brush?.ToImmutable(); Pen = pen?.ToImmutable(); Geometry = geometry; ChildScenes = childScenes; }