/// <summary> /// Initializes a new instance of the <see cref="OpacityMaskNode"/> class that represents an /// opacity mask push. /// </summary> /// <param name="mask">The opacity mask to push.</param> /// <param name="bounds">The bounds of the mask.</param> /// <param name="childScenes">Child scenes for drawing visual brushes.</param> public OpacityMaskNode(IBrush mask, Rect bounds, IDictionary <IVisual, Scene> childScenes = null) : base(Rect.Empty, Matrix.Identity, null) { Mask = mask?.ToImmutable(); MaskBounds = bounds; ChildScenes = childScenes; }
/// <summary> /// Initializes a new instance of the <see cref="GlyphRunNode"/> class. /// </summary> /// <param name="transform">The transform.</param> /// <param name="foreground">The foreground brush.</param> /// <param name="glyphRun">The glyph run to draw.</param> /// <param name="aux">Auxiliary data required to draw the brush.</param> public GlyphRunNode( Matrix transform, IBrush foreground, GlyphRun glyphRun, IDisposable?aux = null) : base(new Rect(glyphRun.Size), transform, aux) { Transform = transform; Foreground = foreground.ToImmutable(); GlyphRun = glyphRun; }
/// <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="GlyphRunNode"/> class. /// </summary> /// <param name="transform">The transform.</param> /// <param name="foreground">The foreground brush.</param> /// <param name="glyphRun">The glyph run to draw.</param> /// <param name="childScenes">Child scenes for drawing visual brushes.</param> public GlyphRunNode( Matrix transform, IBrush foreground, GlyphRun glyphRun, IDictionary <IVisual, Scene>?childScenes = null) : base(new Rect(glyphRun.Size), transform) { Transform = transform; Foreground = foreground.ToImmutable(); GlyphRun = glyphRun; ChildScenes = childScenes; }
void RenderCore(DrawingContext context, IBrush background, IBrush borderBrush, BoxShadows boxShadows, double borderDashOffset, PenLineCap borderLineCap, PenLineJoin borderLineJoin, AvaloniaList <double> borderDashArray) { if (_useComplexRendering) { var backgroundGeometry = _backgroundGeometryCache; if (backgroundGeometry != null) { context.DrawGeometry(background, null, backgroundGeometry); } var borderGeometry = _borderGeometryCache; if (borderGeometry != null) { context.DrawGeometry(borderBrush, null, borderGeometry); } } else { var borderThickness = _borderThickness.Top; IPen pen = null; ImmutableDashStyle?dashStyle = null; if (borderDashArray != null && borderDashArray.Count > 0) { dashStyle = new ImmutableDashStyle(borderDashArray, borderDashOffset); } if (borderBrush != null && borderThickness > 0) { pen = new ImmutablePen( borderBrush.ToImmutable(), borderThickness, dashStyle, borderLineCap, borderLineJoin); } var rect = new Rect(_size); if (!MathUtilities.IsZero(borderThickness)) { rect = rect.Deflate(borderThickness * 0.5); } var rrect = new RoundedRect(rect, _cornerRadius.TopLeft, _cornerRadius.TopRight, _cornerRadius.BottomRight, _cornerRadius.BottomLeft); context.PlatformImpl.DrawRectangle(background, pen, rrect, boxShadows); } }
public EllipseNode( Matrix transform, IBrush?brush, IPen?pen, Rect rect, IDisposable?aux = null) : base(rect.Inflate(pen?.Thickness ?? 0), transform, aux) { Transform = transform; Brush = brush?.ToImmutable(); Pen = pen?.ToImmutable(); Rect = rect; }
/// <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="TextNode"/> class. /// </summary> /// <param name="transform">The transform.</param> /// <param name="foreground">The foreground brush.</param> /// <param name="origin">The draw origin.</param> /// <param name="text">The text to draw.</param> /// <param name="childScenes">Child scenes for drawing visual brushes.</param> public TextNode( Matrix transform, IBrush foreground, Point origin, IFormattedTextImpl text, IDictionary <IVisual, Scene> childScenes = null) { Bounds = new Rect(origin, text.Size).TransformToAABB(transform); Transform = transform; Foreground = foreground?.ToImmutable(); Origin = origin; Text = text; ChildScenes = childScenes; }
/// <summary> /// Initializes a new instance of the <see cref="TextNode"/> class. /// </summary> /// <param name="transform">The transform.</param> /// <param name="foreground">The foreground brush.</param> /// <param name="origin">The draw origin.</param> /// <param name="text">The text to draw.</param> /// <param name="childScenes">Child scenes for drawing visual brushes.</param> public TextNode( Matrix transform, IBrush foreground, Point origin, IFormattedTextImpl text, IDictionary <IVisual, Scene> childScenes = null) : base(text.Bounds.Translate(origin), transform, null) { Transform = transform; Foreground = foreground?.ToImmutable(); Origin = origin; Text = text; 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; }
public EllipseNode( Matrix transform, IBrush?brush, IPen?pen, Rect rect, IDictionary <IVisual, Scene>?childScenes = null) : base(rect.Inflate(pen?.Thickness ?? 0), transform) { Transform = transform; Brush = brush?.ToImmutable(); Pen = pen?.ToImmutable(); Rect = rect; ChildScenes = childScenes; }
/// <summary> /// Initializes a new instance of the <see cref="GlyphRunNode"/> class. /// </summary> /// <param name="transform">The transform.</param> /// <param name="foreground">The foreground brush.</param> /// <param name="glyphRun">The glyph run to draw.</param> /// <param name="baselineOrigin">The baseline origin of the glyph run.</param> /// <param name="childScenes">Child scenes for drawing visual brushes.</param> public GlyphRunNode( Matrix transform, IBrush foreground, GlyphRun glyphRun, Point baselineOrigin, IDictionary <IVisual, Scene> childScenes = null) : base(glyphRun.Bounds, transform, null) { Transform = transform; Foreground = foreground?.ToImmutable(); GlyphRun = glyphRun; BaselineOrigin = baselineOrigin; ChildScenes = childScenes; }
/// <summary> /// Initializes a new instance of the <see cref="RectangleNode"/> class. /// </summary> /// <param name="transform">The transform.</param> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="rect">The rectangle to draw.</param> /// <param name="boxShadows">The box shadow parameters</param> /// <param name="aux">Auxiliary data required to draw the brush.</param> public RectangleNode( Matrix transform, IBrush?brush, IPen?pen, RoundedRect rect, BoxShadows boxShadows, IDisposable?aux = null) : base(boxShadows.TransformBounds(rect.Rect).Inflate((pen?.Thickness ?? 0) / 2), transform, aux) { Transform = transform; Brush = brush?.ToImmutable(); Pen = pen?.ToImmutable(); Rect = rect; BoxShadows = boxShadows; }
private void SetForegroundBrush(IBrush brush, int startIndex, int length) { var key = new FBrushRange(startIndex, length); int index = _foregroundBrushes.FindIndex(v => v.Key.Equals(key)); if (index > -1) { _foregroundBrushes.RemoveAt(index); } if (brush != null) { brush = brush.ToImmutable(); _foregroundBrushes.Insert(0, new KeyValuePair <FBrushRange, IBrush>(key, brush)); } }
/// <summary> /// Initializes a new instance of the <see cref="RectangleNode"/> class. /// </summary> /// <param name="transform">The transform.</param> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="rect">The rectangle to draw.</param> /// <param name="boxShadows">The box shadow parameters</param> /// <param name="childScenes">Child scenes for drawing visual brushes.</param> public RectangleNode( Matrix transform, IBrush brush, IPen pen, RoundedRect rect, BoxShadows boxShadows, IDictionary <IVisual, Scene> childScenes = null) : base(boxShadows.TransformBounds(rect.Rect).Inflate((pen?.Thickness ?? 0) / 2), transform) { Transform = transform; Brush = brush?.ToImmutable(); Pen = pen?.ToImmutable(); Rect = rect; ChildScenes = childScenes; BoxShadows = boxShadows; }
/// <summary> /// Initializes a new instance of the <see cref="RectangleNode"/> class. /// </summary> /// <param name="transform">The transform.</param> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="rect">The rectanle to draw.</param> /// <param name="cornerRadius">The rectangle corner radius.</param> /// <param name="childScenes">Child scenes for drawing visual brushes.</param> public RectangleNode( Matrix transform, IBrush brush, Pen pen, Rect rect, float cornerRadius, IDictionary <IVisual, Scene> childScenes = null) { Bounds = rect.TransformToAABB(transform).Inflate(pen?.Thickness ?? 0); Transform = transform; Brush = brush?.ToImmutable(); Pen = pen?.ToImmutable(); Rect = rect; CornerRadius = cornerRadius; ChildScenes = childScenes; }
/// <summary> /// Initializes a new instance of the <see cref="RectangleNode"/> class. /// </summary> /// <param name="transform">The transform.</param> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="rect">The rectangle to draw.</param> /// <param name="cornerRadius">The rectangle corner radius.</param> /// <param name="childScenes">Child scenes for drawing visual brushes.</param> public RectangleNode( Matrix transform, IBrush brush, Pen pen, Rect rect, float cornerRadius, IDictionary <IVisual, Scene> childScenes = null) : base(rect, transform, pen) { Transform = transform; Brush = brush?.ToImmutable(); Pen = pen?.ToImmutable(); Rect = rect; CornerRadius = cornerRadius; ChildScenes = childScenes; }
/// <summary> /// Initializes a new instance of the <see cref="RectangleNode"/> class. /// </summary> /// <param name="transform">The transform.</param> /// <param name="brush">The fill brush.</param> /// <param name="pen">The stroke pen.</param> /// <param name="rect">The rectangle to draw.</param> /// <param name="radiusY">The radius in the Y dimension of the rounded corners.</param> /// <param name="radiusX">The radius in the X dimension of the rounded corners.</param> /// <param name="childScenes">Child scenes for drawing visual brushes.</param> public RectangleNode( Matrix transform, IBrush brush, IPen pen, Rect rect, double radiusX, double radiusY, IDictionary <IVisual, Scene> childScenes = null) : base(rect, transform, pen) { Transform = transform; Brush = brush?.ToImmutable(); Pen = pen?.ToImmutable(); Rect = rect; RadiusX = radiusX; RadiusY = radiusY; ChildScenes = childScenes; }
void RenderCore(DrawingContext context, IBrush background, IBrush borderBrush, BoxShadows boxShadows) { if (_useComplexRendering) { var backgroundGeometry = _backgroundGeometryCache; if (backgroundGeometry != null) { context.DrawGeometry(background, null, backgroundGeometry); } var borderGeometry = _borderGeometryCache; if (borderGeometry != null) { context.DrawGeometry(borderBrush, null, borderGeometry); } } else { var borderThickness = _borderThickness.Top; IPen pen = null; if (borderBrush != null && borderThickness > 0) { pen = new ImmutablePen(borderBrush.ToImmutable(), borderThickness); } var rect = new Rect(_size); if (!MathUtilities.IsZero(borderThickness)) { rect = rect.Deflate(borderThickness * 0.5); } var rrect = new RoundedRect(rect, _cornerRadius.TopLeft, _cornerRadius.TopRight, _cornerRadius.BottomRight, _cornerRadius.BottomLeft); context.PlatformImpl.DrawRectangle(background, pen, rrect, boxShadows); } }
/// <summary> /// Initializes a new instance of the <see cref="OpacityMaskNode"/> class that represents an /// opacity mask push. /// </summary> /// <param name="mask">The opacity mask to push.</param> /// <param name="bounds">The bounds of the mask.</param> /// <param name="aux">Auxiliary data required to draw the brush.</param> public OpacityMaskNode(IBrush mask, Rect bounds, IDisposable?aux = null) : base(Rect.Empty, Matrix.Identity, aux) { Mask = mask.ToImmutable(); MaskBounds = bounds; }
/// <summary> /// Initializes a new instance of the <see cref="OpacityMaskNode"/> class that represents an /// opacity mask push. /// </summary> /// <param name="mask">The opacity mask to push.</param> /// <param name="bounds">The bounds of the mask.</param> /// <param name="childScenes">Child scenes for drawing visual brushes.</param> public OpacityMaskNode(IBrush mask, Rect bounds, IDictionary <IVisual, Scene> childScenes = null) { Mask = mask?.ToImmutable(); MaskBounds = bounds; ChildScenes = childScenes; }