@@ -17,19 +17,14 @@ internal class BaseGlyphBuilder : IGlyphRenderer
1717 /// The builder. TODO: Should this be a property?
1818 /// </summary>
1919 // ReSharper disable once InconsistentNaming
20- protected readonly PathBuilder builder ;
20+ protected readonly PathDrawer drawer ;
2121#pragma warning restore SA1401 // Fields should be private
22- private readonly List < IPath > paths = new List < IPath > ( ) ;
23- private Vector2 currentPoint = default ;
22+ private readonly List < IPath > paths = new ( ) ;
2423
2524 /// <summary>
2625 /// Initializes a new instance of the <see cref="BaseGlyphBuilder"/> class.
2726 /// </summary>
28- public BaseGlyphBuilder ( )
29- {
30- // glyphs are renderd realative to bottom left so invert the Y axis to allow it to render on top left origin surface
31- this . builder = new PathBuilder ( ) ;
32- }
27+ public BaseGlyphBuilder ( ) => this . drawer = new PathDrawer ( ) ;
3328
3429 /// <summary>
3530 /// Gets the paths that have been rendered by this.
@@ -43,14 +38,12 @@ void IGlyphRenderer.EndText()
4338
4439 /// <inheritdoc/>
4540 void IGlyphRenderer . BeginText ( FontRectangle bounds )
46- {
47- this . BeginText ( bounds ) ;
48- }
41+ => this . BeginText ( bounds ) ;
4942
5043 /// <inheritdoc/>
5144 bool IGlyphRenderer . BeginGlyph ( FontRectangle bounds , GlyphRendererParameters paramaters )
5245 {
53- this . builder . Clear ( ) ;
46+ this . drawer . Clear ( ) ;
5447 this . BeginGlyph ( bounds ) ;
5548 return true ;
5649 }
@@ -59,9 +52,7 @@ bool IGlyphRenderer.BeginGlyph(FontRectangle bounds, GlyphRendererParameters par
5952 /// Begins the figure.
6053 /// </summary>
6154 void IGlyphRenderer . BeginFigure ( )
62- {
63- this . builder . StartFigure ( ) ;
64- }
55+ => this . drawer . StartFigure ( ) ;
6556
6657 /// <summary>
6758 /// Draws a cubic bezier from the current point to the <paramref name="point"/>
@@ -70,57 +61,41 @@ void IGlyphRenderer.BeginFigure()
7061 /// <param name="thirdControlPoint">The third control point.</param>
7162 /// <param name="point">The point.</param>
7263 void IGlyphRenderer . CubicBezierTo ( Vector2 secondControlPoint , Vector2 thirdControlPoint , Vector2 point )
73- {
74- this . builder . AddBezier ( this . currentPoint , secondControlPoint , thirdControlPoint , point ) ;
75- this . currentPoint = point ;
76- }
64+ => this . drawer . CubicBezierTo ( secondControlPoint , thirdControlPoint , point ) ;
7765
7866 /// <summary>
7967 /// Ends the glyph.
8068 /// </summary>
8169 void IGlyphRenderer . EndGlyph ( )
82- {
83- this . paths . Add ( this . builder . Build ( ) ) ;
84- }
70+ => this . paths . Add ( this . drawer . Build ( ) ) ;
8571
8672 /// <summary>
8773 /// Ends the figure.
8874 /// </summary>
8975 void IGlyphRenderer . EndFigure ( )
90- {
91- this . builder . CloseFigure ( ) ;
92- }
76+ => this . drawer . CloseFigure ( ) ;
9377
9478 /// <summary>
9579 /// Draws a line from the current point to the <paramref name="point"/>.
9680 /// </summary>
9781 /// <param name="point">The point.</param>
9882 void IGlyphRenderer . LineTo ( Vector2 point )
99- {
100- this . builder . AddLine ( this . currentPoint , point ) ;
101- this . currentPoint = point ;
102- }
83+ => this . drawer . LineTo ( point ) ;
10384
10485 /// <summary>
10586 /// Moves to current point to the supplied vector.
10687 /// </summary>
10788 /// <param name="point">The point.</param>
10889 void IGlyphRenderer . MoveTo ( Vector2 point )
109- {
110- this . builder . StartFigure ( ) ;
111- this . currentPoint = point ;
112- }
90+ => this . drawer . MoveTo ( point ) ;
11391
11492 /// <summary>
11593 /// Draws a quadratics bezier from the current point to the <paramref name="point"/>
11694 /// </summary>
11795 /// <param name="secondControlPoint">The second control point.</param>
11896 /// <param name="point">The point.</param>
11997 void IGlyphRenderer . QuadraticBezierTo ( Vector2 secondControlPoint , Vector2 point )
120- {
121- this . builder . AddBezier ( this . currentPoint , secondControlPoint , point ) ;
122- this . currentPoint = point ;
123- }
98+ => this . drawer . QuadraticBezierTo ( secondControlPoint , point ) ;
12499
125100 /// <summary>Called before any glyphs have been rendered.</summary>
126101 /// <param name="rect">The bounds the text will be rendered at and at whats size.</param>
0 commit comments