diff --git a/.travis.yml b/.travis.yml
index 54e4dee2f8..2515ca82a9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,7 @@ matrix:
- os: linux # Ubuntu 14.04
dist: trusty
sudo: required
- dotnet: 2.1.4
+ dotnet: 2.1.401
mono: latest
# - os: osx # OSX 10.11
# osx_image: xcode7.3.1
@@ -21,7 +21,7 @@ branches:
script:
- git submodule -q update --init
- dotnet restore
- - dotnet test tests/ImageSharp.Tests/ImageSharp.Tests.csproj -c Release -f "netcoreapp2.0"
+ - dotnet test tests/ImageSharp.Tests/ImageSharp.Tests.csproj -c Release -f "netcoreapp2.1"
env:
global:
diff --git a/ImageSharp.ruleset b/ImageSharp.ruleset
index 3567dc4b9e..d318b75c2e 100644
--- a/ImageSharp.ruleset
+++ b/ImageSharp.ruleset
@@ -9,5 +9,7 @@
+
+
\ No newline at end of file
diff --git a/ImageSharp.sln b/ImageSharp.sln
index 535e4d0846..1c41d8db51 100644
--- a/ImageSharp.sln
+++ b/ImageSharp.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
-VisualStudioVersion = 15.0.27130.2036
+VisualStudioVersion = 15.0.26730.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionItems", "{C317F1B1-D75E-4C6D-83EB-80367343E0D7}"
ProjectSection(SolutionItems) = preProject
@@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt
NuGet.config = NuGet.config
.github\PULL_REQUEST_TEMPLATE.md = .github\PULL_REQUEST_TEMPLATE.md
README.md = README.md
+ run-tests.ps1 = run-tests.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{815C0625-CD3D-440F-9F80-2D83856AB7AE}"
diff --git a/ImageSharp.sln.DotSettings b/ImageSharp.sln.DotSettings
index 435aad73bf..432f4524a0 100644
--- a/ImageSharp.sln.DotSettings
+++ b/ImageSharp.sln.DotSettings
@@ -343,8 +343,11 @@
<Entry DisplayName="All other members" />
</TypePattern>
</Patterns>
- True
+ False
True
+ // Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
AC
DC
DCT
diff --git a/README.md b/README.md
index 7e47e6b06f..a420c07c8e 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,21 @@
-
-
- ImageSharp
-
-
-
-
-
-
-
+
+
+
+SixLabors.ImageSharp
+
+
+
+[](https://raw.githubusercontent.com/SixLabors/ImageSharp/master/LICENSE)
+[](https://gitter.im/ImageSharp/General?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+[](https://twitter.com/intent/tweet?hashtags=imagesharp,dotnet,oss&text=ImageSharp.+A+new+cross-platform+2D+graphics+API+in+C%23&url=https%3a%2f%2fgithub.com%2fSixLabors%2fImageSharp&via=sixlabors)
+[](#backers)
+[](#sponsors)
+
+
+
### **ImageSharp** is a new, fully featured, fully managed, cross-platform, 2D graphics API.
Designed to democratize image processing, ImageSharp brings you an incredibly powerful yet beautifully simple API.
@@ -19,9 +24,13 @@ Compared to `System.Drawing` we have been able to develop something much more fl
Built against .Net Standard 1.1 ImageSharp can be used in device, cloud, and embedded/IoT scenarios.
+### Documentation
+For all SixLabors projects, including ImageSharp:
+https://sixlabors.github.io/docs/
+
### Installation
-Install stable releases via Nuget;evelopment releases are available via MyGet.
+Install stable releases via Nuget; development releases are available via MyGet.
| Package Name | Release (NuGet) | Nightly (MyGet) |
|--------------------------------|-----------------|-----------------|
@@ -51,12 +60,11 @@ The **ImageSharp** library is made up of multiple packages:
### Questions?
-Do you have questions? We are happy to help! Please [join our gitter channel](https://gitter.im/ImageSharp/General), or ask them on [stackoverflow](https://stackoverflow.com) using the `ImageSharp` tag.
+- Do you have questions? We are happy to help! Please [join our gitter channel](https://gitter.im/ImageSharp/General), or ask them on [stackoverflow](https://stackoverflow.com) using the `ImageSharp` tag. **Do not** open issues for questions!
+- Please read our [Contribution Guide](https://github.com/SixLabors/ImageSharp/blob/master/.github/CONTRIBUTING.md) before opening issues or pull requests!
### API
-API documentation is available at [https://sixlabors.github.io/docs/](https://sixlabors.github.io/docs/)
-
Our API is designed to be simple to consume. Here's an example of the code required to resize an image using the default Bicubic resampler then turn the colors into their grayscale equivalent using the BT709 standard matrix.
On platforms supporting netstandard 1.3+
@@ -100,21 +108,25 @@ using (Image image = new Image(400, 400))
`Rgba32` is our default PixelFormat, equivalent to `System.Drawing Color`. For advanced pixel format usage there are multiple [PixelFormat implementations](https://github.com/SixLabors/ImageSharp/tree/master/src/ImageSharp/PixelFormats) available allowing developers to implement their own color models in the same manner as Microsoft XNA Game Studio and MonoGame.
-**Check out this [blog post](https://sixlabors.com/blog/announcing-imagesharp-beta-1/) or our [Samples Repository](https://github.com/SixLabors/Samples/tree/master/ImageSharp) for more examples!**
+For more examples check out:
+- [Our Documentation](https://sixlabors.github.io/docs/)
+- Our [Samples Repository](https://github.com/SixLabors/Samples/tree/master/ImageSharp)
+- The [beta1 blog post](https://sixlabors.com/blog/announcing-imagesharp-beta-1/)
### Manual build
-If you prefer, you can compile ImageSharp yourself (please do and help!), you'll need:
+If you prefer, you can compile ImageSharp yourself (please do and help!)
-- [Visual Studio 2017 (or above)](https://www.visualstudio.com/en-us/news/releasenotes/vs2017-relnotes)
-- The [.NET Core SDK Installer](https://www.microsoft.com/net/core#windows) - Non VSCode link.
+- Using [Visual Studio 2017](https://visualstudio.microsoft.com/vs/)
+ - Make sure you have the latest version installed
+ - Make sure you have [the .NET Core 2.1 SDK](https://www.microsoft.com/net/core#windows) installed
-Alternatively on Linux you can use:
+Alternatively, you can work from command line and/or with a lightweight editor on **both Linux/Unix and Windows**:
- [Visual Studio Code](https://code.visualstudio.com/) with [C# Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp)
- [.Net Core](https://www.microsoft.com/net/core#linuxubuntu)
-To clone it locally click the "Clone in Windows" button above or run the following git commands.
+To clone ImageSharp locally click the "Clone in Windows" button above or run the following git commands.
```bash
git clone https://github.com/SixLabors/ImageSharp
@@ -122,7 +134,7 @@ git clone https://github.com/SixLabors/ImageSharp
### How can you help?
-Please... Spread the word, contribute algorithms, submit performance improvements, unit tests, no input is too little.
+Please... Spread the word, contribute algorithms, submit performance improvements, unit tests, no input is too little. Make sure to read our [Contribution Guide](https://github.com/SixLabors/ImageSharp/blob/master/.github/CONTRIBUTING.md) before opening a PR.
### The ImageSharp Team
diff --git a/appveyor.yml b/appveyor.yml
index 8321209905..fccac0c44d 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,18 +1,57 @@
version: 1.0.0.{build}
-image: Visual Studio 2017
+image: Previous Visual Studio 2017
# prevent the double build when a branch has an active PR
skip_branch_with_pr: true
+environment:
+ matrix:
+ - target_framework: netcoreapp2.1
+ is_32bit: False
+
+ - target_framework: netcoreapp2.1
+ is_32bit: True
+
+ - target_framework: net471
+ is_32bit: False
+
+ - target_framework: net471
+ is_32bit: True
+
+ - target_framework: net462
+ is_32bit: False
+
+ - target_framework: net462
+ is_32bit: True
+
+ #- target_framework: mono
+ # is_32bit: False
+ #- target_framework: mono
+ # is_32bit: True
+ #- target_framework: net47
+ # is_32bit: False
+ #- target_framework: net47
+ # is_32bit: True
+
+install:
+ - ps: |
+ if ($env:target_framework -eq "mono") {
+ if ($env:is_32bit -eq "True") {
+ cinst mono --x86
+ } else {
+ cinst mono
+ }
+ }
+
before_build:
- git submodule -q update --init
- - cmd: dotnet --version
+ - cmd: dotnet --info
build_script:
- cmd: build.cmd
test_script:
-- tests\CodeCoverage\CodeCoverage.cmd
+- ps: .\run-tests.ps1 $env:target_framework $env:is_32bit
after_test:
- cmd: appveyor PushArtifact "artifacts\SixLabors.ImageSharp.%APPVEYOR_BUILD_VERSION%.nupkg"
@@ -27,4 +66,4 @@ deploy:
secure: V/lEHP0UeMWIpWd0fiNlY2IgbCnJKQlGdRksECdJbOBdaE20Fl0RNL7WyqHe02o4
artifact: /.*\.nupkg/
on:
- branch: master
+ branch: master
\ No newline at end of file
diff --git a/build.ps1 b/build.ps1
index 2f4d1c949f..35b8344dcc 100644
--- a/build.ps1
+++ b/build.ps1
@@ -8,7 +8,7 @@ $tagRegex = '^v?(\d+\.\d+\.\d+)(-([a-zA-Z]+)\.?(\d*))?$'
# we are running on the build server
$isVersionTag = $env:APPVEYOR_REPO_TAG_NAME -match $tagRegex
- if($isVersionTag){
+ if($isVersionTag) {
Write-Debug "Building commit tagged with a compatable version number"
@@ -26,7 +26,8 @@ $isVersionTag = $env:APPVEYOR_REPO_TAG_NAME -match $tagRegex
$version = "${version}${padded}"
}
- }else {
+ }
+ else {
Write-Debug "Untagged"
$lastTag = (git tag --list --sort=-taggerdate) | Out-String
@@ -100,9 +101,17 @@ dotnet build -c Release /p:packageversion=$version
if ($LASTEXITCODE ){ Exit $LASTEXITCODE }
-if ( $env:CI -ne "True") {
- dotnet test ./tests/ImageSharp.Tests/ImageSharp.Tests.csproj --no-build -c Release
-}
+#
+# TODO: DO WE NEED TO RUN TESTS IMPLICITLY?
+#
+# if ( $env:CI -ne "True") {
+# cd ./tests/ImageSharp.Tests/
+# dotnet xunit -nobuild -c Release -f netcoreapp2.0 --fx-version 2.0.0
+# ./RunExtendedTests.cmd
+# cd ../..
+# }
+#
+
if ($LASTEXITCODE ){ Exit $LASTEXITCODE }
Write-Host "Packaging projects"
diff --git a/run-tests.ps1 b/run-tests.ps1
new file mode 100644
index 0000000000..4aeaa14908
--- /dev/null
+++ b/run-tests.ps1
@@ -0,0 +1,112 @@
+param(
+ [string]$targetFramework,
+ [string]$is32Bit = "False"
+)
+
+if (!$targetFramework){
+ Write-Host "run-tests.ps1 ERROR: targetFramework is undefined!"
+ exit 1
+}
+
+function VerifyPath($path, $errorMessage) {
+ if (!(Test-Path -Path $path)) {
+ Write-Host "run-tests.ps1 $errorMessage `n $xunitRunnerPath"
+ exit 1
+ }
+}
+
+function CheckSubmoduleStatus() {
+ $submoduleStatus = (git submodule status) | Out-String
+ # if the result string is empty, the command failed to run (we didn't capture the error stream)
+ if ($submoduleStatus) {
+ # git has been called successfully, what about the status?
+ if (($submoduleStatus -match "\-") -or ($submoduleStatus -match "\(\(null\)\)"))
+ {
+ # submodule has not been initialized!
+ return 2;
+ }
+ elseif ($submoduleStatus -match "\+")
+ {
+ # submodule is not synced:
+ return 1;
+ }
+ else {
+ # everything fine:
+ return 0;
+ }
+ } else {
+ # git call failed, so we should warn
+ return 3;
+ }
+}
+
+
+if ( ($targetFramework -eq "netcoreapp2.1") -and ($env:CI -eq "True") -and ($is32Bit -ne "True")) {
+ # We execute CodeCoverage.cmd only for one specific job on CI (netcoreapp2.1 + 64bit )
+ $testRunnerCmd = ".\tests\CodeCoverage\CodeCoverage.cmd"
+}
+elseif ($targetFramework -eq "mono") {
+ $testDllPath = "$PSScriptRoot\tests\ImageSharp.Tests\bin\Release\net462\SixLabors.ImageSharp.Tests.dll"
+ VerifyPath($testDllPath, "test dll missing:")
+
+ $xunitRunnerPath = "${env:HOMEPATH}\.nuget\packages\xunit.runner.console\2.3.1\tools\net452\"
+
+ VerifyPath($xunitRunnerPath, "xunit console runner is missing on path:")
+
+ cd "$xunitRunnerPath"
+
+ if ($is32Bit -ne "True") {
+ $monoPath = "${env:PROGRAMFILES}\Mono\bin\mono.exe"
+ }
+ else {
+ $monoPath = "${env:ProgramFiles(x86)}\Mono\bin\mono.exe"
+ }
+
+ VerifyPath($monoPath, "mono runtime missing:")
+
+ $testRunnerCmd = "& `"${monoPath}`" .\xunit.console.exe `"${testDllPath}`""
+}
+else {
+ cd .\tests\ImageSharp.Tests
+ $xunitArgs = "-nobuild -c Release -framework $targetFramework"
+
+ if ($targetFramework -eq "netcoreapp2.1") {
+ # There were issues matching the correct installed runtime if we do not specify it explicitly:
+ $xunitArgs += " --fx-version 2.1.0"
+ }
+
+ if ($is32Bit -eq "True") {
+ $xunitArgs += " -x86"
+ }
+
+ $testRunnerCmd = "dotnet xunit $xunitArgs"
+}
+
+Write-Host "running:"
+Write-Host $testRunnerCmd
+Write-Host "..."
+
+Invoke-Expression $testRunnerCmd
+
+cd $PSScriptRoot
+
+$exitCodeOfTests = $LASTEXITCODE;
+
+if (0 -ne ([int]$exitCodeOfTests)) {
+ # check submodule status
+ $submoduleStatus = CheckSubmoduleStatus
+ if ([int]$submoduleStatus -eq 1) {
+ # not synced
+ Write-Host -ForegroundColor Yellow "Check if submodules are up to date. You can use 'git submodule update' to fix this";
+ } elseif ($submoduleStatus -eq 2) {
+ # not initialized
+ Write-Host -ForegroundColor Yellow "Check if submodules are initialized. You can run 'git submodule init' to initialize them."
+ } elseif ($submoduleStatus -eq 3) {
+ # git not found, maybe submodules not synced?
+ Write-Host -ForegroundColor Yellow "Could not check if submodules are initialized correctly. Maybe git is not installed?"
+ } else {
+ #Write-Host "Submodules are up to date";
+ }
+}
+
+exit $exitCodeOfTests
diff --git a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
index 2c4a286d63..42ef080e53 100644
--- a/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
+++ b/src/ImageSharp.Drawing/ImageSharp.Drawing.csproj
@@ -6,12 +6,13 @@
0.0.1
SixLabors and contributors
netstandard1.1;netstandard2.0
+ 7.2
true
true
SixLabors.ImageSharp.Drawing
SixLabors.ImageSharp.Drawing
Image Draw Shape Path Font
- https://raw.githubusercontent.com/SixLabors/ImageSharp/master/build/icons/imagesharp-logo-128.png
+ https://raw.githubusercontent.com/SixLabors/Branding/master/icons/imagesharp/sixlabors.imagesharp.128.png
https://github.com/SixLabors/ImageSharp
http://www.apache.org/licenses/LICENSE-2.0
git
@@ -36,11 +37,10 @@
-
-
-
-
+
+
+
All
diff --git a/src/ImageSharp.Drawing/Primitives/Region.cs b/src/ImageSharp.Drawing/Primitives/Region.cs
index c85e373fb3..27f039f122 100644
--- a/src/ImageSharp.Drawing/Primitives/Region.cs
+++ b/src/ImageSharp.Drawing/Primitives/Region.cs
@@ -1,6 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
+using System;
using SixLabors.Primitives;
namespace SixLabors.ImageSharp.Primitives
@@ -19,7 +20,7 @@ namespace SixLabors.ImageSharp.Primitives
/// Gets the bounding box that entirely surrounds this region.
///
///
- /// This should always contains all possible points returned from .
+ /// This should always contains all possible points returned from .
///
public abstract Rectangle Bounds { get; }
@@ -28,8 +29,8 @@ namespace SixLabors.ImageSharp.Primitives
///
/// The position along the y axis to find intersections.
/// The buffer.
- /// The point in the buffer to start setting offset.
+ /// A instance in the context of the caller.
/// The number of intersections found.
- public abstract int Scan(float y, float[] buffer, int offset);
+ public abstract int Scan(float y, Span buffer, Configuration configuration);
}
}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Primitives/ShapePath.cs b/src/ImageSharp.Drawing/Primitives/ShapePath.cs
index 2a569f0616..a4fef66a67 100644
--- a/src/ImageSharp.Drawing/Primitives/ShapePath.cs
+++ b/src/ImageSharp.Drawing/Primitives/ShapePath.cs
@@ -1,7 +1,7 @@
// Copyright (c) Six Labors and contributors.
// Licensed under the Apache License, Version 2.0.
-using SixLabors.ImageSharp.Processing.Drawing.Pens;
+using SixLabors.ImageSharp.Processing;
using SixLabors.Shapes;
namespace SixLabors.ImageSharp.Primitives
@@ -16,9 +16,8 @@ namespace SixLabors.ImageSharp.Primitives
///
/// The shape.
/// The pen to apply to the shape.
- // TODO: SixLabors.shape will be moving to a Span/ReadOnlySpan based API shortly use ToArray for now.
public ShapePath(IPath shape, IPen pen)
- : base(shape.GenerateOutline(pen.StrokeWidth, pen.StrokePattern.ToArray()))
+ : base(shape.GenerateOutline(pen.StrokeWidth, pen.StrokePattern))
{
}
}
diff --git a/src/ImageSharp.Drawing/Primitives/ShapeRegion.cs b/src/ImageSharp.Drawing/Primitives/ShapeRegion.cs
index cfd1945d08..812744b895 100644
--- a/src/ImageSharp.Drawing/Primitives/ShapeRegion.cs
+++ b/src/ImageSharp.Drawing/Primitives/ShapeRegion.cs
@@ -2,6 +2,10 @@
// Licensed under the Apache License, Version 2.0.
using System;
+using System.Buffers;
+
+using SixLabors.ImageSharp.Memory;
+using SixLabors.Memory;
using SixLabors.Primitives;
using SixLabors.Shapes;
@@ -39,21 +43,23 @@ namespace SixLabors.ImageSharp.Primitives
public override Rectangle Bounds { get; }
///
- public override int Scan(float y, float[] buffer, int offset)
+ public override int Scan(float y, Span buffer, Configuration configuration)
{
var start = new PointF(this.Bounds.Left - 1, y);
var end = new PointF(this.Bounds.Right + 1, y);
- // TODO: This is a temporary workaround because of the lack of Span API-s on IPath. We should use MemoryManager.Allocate() here!
- var innerBuffer = new PointF[buffer.Length];
- int count = this.Shape.FindIntersections(start, end, innerBuffer, 0);
-
- for (int i = 0; i < count; i++)
+ using (IMemoryOwner tempBuffer = configuration.MemoryAllocator.Allocate(buffer.Length))
{
- buffer[i + offset] = innerBuffer[i].X;
- }
+ Span innerBuffer = tempBuffer.GetSpan();
+ int count = this.Shape.FindIntersections(start, end, innerBuffer);
- return count;
+ for (int i = 0; i < count; i++)
+ {
+ buffer[i] = innerBuffer[i].X;
+ }
+
+ return count;
+ }
}
}
}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs b/src/ImageSharp.Drawing/Processing/BrushApplicator.cs
similarity index 81%
rename from src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs
rename to src/ImageSharp.Drawing/Processing/BrushApplicator.cs
index f665e8408c..770d440656 100644
--- a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/BrushApplicator.cs
+++ b/src/ImageSharp.Drawing/Processing/BrushApplicator.cs
@@ -2,11 +2,14 @@
// Licensed under the Apache License, Version 2.0.
using System;
+using System.Buffers;
+
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.Memory;
using SixLabors.ImageSharp.PixelFormats;
+using SixLabors.Memory;
-namespace SixLabors.ImageSharp.Processing.Drawing.Brushes
+namespace SixLabors.ImageSharp.Processing
{
///
/// primitive that converts a point in to a color for discovering the fill color based on an implementation
@@ -24,10 +27,8 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes
internal BrushApplicator(ImageFrame target, GraphicsOptions options)
{
this.Target = target;
-
this.Options = options;
-
- this.Blender = PixelOperations.Instance.GetPixelBlender(options.BlenderMode);
+ this.Blender = PixelOperations.Instance.GetPixelBlender(options);
}
///
@@ -65,13 +66,13 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes
/// scanlineBuffer will be > scanlineWidth but provide and offset in case we want to share a larger buffer across runs.
internal virtual void Apply(Span scanline, int x, int y)
{
- MemoryManager memoryManager = this.Target.MemoryManager;
+ MemoryAllocator memoryAllocator = this.Target.MemoryAllocator;
- using (IBuffer amountBuffer = memoryManager.Allocate(scanline.Length))
- using (IBuffer overlay = memoryManager.Allocate(scanline.Length))
+ using (IMemoryOwner amountBuffer = memoryAllocator.Allocate(scanline.Length))
+ using (IMemoryOwner overlay = memoryAllocator.Allocate(scanline.Length))
{
- Span amountSpan = amountBuffer.Span;
- Span overlaySpan = overlay.Span;
+ Span amountSpan = amountBuffer.GetSpan();
+ Span overlaySpan = overlay.GetSpan();
for (int i = 0; i < scanline.Length; i++)
{
@@ -79,12 +80,16 @@ namespace SixLabors.ImageSharp.Processing.Drawing.Brushes
{
amountSpan[i] = scanline[i] * this.Options.BlendPercentage;
}
+ else
+ {
+ amountSpan[i] = scanline[i];
+ }
overlaySpan[i] = this[x + i, y];
}
Span destinationRow = this.Target.GetPixelRowSpan(y).Slice(x, scanline.Length);
- this.Blender.Blend(memoryManager, destinationRow, destinationRow, overlaySpan, amountSpan);
+ this.Blender.Blend(memoryAllocator, destinationRow, destinationRow, overlaySpan, amountSpan);
}
}
}
diff --git a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/Brushes.cs b/src/ImageSharp.Drawing/Processing/Brushes.cs
similarity index 99%
rename from src/ImageSharp.Drawing/Processing/Drawing/Brushes/Brushes.cs
rename to src/ImageSharp.Drawing/Processing/Brushes.cs
index 141ca403b3..c5e7a3e9ff 100644
--- a/src/ImageSharp.Drawing/Processing/Drawing/Brushes/Brushes.cs
+++ b/src/ImageSharp.Drawing/Processing/Brushes.cs
@@ -3,7 +3,7 @@
using SixLabors.ImageSharp.PixelFormats;
-namespace SixLabors.ImageSharp.Processing.Drawing.Brushes
+namespace SixLabors.ImageSharp.Processing
{
///
/// A collection of methods for creating generic brushes.
diff --git a/src/ImageSharp.Drawing/Processing/ColorStop{TPixel}.cs b/src/ImageSharp.Drawing/Processing/ColorStop{TPixel}.cs
new file mode 100644
index 0000000000..7fd0ba7cd3
--- /dev/null
+++ b/src/ImageSharp.Drawing/Processing/ColorStop{TPixel}.cs
@@ -0,0 +1,39 @@
+// Copyright (c) Six Labors and contributors.
+// Licensed under the Apache License, Version 2.0.
+
+using System.Diagnostics;
+
+using SixLabors.ImageSharp.PixelFormats;
+
+namespace SixLabors.ImageSharp.Processing
+{
+ ///
+ /// A struct that defines a single color stop.
+ ///
+ /// The pixel format.
+ [DebuggerDisplay("ColorStop({Ratio} -> {Color}")]
+ public struct ColorStop
+ where TPixel : struct, IPixel
+ {
+ ///
+ /// Initializes a new instance of the struct.
+ ///
+ /// Where should it be? 0 is at the start, 1 at the end of the Gradient.
+ /// What color should be used at that point?
+ public ColorStop(float ratio, TPixel color)
+ {
+ this.Ratio = ratio;
+ this.Color = color;
+ }
+
+ ///
+ /// Gets the point along the defined gradient axis.
+ ///
+ public float Ratio { get; }
+
+ ///
+ /// Gets the color to be used.
+ ///
+ public TPixel Color { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/Drawing/DrawBezierExtensions.cs b/src/ImageSharp.Drawing/Processing/DrawBezierExtensions.cs
similarity index 83%
rename from src/ImageSharp.Drawing/Processing/Drawing/DrawBezierExtensions.cs
rename to src/ImageSharp.Drawing/Processing/DrawBezierExtensions.cs
index 8f075d5c2c..782f5d4d73 100644
--- a/src/ImageSharp.Drawing/Processing/Drawing/DrawBezierExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/DrawBezierExtensions.cs
@@ -2,12 +2,10 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Drawing.Brushes;
-using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.Primitives;
using SixLabors.Shapes;
-namespace SixLabors.ImageSharp.Processing.Drawing
+namespace SixLabors.ImageSharp.Processing
{
///
/// Adds extensions that allow the drawing of Bezier paths to the type.
@@ -19,14 +17,14 @@ namespace SixLabors.ImageSharp.Processing.Drawing
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The brush.
/// The thickness.
/// The points.
- /// The options.
/// The .
- public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points, GraphicsOptions options)
+ public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, float thickness, params PointF[] points)
where TPixel : struct, IPixel
- => source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)), options);
+ => source.Draw(options, new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)));
///
/// Draws the provided points as an open Bezier path at the provided thickness with the supplied brush
@@ -37,7 +35,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points)
+ public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IBrush brush, float thickness, params PointF[] points)
where TPixel : struct, IPixel
=> source.Draw(new Pen(brush, thickness), new Path(new CubicBezierLineSegment(points)));
@@ -50,7 +48,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points)
+ public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, TPixel color, float thickness, params PointF[] points)
where TPixel : struct, IPixel
=> source.DrawBeziers(new SolidBrush(color), thickness, points);
@@ -59,27 +57,27 @@ namespace SixLabors.ImageSharp.Processing.Drawing
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The color.
/// The thickness.
/// The points.
- /// The options.
/// The .
- public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
+ public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, GraphicsOptions options, TPixel color, float thickness, params PointF[] points)
where TPixel : struct, IPixel
- => source.DrawBeziers(new SolidBrush(color), thickness, points, options);
+ => source.DrawBeziers(options, new SolidBrush(color), thickness, points);
///
/// Draws the provided points as an open Bezier path with the supplied pen
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The pen.
/// The points.
- /// The options.
/// The .
- public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IPen pen, PointF[] points, GraphicsOptions options)
+ public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, GraphicsOptions options, IPen pen, params PointF[] points)
where TPixel : struct, IPixel
- => source.Draw(pen, new Path(new CubicBezierLineSegment(points)), options);
+ => source.Draw(options, pen, new Path(new CubicBezierLineSegment(points)));
///
/// Draws the provided points as an open Bezier path with the supplied pen
@@ -89,7 +87,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The pen.
/// The points.
/// The .
- public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IPen pen, PointF[] points)
+ public static IImageProcessingContext DrawBeziers(this IImageProcessingContext source, IPen pen, params PointF[] points)
where TPixel : struct, IPixel
=> source.Draw(pen, new Path(new CubicBezierLineSegment(points)));
}
diff --git a/src/ImageSharp.Drawing/Processing/Drawing/DrawImageExtensions.cs b/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs
similarity index 55%
rename from src/ImageSharp.Drawing/Processing/Drawing/DrawImageExtensions.cs
rename to src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs
index 6187682067..8ccbe22acb 100644
--- a/src/ImageSharp.Drawing/Processing/Drawing/DrawImageExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/DrawImageExtensions.cs
@@ -2,10 +2,10 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Drawing.Processors;
+using SixLabors.ImageSharp.Processing.Processors.Drawing;
using SixLabors.Primitives;
-namespace SixLabors.ImageSharp.Processing.Drawing
+namespace SixLabors.ImageSharp.Processing
{
///
/// Adds extensions that allow the drawing of images to the type.
@@ -20,9 +20,9 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The image to blend with the currently processing image.
/// The opacity of the image to blend. Must be between 0 and 1.
/// The .
- public static IImageProcessingContext Blend(this IImageProcessingContext source, Image image, float opacity)
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, float opacity)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, opacity));
+ => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity));
///
/// Draws the given image together with the current one by blending their pixels.
@@ -30,65 +30,92 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The pixel format.
/// The image this method extends.
/// The image to blend with the currently processing image.
- /// The blending mode.
+ /// The blending mode.
/// The opacity of the image to blend. Must be between 0 and 1.
/// The .
- public static IImageProcessingContext Blend(this IImageProcessingContext source, Image image, PixelBlenderMode blender, float opacity)
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode colorBlending, float opacity)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, opacity, blender));
-
+ => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity));
+
///
/// Draws the given image together with the current one by blending their pixels.
///
/// The pixel format.
/// The image this method extends.
/// The image to blend with the currently processing image.
- /// The options, including the blending type and blending amount.
+ /// The color blending mode.
+ /// The alpha composition mode.
+ /// The opacity of the image to blend. Must be between 0 and 1.
/// The .
- public static IImageProcessingContext Blend(this IImageProcessingContext source, Image image, GraphicsOptions options)
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity)
where TPixel : struct, IPixel
- {
- return source.ApplyProcessor(new DrawImageProcessor(image, options));
- }
-
+ => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, colorBlending, alphaComposition, opacity));
+
///
/// Draws the given image together with the current one by blending their pixels.
///
- /// The image this method extends.
+ /// The pixel format.
+ /// The image this method extends.
/// The image to blend with the currently processing image.
+ /// The options, including the blending type and blending amount.
+ /// The .
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, GraphicsOptions options)
+ where TPixel : struct, IPixel
+ => source.ApplyProcessor(new DrawImageProcessor(image, Point.Empty, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage));
+
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
/// The pixel format.
- /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
/// The location to draw the blended image.
+ /// The opacity of the image to blend. Must be between 0 and 1.
/// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, float opacity, Point location)
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, float opacity)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, location, opacity));
-
+ => source.ApplyProcessor(new DrawImageProcessor(image, location, GraphicsOptions.Default.ColorBlendingMode, GraphicsOptions.Default.AlphaCompositionMode, opacity));
+
///
/// Draws the given image together with the current one by blending their pixels.
- ///
- /// The image this method extends.
- /// The image to blend with the currently processing image.
+ ///
/// The pixel format.
- /// The type of bending to apply.
- /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
/// The location to draw the blended image.
+ /// The color blending to apply.
+ /// The opacity of the image to blend. Must be between 0 and 1.
/// The .
- public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, PixelBlenderMode blender, float opacity, Point location)
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, PixelColorBlendingMode colorBlending, float opacity)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, location, opacity, blender));
-
+ => source.ApplyProcessor(new DrawImageProcessor(image, location, colorBlending, GraphicsOptions.Default.AlphaCompositionMode, opacity));
+
///
/// Draws the given image together with the current one by blending their pixels.
- ///
- /// The image this method extends.
- /// The image to blend with the currently processing image.
+ ///
/// The pixel format.
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
/// The location to draw the blended image.
+ /// The color blending to apply.
+ /// The alpha composition mode.
+ /// The opacity of the image to blend. Must be between 0 and 1.
+ /// The .
+ public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, PixelColorBlendingMode colorBlending, PixelAlphaCompositionMode alphaComposition, float opacity)
+ where TPixel : struct, IPixel
+ => source.ApplyProcessor(new DrawImageProcessor(image, location, colorBlending, alphaComposition, opacity));
+
+ ///
+ /// Draws the given image together with the current one by blending their pixels.
+ ///
+ /// The pixel format.
+ /// The image this method extends.
+ /// The image to blend with the currently processing image.
+ /// The location to draw the blended image.
/// The options containing the blend mode and opacity.
/// The .
public static IImageProcessingContext DrawImage(this IImageProcessingContext source, Image image, Point location, GraphicsOptions options)
where TPixel : struct, IPixel
- => source.ApplyProcessor(new DrawImageProcessor(image, location, options));
+ => source.ApplyProcessor(new DrawImageProcessor(image, location, options.ColorBlendingMode, options.AlphaCompositionMode, options.BlendPercentage));
}
}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/Drawing/DrawLineExtensions.cs b/src/ImageSharp.Drawing/Processing/DrawLineExtensions.cs
similarity index 83%
rename from src/ImageSharp.Drawing/Processing/Drawing/DrawLineExtensions.cs
rename to src/ImageSharp.Drawing/Processing/DrawLineExtensions.cs
index 9d2ea0c1d8..9084b30efe 100644
--- a/src/ImageSharp.Drawing/Processing/Drawing/DrawLineExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/DrawLineExtensions.cs
@@ -2,12 +2,10 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Drawing.Brushes;
-using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.Primitives;
using SixLabors.Shapes;
-namespace SixLabors.ImageSharp.Processing.Drawing
+namespace SixLabors.ImageSharp.Processing
{
///
/// Adds extensions that allow the drawing of lines to the type.
@@ -19,14 +17,14 @@ namespace SixLabors.ImageSharp.Processing.Drawing
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The brush.
/// The thickness.
/// The points.
- /// The options.
/// The .
- public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points, GraphicsOptions options)
+ public static IImageProcessingContext DrawLines(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, float thickness, params PointF[] points)
where TPixel : struct, IPixel
- => source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points)), options);
+ => source.Draw(options, new Pen(brush, thickness), new Path(new LinearLineSegment(points)));
///
/// Draws the provided Points as an open Linear path at the provided thickness with the supplied brush
@@ -37,7 +35,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points)
+ public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IBrush brush, float thickness, params PointF[] points)
where TPixel : struct, IPixel
=> source.Draw(new Pen(brush, thickness), new Path(new LinearLineSegment(points)));
@@ -50,7 +48,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawLines(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points)
+ public static IImageProcessingContext DrawLines(this IImageProcessingContext source, TPixel color, float thickness, params PointF[] points)
where TPixel : struct, IPixel
=> source.DrawLines(new SolidBrush(color), thickness, points);
@@ -59,27 +57,27 @@ namespace SixLabors.ImageSharp.Processing.Drawing
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The color.
/// The thickness.
/// The points.
- /// The options.
/// The .>
- public static IImageProcessingContext DrawLines(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
+ public static IImageProcessingContext DrawLines(this IImageProcessingContext source, GraphicsOptions options, TPixel color, float thickness, params PointF[] points)
where TPixel : struct, IPixel
- => source.DrawLines(new SolidBrush(color), thickness, points, options);
+ => source.DrawLines(options, new SolidBrush(color), thickness, points);
///
/// Draws the provided Points as an open Linear path with the supplied pen
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The pen.
/// The points.
- /// The options.
/// The .
- public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IPen pen, PointF[] points, GraphicsOptions options)
+ public static IImageProcessingContext DrawLines(this IImageProcessingContext source, GraphicsOptions options, IPen pen, params PointF[] points)
where TPixel : struct, IPixel
- => source.Draw(pen, new Path(new LinearLineSegment(points)), options);
+ => source.Draw(options, pen, new Path(new LinearLineSegment(points)));
///
/// Draws the provided Points as an open Linear path with the supplied pen
@@ -89,8 +87,8 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The pen.
/// The points.
/// The .
- public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IPen pen, PointF[] points)
+ public static IImageProcessingContext DrawLines(this IImageProcessingContext source, IPen pen, params PointF[] points)
where TPixel : struct, IPixel
=> source.Draw(pen, new Path(new LinearLineSegment(points)));
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/Drawing/DrawPathCollectionExtensions.cs b/src/ImageSharp.Drawing/Processing/DrawPathCollectionExtensions.cs
similarity index 85%
rename from src/ImageSharp.Drawing/Processing/Drawing/DrawPathCollectionExtensions.cs
rename to src/ImageSharp.Drawing/Processing/DrawPathCollectionExtensions.cs
index d148638ae1..0d3abf297e 100644
--- a/src/ImageSharp.Drawing/Processing/Drawing/DrawPathCollectionExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/DrawPathCollectionExtensions.cs
@@ -2,11 +2,9 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Drawing.Brushes;
-using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.Shapes;
-namespace SixLabors.ImageSharp.Processing.Drawing
+namespace SixLabors.ImageSharp.Processing
{
///
/// Adds extensions that allow the drawing of collections of polygon outlines to the type.
@@ -18,16 +16,16 @@ namespace SixLabors.ImageSharp.Processing.Drawing
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The pen.
/// The paths.
- /// The options.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPathCollection paths, GraphicsOptions options)
+ public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, IPen pen, IPathCollection paths)
where TPixel : struct, IPixel
{
foreach (IPath path in paths)
{
- source.Draw(pen, path, options);
+ source.Draw(options, pen, path);
}
return source;
@@ -43,21 +41,21 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The .
public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPathCollection paths)
where TPixel : struct, IPixel
- => source.Draw(pen, paths, GraphicsOptions.Default);
+ => source.Draw(GraphicsOptions.Default, pen, paths);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The brush.
/// The thickness.
/// The shapes.
- /// The options.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPathCollection paths, GraphicsOptions options)
+ public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, float thickness, IPathCollection paths)
where TPixel : struct, IPixel
- => source.Draw(new Pen(brush, thickness), paths, options);
+ => source.Draw(options, new Pen(brush, thickness), paths);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
@@ -77,14 +75,14 @@ namespace SixLabors.ImageSharp.Processing.Drawing
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The color.
/// The thickness.
/// The paths.
- /// The options.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPathCollection paths, GraphicsOptions options)
+ public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, TPixel color, float thickness, IPathCollection paths)
where TPixel : struct, IPixel
- => source.Draw(new SolidBrush(color), thickness, paths, options);
+ => source.Draw(options, new SolidBrush(color), thickness, paths);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
diff --git a/src/ImageSharp.Drawing/Processing/Drawing/DrawPathExtensions.cs b/src/ImageSharp.Drawing/Processing/DrawPathExtensions.cs
similarity index 84%
rename from src/ImageSharp.Drawing/Processing/Drawing/DrawPathExtensions.cs
rename to src/ImageSharp.Drawing/Processing/DrawPathExtensions.cs
index a795ee295b..4dbe942f2b 100644
--- a/src/ImageSharp.Drawing/Processing/Drawing/DrawPathExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/DrawPathExtensions.cs
@@ -3,11 +3,9 @@
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Primitives;
-using SixLabors.ImageSharp.Processing.Drawing.Brushes;
-using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.Shapes;
-namespace SixLabors.ImageSharp.Processing.Drawing
+namespace SixLabors.ImageSharp.Processing
{
///
/// Adds extensions that allow the drawing of polygon outlines to the type.
@@ -19,13 +17,13 @@ namespace SixLabors.ImageSharp.Processing.Drawing
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The pen.
/// The path.
- /// The options.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPath path, GraphicsOptions options)
+ public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, IPen pen, IPath path)
where TPixel : struct, IPixel
- => source.Fill(pen.StrokeFill, new ShapePath(path, pen), options);
+ => source.Fill(options, pen.StrokeFill, new ShapePath(path, pen));
///
/// Draws the outline of the polygon with the provided pen.
@@ -37,21 +35,21 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The .
public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, IPath path)
where TPixel : struct, IPixel
- => source.Draw(pen, path, GraphicsOptions.Default);
+ => source.Draw(GraphicsOptions.Default, pen, path);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The brush.
/// The thickness.
/// The shape.
- /// The options.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, IPath path, GraphicsOptions options)
+ public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, float thickness, IPath path)
where TPixel : struct, IPixel
- => source.Draw(new Pen(brush, thickness), path, options);
+ => source.Draw(options, new Pen(brush, thickness), path);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
@@ -71,14 +69,14 @@ namespace SixLabors.ImageSharp.Processing.Drawing
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The color.
/// The thickness.
/// The path.
- /// The options.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, TPixel color, float thickness, IPath path, GraphicsOptions options)
+ public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, TPixel color, float thickness, IPath path)
where TPixel : struct, IPixel
- => source.Draw(new SolidBrush(color), thickness, path, options);
+ => source.Draw(options, new SolidBrush(color), thickness, path);
///
/// Draws the outline of the polygon with the provided brush at the provided thickness.
@@ -93,4 +91,4 @@ namespace SixLabors.ImageSharp.Processing.Drawing
where TPixel : struct, IPixel
=> source.Draw(new SolidBrush(color), thickness, path);
}
-}
+}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/Drawing/DrawPolygonExtensions.cs b/src/ImageSharp.Drawing/Processing/DrawPolygonExtensions.cs
similarity index 81%
rename from src/ImageSharp.Drawing/Processing/Drawing/DrawPolygonExtensions.cs
rename to src/ImageSharp.Drawing/Processing/DrawPolygonExtensions.cs
index 833b616f89..4dcfe00aa3 100644
--- a/src/ImageSharp.Drawing/Processing/Drawing/DrawPolygonExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/DrawPolygonExtensions.cs
@@ -2,12 +2,10 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Drawing.Brushes;
-using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.Primitives;
using SixLabors.Shapes;
-namespace SixLabors.ImageSharp.Processing.Drawing
+namespace SixLabors.ImageSharp.Processing
{
///
/// Adds extensions that allow the drawing of closed linear polygons to the type.
@@ -19,14 +17,14 @@ namespace SixLabors.ImageSharp.Processing.Drawing
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The brush.
/// The thickness.
/// The points.
- /// The options.
/// The .
- public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points, GraphicsOptions options)
+ public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, GraphicsOptions options, IBrush brush, float thickness, params PointF[] points)
where TPixel : struct, IPixel
- => source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)), options);
+ => source.Draw(options, new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)));
///
/// Draws the provided Points as a closed Linear Polygon with the provided brush at the provided thickness.
@@ -37,7 +35,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IBrush brush, float thickness, PointF[] points)
+ public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IBrush brush, float thickness, params PointF[] points)
where TPixel : struct, IPixel
=> source.Draw(new Pen(brush, thickness), new Polygon(new LinearLineSegment(points)));
@@ -50,7 +48,7 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The thickness.
/// The points.
/// The .
- public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points)
+ public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, TPixel color, float thickness, params PointF[] points)
where TPixel : struct, IPixel
=> source.DrawPolygon(new SolidBrush(color), thickness, points);
@@ -59,14 +57,14 @@ namespace SixLabors.ImageSharp.Processing.Drawing
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The color.
/// The thickness.
/// The points.
- /// The options.
/// The .
- public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, TPixel color, float thickness, PointF[] points, GraphicsOptions options)
+ public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, GraphicsOptions options, TPixel color, float thickness, params PointF[] points)
where TPixel : struct, IPixel
- => source.DrawPolygon(new SolidBrush(color), thickness, points, options);
+ => source.DrawPolygon(options, new SolidBrush(color), thickness, points);
///
/// Draws the provided Points as a closed Linear Polygon with the provided Pen.
@@ -76,21 +74,21 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The pen.
/// The points.
/// The .
- public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IPen pen, PointF[] points)
+ public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IPen pen, params PointF[] points)
where TPixel : struct, IPixel
- => source.Draw(pen, new Polygon(new LinearLineSegment(points)), GraphicsOptions.Default);
+ => source.Draw(GraphicsOptions.Default, pen, new Polygon(new LinearLineSegment(points)));
///
/// Draws the provided Points as a closed Linear Polygon with the provided Pen.
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The pen.
/// The points.
- /// The options.
/// The .
- public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, IPen pen, PointF[] points, GraphicsOptions options)
+ public static IImageProcessingContext DrawPolygon(this IImageProcessingContext source, GraphicsOptions options, IPen pen, params PointF[] points)
where TPixel : struct, IPixel
- => source.Draw(pen, new Polygon(new LinearLineSegment(points)), options);
+ => source.Draw(options, pen, new Polygon(new LinearLineSegment(points)));
}
}
\ No newline at end of file
diff --git a/src/ImageSharp.Drawing/Processing/Drawing/DrawRectangleExtensions.cs b/src/ImageSharp.Drawing/Processing/DrawRectangleExtensions.cs
similarity index 84%
rename from src/ImageSharp.Drawing/Processing/Drawing/DrawRectangleExtensions.cs
rename to src/ImageSharp.Drawing/Processing/DrawRectangleExtensions.cs
index 3d6702be97..918fb1e738 100644
--- a/src/ImageSharp.Drawing/Processing/Drawing/DrawRectangleExtensions.cs
+++ b/src/ImageSharp.Drawing/Processing/DrawRectangleExtensions.cs
@@ -2,12 +2,10 @@
// Licensed under the Apache License, Version 2.0.
using SixLabors.ImageSharp.PixelFormats;
-using SixLabors.ImageSharp.Processing.Drawing.Brushes;
-using SixLabors.ImageSharp.Processing.Drawing.Pens;
using SixLabors.Primitives;
using SixLabors.Shapes;
-namespace SixLabors.ImageSharp.Processing.Drawing
+namespace SixLabors.ImageSharp.Processing
{
///
/// Adds extensions that allow the drawing of rectangles to the type.
@@ -19,13 +17,13 @@ namespace SixLabors.ImageSharp.Processing.Drawing
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The pen.
/// The shape.
- /// The options.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, RectangleF shape, GraphicsOptions options)
+ public static IImageProcessingContext Draw(this IImageProcessingContext source, GraphicsOptions options, IPen pen, RectangleF shape)
where TPixel : struct, IPixel
- => source.Draw(pen, new RectangularePolygon(shape.X, shape.Y, shape.Width, shape.Height), options);
+ => source.Draw(options, pen, new RectangularPolygon(shape.X, shape.Y, shape.Width, shape.Height));
///
/// Draws the outline of the rectangle with the provided pen.
@@ -37,21 +35,21 @@ namespace SixLabors.ImageSharp.Processing.Drawing
/// The .
public static IImageProcessingContext Draw(this IImageProcessingContext source, IPen pen, RectangleF shape)
where TPixel : struct, IPixel
- => source.Draw(pen, shape, GraphicsOptions.Default);
+ => source.Draw(GraphicsOptions.Default, pen, shape);
///
/// Draws the outline of the rectangle with the provided brush at the provided thickness.
///
/// The type of the color.
/// The image this method extends.
+ /// The options.
/// The brush.
/// The thickness.
/// The shape.
- /// The options.
/// The .
- public static IImageProcessingContext Draw(this IImageProcessingContext source, IBrush brush, float thickness, RectangleF shape, GraphicsOptions options)
+ public static IImageProcessingContext Draw