Skip to content

Commit 5511873

Browse files
committed
optimize Shape.Transform
1 parent 9732c4c commit 5511873

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/ImageSharp.Drawing/Processing/Processors/Drawing/DrawPathProcessor.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) Six Labors.
22
// Licensed under the Apache License, Version 2.0.
33

4+
using System.Numerics;
45
using SixLabors.ImageSharp.PixelFormats;
56
using SixLabors.ImageSharp.Processing.Processors;
67

@@ -44,8 +45,9 @@ public DrawPathProcessor(DrawingOptions options, IPen pen, IPath shape)
4445
public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuration configuration, Image<TPixel> source, Rectangle sourceRectangle)
4546
where TPixel : unmanaged, IPixel<TPixel>
4647
{
47-
// offset drawlines to align drawing outlines to pixel centers
48-
var shape = this.Shape.Translate(0.5f, 0.5f).Transform(this.Options.Transform);
48+
// offset drawlines to align drawing outlines to pixel centers, and apply global transform
49+
Matrix3x2 transform = Matrix3x2.CreateTranslation(0.5f, 0.5f) * this.Options.Transform;
50+
IPath shape = this.Shape.Transform(transform);
4951
return new FillRegionProcessor(this.Options, this.Pen.StrokeFill, new ShapePath(shape, this.Pen)).CreatePixelSpecificProcessor(configuration, source, sourceRectangle);
5052
}
5153
}

0 commit comments

Comments
 (0)