Skip to content

Commit a1b8097

Browse files
Merge pull request #185 from jtjackson/expose_new_properties_on_ipen
Expose JointStyle and EndCapStyle on IPen
2 parents 879f3cf + fb7d82c commit a1b8097

40 files changed

Lines changed: 509 additions & 246 deletions

File tree

Lines changed: 154 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,158 @@
11
name: Build
22

33
on:
4-
push:
5-
branches:
6-
- master
7-
tags:
8-
- "v*"
9-
pull_request:
10-
branches:
11-
- master
4+
push:
5+
branches:
6+
- master
7+
tags:
8+
- "v*"
9+
pull_request:
10+
branches:
11+
- master
1212
jobs:
13-
Build:
14-
strategy:
15-
matrix:
16-
options:
17-
- os: ubuntu-latest
18-
framework: netcoreapp3.1
19-
runtime: -x64
20-
codecov: false
21-
- os: macos-latest
22-
framework: netcoreapp3.1
23-
runtime: -x64
24-
codecov: false
25-
- os: windows-latest
26-
framework: netcoreapp3.1
27-
runtime: -x64
28-
codecov: true
29-
- os: windows-latest
30-
framework: netcoreapp2.1
31-
runtime: -x64
32-
codecov: false
33-
- os: windows-latest
34-
framework: net472
35-
runtime: -x64
36-
codecov: false
37-
- os: windows-latest
38-
framework: net472
39-
runtime: -x86
40-
codecov: false
41-
42-
runs-on: ${{matrix.options.os}}
43-
if: "!contains(github.event.head_commit.message, '[skip ci]')"
44-
45-
steps:
46-
- name: Git Config
47-
shell: bash
48-
run: |
49-
git config --global core.autocrlf false
50-
git config --global core.longpaths true
51-
52-
- name: Git Checkout
53-
uses: actions/checkout@v2
54-
with:
55-
fetch-depth: 0
56-
submodules: recursive
57-
58-
# See https://github.com/actions/checkout/issues/165#issuecomment-657673315
59-
- name: Git Create LFS FileList
60-
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
61-
62-
- name: Git Setup LFS Cache
63-
uses: actions/cache@v2
64-
id: lfs-cache
65-
with:
66-
path: .git/lfs
67-
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
68-
69-
- name: Git Pull LFS
70-
run: git lfs pull
71-
72-
- name: NuGet Install
73-
uses: NuGet/setup-nuget@v1
74-
75-
- name: NuGet Setup Cache
76-
uses: actions/cache@v2
77-
id: nuget-cache
78-
with:
79-
path: ~/.nuget
80-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
81-
restore-keys: ${{ runner.os }}-nuget-
82-
83-
- name: DotNet Build
84-
shell: pwsh
85-
run: ./ci-build.ps1
86-
env:
87-
SIXLABORS_TESTING: True
88-
89-
- name: DotNet Test
90-
shell: pwsh
91-
run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}"
92-
env:
93-
SIXLABORS_TESTING: True
94-
XUNIT_PATH: .\tests\ImageSharp.Drawing.Tests # Required for xunit
95-
96-
- name: Export Failed Output
97-
uses: actions/upload-artifact@v2
98-
if: failure()
99-
with:
100-
name: actual_output_${{ runner.os }}_${{ matrix.options.framework }}${{ matrix.options.runtime }}.zip
101-
path: tests/Images/ActualOutput/
102-
103-
- name: Codecov Update
104-
uses: codecov/codecov-action@v1
105-
if: matrix.options.codecov == true && startsWith(github.repository, 'SixLabors')
106-
with:
107-
flags: unittests
108-
109-
Publish:
110-
needs: [Build]
111-
112-
runs-on: ubuntu-latest
113-
114-
if: (github.event_name == 'push')
115-
116-
steps:
117-
- name: Git Config
118-
shell: bash
119-
run: |
120-
git config --global core.autocrlf false
121-
git config --global core.longpaths true
122-
123-
- name: Git Checkout
124-
uses: actions/checkout@v2
125-
with:
126-
fetch-depth: 0
127-
submodules: recursive
128-
129-
- name: NuGet Install
130-
uses: NuGet/setup-nuget@v1
131-
132-
- name: NuGet Setup Cache
133-
uses: actions/cache@v2
134-
id: nuget-cache
135-
with:
136-
path: ~/.nuget
137-
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
138-
restore-keys: ${{ runner.os }}-nuget-
139-
140-
- name: DotNet Pack
141-
shell: pwsh
142-
run: ./ci-pack.ps1
143-
144-
- name: MyGet Publish
145-
shell: pwsh
146-
run: |
147-
dotnet nuget push .\artifacts\*.nupkg -k ${{secrets.MYGET_TOKEN}} -s https://www.myget.org/F/sixlabors/api/v2/package
148-
dotnet nuget push .\artifacts\*.snupkg -k ${{secrets.MYGET_TOKEN}} -s https://www.myget.org/F/sixlabors/api/v3/index.json
149-
# TODO: If github.ref starts with 'refs/tags' then it was tag push and we can optionally push out package to nuget.org
13+
Build:
14+
strategy:
15+
matrix:
16+
options:
17+
- os: ubuntu-latest
18+
framework: netcoreapp3.1
19+
runtime: -x64
20+
codecov: false
21+
- os: macos-latest
22+
framework: netcoreapp3.1
23+
runtime: -x64
24+
codecov: false
25+
- os: windows-latest
26+
framework: netcoreapp3.1
27+
runtime: -x64
28+
codecov: true
29+
- os: windows-latest
30+
framework: netcoreapp2.1
31+
runtime: -x64
32+
codecov: false
33+
- os: windows-latest
34+
framework: net472
35+
runtime: -x64
36+
codecov: false
37+
- os: windows-latest
38+
framework: net472
39+
runtime: -x86
40+
codecov: false
41+
42+
runs-on: ${{matrix.options.os}}
43+
if: "!contains(github.event.head_commit.message, '[skip ci]')"
44+
45+
steps:
46+
- name: Git Config
47+
shell: bash
48+
run: |
49+
git config --global core.autocrlf false
50+
git config --global core.longpaths true
51+
52+
- name: Git Checkout
53+
uses: actions/checkout@v2
54+
with:
55+
fetch-depth: 0
56+
submodules: recursive
57+
58+
# See https://github.com/actions/checkout/issues/165#issuecomment-657673315
59+
- name: Git Create LFS FileList
60+
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
61+
62+
- name: Git Setup LFS Cache
63+
uses: actions/cache@v2
64+
id: lfs-cache
65+
with:
66+
path: .git/lfs
67+
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1
68+
69+
- name: Git Pull LFS
70+
run: git lfs pull
71+
72+
- name: NuGet Install
73+
uses: NuGet/setup-nuget@v1
74+
75+
- name: NuGet Setup Cache
76+
uses: actions/cache@v2
77+
id: nuget-cache
78+
with:
79+
path: ~/.nuget
80+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
81+
restore-keys: ${{ runner.os }}-nuget-
82+
83+
- name: DotNet Setup
84+
uses: actions/setup-dotnet@v1
85+
with:
86+
dotnet-version: |
87+
6.0.x
88+
5.0.x
89+
3.1.x
90+
2.1.x
91+
92+
- name: DotNet Build
93+
shell: pwsh
94+
run: ./ci-build.ps1
95+
env:
96+
SIXLABORS_TESTING: True
97+
98+
- name: DotNet Test
99+
shell: pwsh
100+
run: ./ci-test.ps1 "${{matrix.options.os}}" "${{matrix.options.framework}}" "${{matrix.options.runtime}}" "${{matrix.options.codecov}}"
101+
env:
102+
SIXLABORS_TESTING: True
103+
XUNIT_PATH: .\tests\ImageSharp.Drawing.Tests # Required for xunit
104+
105+
- name: Export Failed Output
106+
uses: actions/upload-artifact@v2
107+
if: failure()
108+
with:
109+
name: actual_output_${{ runner.os }}_${{ matrix.options.framework }}${{ matrix.options.runtime }}.zip
110+
path: tests/Images/ActualOutput/
111+
112+
- name: Codecov Update
113+
uses: codecov/codecov-action@v1
114+
if: matrix.options.codecov == true && startsWith(github.repository, 'SixLabors')
115+
with:
116+
flags: unittests
117+
118+
Publish:
119+
needs: [Build]
120+
121+
runs-on: ubuntu-latest
122+
123+
if: (github.event_name == 'push')
124+
125+
steps:
126+
- name: Git Config
127+
shell: bash
128+
run: |
129+
git config --global core.autocrlf false
130+
git config --global core.longpaths true
131+
132+
- name: Git Checkout
133+
uses: actions/checkout@v2
134+
with:
135+
fetch-depth: 0
136+
submodules: recursive
137+
138+
- name: NuGet Install
139+
uses: NuGet/setup-nuget@v1
140+
141+
- name: NuGet Setup Cache
142+
uses: actions/cache@v2
143+
id: nuget-cache
144+
with:
145+
path: ~/.nuget
146+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.props', '**/*.targets') }}
147+
restore-keys: ${{ runner.os }}-nuget-
148+
149+
- name: DotNet Pack
150+
shell: pwsh
151+
run: ./ci-pack.ps1
152+
153+
- name: MyGet Publish
154+
shell: pwsh
155+
run: |
156+
dotnet nuget push .\artifacts\*.nupkg -k ${{secrets.MYGET_TOKEN}} -s https://www.myget.org/F/sixlabors/api/v2/package
157+
dotnet nuget push .\artifacts\*.snupkg -k ${{secrets.MYGET_TOKEN}} -s https://www.myget.org/F/sixlabors/api/v3/index.json
158+
# TODO: If github.ref starts with 'refs/tags' then it was tag push and we can optionally push out package to nuget.org

samples/DrawShapesWithImageSharp/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ private static void OutputStarOutline(int points, float inner = 10, float outer
189189
float offset = outer + 10;
190190

191191
var star = new Star(offset, offset, points, inner, outer);
192-
IPath outline = star.GenerateOutline(width, jointStyle);
192+
IPath outline = star.GenerateOutline(width, jointStyle, EndCapStyle.Butt);
193193
outline.SaveImage("Stars", $"StarOutline_{points}_{jointStyle}.png");
194194
}
195195

@@ -199,7 +199,7 @@ private static void OutputStarOutlineDashed(int points, float inner = 10, float
199199
float offset = outer + 10;
200200

201201
var star = new Star(offset, offset, points, inner, outer);
202-
IPath outline = star.GenerateOutline(width, new float[] { 3, 3 }, false, jointStyle, cap);
202+
IPath outline = star.GenerateOutline(width, new float[] { 3, 3 }, jointStyle, cap);
203203
outline.SaveImage("Stars", $"StarOutlineDashed_{points}_{jointStyle}_{cap}.png");
204204
}
205205

src/ImageSharp.Drawing/Processing/IPen.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,15 @@ public interface IPen
2424
/// Gets the stoke pattern.
2525
/// </summary>
2626
ReadOnlySpan<float> StrokePattern { get; }
27+
28+
/// <summary>
29+
/// Gets or sets the stroke joint style
30+
/// </summary>
31+
public JointStyle JointStyle { get; set; }
32+
33+
/// <summary>
34+
/// Gets or sets the stroke endcap style
35+
/// </summary>
36+
public EndCapStyle EndCapStyle { get; set; }
2737
}
2838
}

src/ImageSharp.Drawing/Processing/Pen.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,11 @@ public Pen(IBrush brush, float width)
7474

7575
/// <inheritdoc/>
7676
public ReadOnlySpan<float> StrokePattern => this.pattern;
77+
78+
/// <inheritdoc/>
79+
public JointStyle JointStyle { get; set; }
80+
81+
/// <inheritdoc/>
82+
public EndCapStyle EndCapStyle { get; set; }
7783
}
7884
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public IImageProcessor<TPixel> CreatePixelSpecificProcessor<TPixel>(Configuratio
4949
// The global transform is applied in the FillPathProcessor.
5050
IPath outline = this.Path
5151
.Transform(Matrix3x2.CreateTranslation(0.5F, 0.5F))
52-
.GenerateOutline(this.Pen.StrokeWidth, this.Pen.StrokePattern);
52+
.GenerateOutline(this.Pen.StrokeWidth, this.Pen.StrokePattern, this.Pen.JointStyle, this.Pen.EndCapStyle);
5353

5454
return new FillPathProcessor(this.Options, this.Pen.StrokeFill, outline)
5555
.CreatePixelSpecificProcessor(configuration, source, sourceRectangle);

src/ImageSharp.Drawing/Processing/Processors/Text/DrawTextProcessor{TPixel}.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ public void EndGlyph()
306306
}
307307
else
308308
{
309-
path = path.GenerateOutline(this.Pen.StrokeWidth, this.Pen.StrokePattern);
309+
path = path.GenerateOutline(this.Pen.StrokeWidth, this.Pen.StrokePattern, this.Pen.JointStyle, this.Pen.EndCapStyle);
310310
}
311311

312312
renderData.OutlineMap = this.Render(path);

src/ImageSharp.Drawing/Shapes/EndCapStyle.cs

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

44
namespace SixLabors.ImageSharp.Drawing

src/ImageSharp.Drawing/Shapes/JointStyle.cs

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

44
namespace SixLabors.ImageSharp.Drawing
55
{
66
/// <summary>
7-
/// The style we use to generate the joints when outlining.
7+
/// The style to apply to the joints when generating an outline.
88
/// </summary>
99
public enum JointStyle
1010
{
1111
/// <summary>
12-
/// Joints will generate to a long point unless the end of the point will exceed 20 times the width then we generate the joint using <see cref="JointStyle.Square"/>.
12+
/// Joints will generate to a long point unless the end of the point will exceed 20 times the width then we generate the joint using <see cref="Square"/>.
1313
/// </summary>
1414
Miter = 2,
1515

0 commit comments

Comments
 (0)