Skip to content

Commit dc7b553

Browse files
Merge pull request #257 from stefannikolei/revisit-pen
Revisit pen api
2 parents d63aabc + 2080b0d commit dc7b553

57 files changed

Lines changed: 261 additions & 234 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/ImageSharp.Drawing/Processing/IBrush.cs renamed to src/ImageSharp.Drawing/Processing/Brush.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace SixLabors.ImageSharp.Drawing.Processing
1212
/// A brush is a simple class that will return an <see cref="BrushApplicator{TPixel}" /> that will perform the
1313
/// logic for retrieving pixel values for specific locations.
1414
/// </remarks>
15-
public interface IBrush
15+
public abstract class Brush
1616
{
1717
/// <summary>
1818
/// Creates the applicator for this brush.
@@ -29,7 +29,7 @@ public interface IBrush
2929
/// The <paramref name="region" /> when being applied to things like shapes would usually be the
3030
/// bounding box of the shape not necessarily the bounds of the whole image.
3131
/// </remarks>
32-
BrushApplicator<TPixel> CreateApplicator<TPixel>(
32+
public abstract BrushApplicator<TPixel> CreateApplicator<TPixel>(
3333
Configuration configuration,
3434
GraphicsOptions options,
3535
ImageFrame<TPixel> source,

src/ImageSharp.Drawing/Processing/BrushApplicator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace SixLabors.ImageSharp.Drawing.Processing
88
{
99
/// <summary>
10-
/// Performs the application of an <see cref="IBrush"/> implementation against individual scanlines.
10+
/// Performs the application of an <see cref="Brush"/> implementation against individual scanlines.
1111
/// </summary>
1212
/// <typeparam name="TPixel">The pixel format.</typeparam>
1313
/// <seealso cref="IDisposable" />

src/ImageSharp.Drawing/Processing/Extensions/ClearExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static IImageProcessingContext Clear(this IImageProcessingContext source,
3535
/// <param name="source">The image processing context.</param>
3636
/// <param name="brush">The brush.</param>
3737
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
38-
public static IImageProcessingContext Clear(this IImageProcessingContext source, IBrush brush) =>
38+
public static IImageProcessingContext Clear(this IImageProcessingContext source, Brush brush) =>
3939
source.Clear(source.GetDrawingOptions(), brush);
4040

4141
/// <summary>
@@ -45,7 +45,7 @@ public static IImageProcessingContext Clear(this IImageProcessingContext source,
4545
/// <param name="options">The drawing options.</param>
4646
/// <param name="brush">The brush.</param>
4747
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
48-
public static IImageProcessingContext Clear(this IImageProcessingContext source, DrawingOptions options, IBrush brush)
48+
public static IImageProcessingContext Clear(this IImageProcessingContext source, DrawingOptions options, Brush brush)
4949
=> source.Fill(options.CloneForClearOperation(), brush);
5050

5151
/// <summary>

src/ImageSharp.Drawing/Processing/Extensions/ClearPathExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static IImageProcessingContext Clear(
5050
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
5151
public static IImageProcessingContext Clear(
5252
this IImageProcessingContext source,
53-
IBrush brush,
53+
Brush brush,
5454
IPath region)
5555
=> source.Clear(source.GetDrawingOptions(), brush, region);
5656

@@ -66,7 +66,7 @@ public static IImageProcessingContext Clear(
6666
public static IImageProcessingContext Clear(
6767
this IImageProcessingContext source,
6868
DrawingOptions options,
69-
IBrush brush,
69+
Brush brush,
7070
IPath region)
7171
=> source.Fill(options.CloneForClearOperation(), brush, region);
7272
}

src/ImageSharp.Drawing/Processing/Extensions/ClearRectangleExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static IImageProcessingContext Clear(
4444
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
4545
public static IImageProcessingContext Clear(
4646
this IImageProcessingContext source,
47-
IBrush brush,
47+
Brush brush,
4848
RectangleF rectangle)
4949
=> source.Clear(brush, new RectangularPolygon(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height));
5050

@@ -59,7 +59,7 @@ public static IImageProcessingContext Clear(
5959
public static IImageProcessingContext Clear(
6060
this IImageProcessingContext source,
6161
DrawingOptions options,
62-
IBrush brush,
62+
Brush brush,
6363
RectangleF rectangle)
6464
=> source.Clear(options, brush, new RectangularPolygon(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height));
6565
}

src/ImageSharp.Drawing/Processing/Extensions/DrawBezierExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static class DrawBezierExtensions
2121
public static IImageProcessingContext DrawBeziers(
2222
this IImageProcessingContext source,
2323
DrawingOptions options,
24-
IPen pen,
24+
Pen pen,
2525
params PointF[] points) =>
2626
source.Draw(options, pen, new Path(new CubicBezierLineSegment(points)));
2727

@@ -34,7 +34,7 @@ public static IImageProcessingContext DrawBeziers(
3434
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
3535
public static IImageProcessingContext DrawBeziers(
3636
this IImageProcessingContext source,
37-
IPen pen,
37+
Pen pen,
3838
params PointF[] points) =>
3939
source.Draw(pen, new Path(new CubicBezierLineSegment(points)));
4040

@@ -50,7 +50,7 @@ public static IImageProcessingContext DrawBeziers(
5050
public static IImageProcessingContext DrawBeziers(
5151
this IImageProcessingContext source,
5252
DrawingOptions options,
53-
IBrush brush,
53+
Brush brush,
5454
float thickness,
5555
params PointF[] points) =>
5656
source.Draw(options, new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)));
@@ -65,7 +65,7 @@ public static IImageProcessingContext DrawBeziers(
6565
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
6666
public static IImageProcessingContext DrawBeziers(
6767
this IImageProcessingContext source,
68-
IBrush brush,
68+
Brush brush,
6969
float thickness,
7070
params PointF[] points) =>
7171
source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)));

src/ImageSharp.Drawing/Processing/Extensions/DrawLineExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static class DrawLineExtensions
2222
public static IImageProcessingContext DrawLines(
2323
this IImageProcessingContext source,
2424
DrawingOptions options,
25-
IBrush brush,
25+
Brush brush,
2626
float thickness,
2727
params PointF[] points) =>
2828
source.Draw(options, new Pen(brush, thickness), new Path(new LinearLineSegment(points)));
@@ -37,7 +37,7 @@ public static IImageProcessingContext DrawLines(
3737
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
3838
public static IImageProcessingContext DrawLines(
3939
this IImageProcessingContext source,
40-
IBrush brush,
40+
Brush brush,
4141
float thickness,
4242
params PointF[] points) =>
4343
source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points)));
@@ -85,7 +85,7 @@ public static IImageProcessingContext DrawLines(
8585
public static IImageProcessingContext DrawLines(
8686
this IImageProcessingContext source,
8787
DrawingOptions options,
88-
IPen pen,
88+
Pen pen,
8989
params PointF[] points) =>
9090
source.Draw(options, pen, new Path(new LinearLineSegment(points)));
9191

@@ -98,7 +98,7 @@ public static IImageProcessingContext DrawLines(
9898
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
9999
public static IImageProcessingContext DrawLines(
100100
this IImageProcessingContext source,
101-
IPen pen,
101+
Pen pen,
102102
params PointF[] points) =>
103103
source.Draw(pen, new Path(new LinearLineSegment(points)));
104104
}

src/ImageSharp.Drawing/Processing/Extensions/DrawPathCollectionExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static class DrawPathCollectionExtensions
2121
public static IImageProcessingContext Draw(
2222
this IImageProcessingContext source,
2323
DrawingOptions options,
24-
IPen pen,
24+
Pen pen,
2525
IPathCollection paths)
2626
{
2727
foreach (IPath path in paths)
@@ -40,7 +40,7 @@ public static IImageProcessingContext Draw(
4040
/// <param name="paths">The paths.</param>
4141
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
4242
public static IImageProcessingContext
43-
Draw(this IImageProcessingContext source, IPen pen, IPathCollection paths) =>
43+
Draw(this IImageProcessingContext source, Pen pen, IPathCollection paths) =>
4444
source.Draw(source.GetDrawingOptions(), pen, paths);
4545

4646
/// <summary>
@@ -55,7 +55,7 @@ public static IImageProcessingContext
5555
public static IImageProcessingContext Draw(
5656
this IImageProcessingContext source,
5757
DrawingOptions options,
58-
IBrush brush,
58+
Brush brush,
5959
float thickness,
6060
IPathCollection paths) =>
6161
source.Draw(options, new Pen(brush, thickness), paths);
@@ -70,7 +70,7 @@ public static IImageProcessingContext Draw(
7070
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
7171
public static IImageProcessingContext Draw(
7272
this IImageProcessingContext source,
73-
IBrush brush,
73+
Brush brush,
7474
float thickness,
7575
IPathCollection paths) =>
7676
source.Draw(new Pen(brush, thickness), paths);

src/ImageSharp.Drawing/Processing/Extensions/DrawPathExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public static class DrawPathExtensions
2222
public static IImageProcessingContext Draw(
2323
this IImageProcessingContext source,
2424
DrawingOptions options,
25-
IPen pen,
25+
Pen pen,
2626
IPath path) =>
2727
source.ApplyProcessor(new DrawPathProcessor(options, pen, path));
2828

@@ -33,7 +33,7 @@ public static IImageProcessingContext Draw(
3333
/// <param name="pen">The pen.</param>
3434
/// <param name="path">The path.</param>
3535
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
36-
public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPath path) =>
36+
public static IImageProcessingContext Draw(this IImageProcessingContext source, Pen pen, IPath path) =>
3737
source.Draw(source.GetDrawingOptions(), pen, path);
3838

3939
/// <summary>
@@ -48,7 +48,7 @@ public static IImageProcessingContext Draw(this IImageProcessingContext source,
4848
public static IImageProcessingContext Draw(
4949
this IImageProcessingContext source,
5050
DrawingOptions options,
51-
IBrush brush,
51+
Brush brush,
5252
float thickness,
5353
IPath path) =>
5454
source.Draw(options, new Pen(brush, thickness), path);
@@ -63,7 +63,7 @@ public static IImageProcessingContext Draw(
6363
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
6464
public static IImageProcessingContext Draw(
6565
this IImageProcessingContext source,
66-
IBrush brush,
66+
Brush brush,
6767
float thickness,
6868
IPath path) =>
6969
source.Draw(new Pen(brush, thickness), path);

src/ImageSharp.Drawing/Processing/Extensions/DrawPolygonExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static class DrawPolygonExtensions
1919
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
2020
public static IImageProcessingContext DrawPolygon(
2121
this IImageProcessingContext source,
22-
IPen pen,
22+
Pen pen,
2323
params PointF[] points) =>
2424
source.Draw(source.GetDrawingOptions(), pen, new Polygon(new LinearLineSegment(points)));
2525

@@ -34,7 +34,7 @@ public static IImageProcessingContext DrawPolygon(
3434
public static IImageProcessingContext DrawPolygon(
3535
this IImageProcessingContext source,
3636
DrawingOptions options,
37-
IPen pen,
37+
Pen pen,
3838
params PointF[] points) =>
3939
source.Draw(options, pen, new Polygon(new LinearLineSegment(points)));
4040

@@ -50,7 +50,7 @@ public static IImageProcessingContext DrawPolygon(
5050
public static IImageProcessingContext DrawPolygon(
5151
this IImageProcessingContext source,
5252
DrawingOptions options,
53-
IBrush brush,
53+
Brush brush,
5454
float thickness,
5555
params PointF[] points) =>
5656
source.DrawPolygon(options, new Pen(brush, thickness), points);
@@ -65,7 +65,7 @@ public static IImageProcessingContext DrawPolygon(
6565
/// <returns>The <see cref="IImageProcessingContext"/> to allow chaining of operations.</returns>
6666
public static IImageProcessingContext DrawPolygon(
6767
this IImageProcessingContext source,
68-
IBrush brush,
68+
Brush brush,
6969
float thickness,
7070
params PointF[] points) =>
7171
source.DrawPolygon(new Pen(brush, thickness), points);

0 commit comments

Comments
 (0)