diff --git a/.gitignore b/.gitignore
index 940794e60..6eac430e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -286,3 +286,4 @@ __pycache__/
*.btm.cs
*.odx.cs
*.xsd.cs
+/src/D2DLib.sln
diff --git a/src/D2DLib.sln b/src/D2DLib.sln
deleted file mode 100644
index 63ad7e31c..000000000
--- a/src/D2DLib.sln
+++ /dev/null
@@ -1,95 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.29020.237
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "d2dlib", "d2dlib\d2dlib.vcxproj", "{E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D2DLibExport", "D2DLibExport\D2DLibExport.csproj", "{81DD53D8-FCF0-4384-A931-9370FA8E8E67}"
- ProjectSection(ProjectDependencies) = postProject
- {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9} = {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9}
- EndProjectSection
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples", "Examples\Examples.csproj", "{D653531B-D30C-4A20-8AE5-D46A6F03E274}"
- ProjectSection(ProjectDependencies) = postProject
- {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9} = {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9}
- EndProjectSection
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EF3FC267-D558-4556-8E8E-16BA7C52BDA3}"
- ProjectSection(SolutionItems) = preProject
- ..\.editorconfig = ..\.editorconfig
- ..\.gitignore = ..\.gitignore
- d2dlib.snk = d2dlib.snk
- Directory.Build.props = Directory.Build.props
- ..\INSTALL.md = ..\INSTALL.md
- ..\LICENSE.md = ..\LICENSE.md
- ..\package\logo_d2dlib.png = ..\package\logo_d2dlib.png
- NativeLibraries.props = NativeLibraries.props
- ..\README.md = ..\README.md
- EndProjectSection
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "snapshots", "snapshots", "{F362F889-0287-4377-A211-440C9871FDA6}"
- ProjectSection(SolutionItems) = preProject
- ..\snapshots\bitmap_rendering.png = ..\snapshots\bitmap_rendering.png
- ..\snapshots\imagetest.png = ..\snapshots\imagetest.png
- ..\snapshots\starspace.png = ..\snapshots\starspace.png
- ..\snapshots\subtitle.png = ..\snapshots\subtitle.png
- ..\snapshots\whiteboard.png = ..\snapshots\whiteboard.png
- EndProjectSection
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "D2DWinForm", "D2DWinForm\D2DWinForm.csproj", "{40ED2809-ABA2-4655-82DD-E38AD12138BB}"
- ProjectSection(ProjectDependencies) = postProject
- {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9} = {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9}
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9}.Debug|x64.ActiveCfg = Debug|x64
- {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9}.Debug|x64.Build.0 = Debug|x64
- {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9}.Debug|x86.ActiveCfg = Debug|Win32
- {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9}.Debug|x86.Build.0 = Debug|Win32
- {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9}.Release|x64.ActiveCfg = Release|x64
- {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9}.Release|x64.Build.0 = Release|x64
- {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9}.Release|x86.ActiveCfg = Release|Win32
- {E0A71FCE-69DD-40A6-87FB-2D63AB5D25C9}.Release|x86.Build.0 = Release|Win32
- {81DD53D8-FCF0-4384-A931-9370FA8E8E67}.Debug|x64.ActiveCfg = Debug|x64
- {81DD53D8-FCF0-4384-A931-9370FA8E8E67}.Debug|x64.Build.0 = Debug|x64
- {81DD53D8-FCF0-4384-A931-9370FA8E8E67}.Debug|x86.ActiveCfg = Debug|x86
- {81DD53D8-FCF0-4384-A931-9370FA8E8E67}.Debug|x86.Build.0 = Debug|x86
- {81DD53D8-FCF0-4384-A931-9370FA8E8E67}.Release|x64.ActiveCfg = Release|x64
- {81DD53D8-FCF0-4384-A931-9370FA8E8E67}.Release|x64.Build.0 = Release|x64
- {81DD53D8-FCF0-4384-A931-9370FA8E8E67}.Release|x86.ActiveCfg = Release|x86
- {81DD53D8-FCF0-4384-A931-9370FA8E8E67}.Release|x86.Build.0 = Release|x86
- {D653531B-D30C-4A20-8AE5-D46A6F03E274}.Debug|x64.ActiveCfg = Debug|x64
- {D653531B-D30C-4A20-8AE5-D46A6F03E274}.Debug|x64.Build.0 = Debug|x64
- {D653531B-D30C-4A20-8AE5-D46A6F03E274}.Debug|x86.ActiveCfg = Debug|x86
- {D653531B-D30C-4A20-8AE5-D46A6F03E274}.Debug|x86.Build.0 = Debug|x86
- {D653531B-D30C-4A20-8AE5-D46A6F03E274}.Release|x64.ActiveCfg = Release|x64
- {D653531B-D30C-4A20-8AE5-D46A6F03E274}.Release|x64.Build.0 = Release|x64
- {D653531B-D30C-4A20-8AE5-D46A6F03E274}.Release|x86.ActiveCfg = Release|x86
- {D653531B-D30C-4A20-8AE5-D46A6F03E274}.Release|x86.Build.0 = Release|x86
- {40ED2809-ABA2-4655-82DD-E38AD12138BB}.Debug|x64.ActiveCfg = Debug|x64
- {40ED2809-ABA2-4655-82DD-E38AD12138BB}.Debug|x64.Build.0 = Debug|x64
- {40ED2809-ABA2-4655-82DD-E38AD12138BB}.Debug|x86.ActiveCfg = Debug|x86
- {40ED2809-ABA2-4655-82DD-E38AD12138BB}.Debug|x86.Build.0 = Debug|x86
- {40ED2809-ABA2-4655-82DD-E38AD12138BB}.Release|x64.ActiveCfg = Release|x64
- {40ED2809-ABA2-4655-82DD-E38AD12138BB}.Release|x64.Build.0 = Release|x64
- {40ED2809-ABA2-4655-82DD-E38AD12138BB}.Release|x86.ActiveCfg = Release|x86
- {40ED2809-ABA2-4655-82DD-E38AD12138BB}.Release|x86.Build.0 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {F362F889-0287-4377-A211-440C9871FDA6} = {EF3FC267-D558-4556-8E8E-16BA7C52BDA3}
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {7BAB2A3D-55C4-4645-8E81-459E60AAC2CD}
- EndGlobalSection
-EndGlobal
diff --git a/src/D2DLibExport/D2DDevice.cs b/src/D2DLibExport/D2DDevice.cs
index d5409d958..ac398c742 100644
--- a/src/D2DLibExport/D2DDevice.cs
+++ b/src/D2DLibExport/D2DDevice.cs
@@ -116,6 +116,11 @@ public D2DGeometry CreateEllipseGeometry(D2DPoint origin, D2DSize size)
return new D2DGeometry(this, D2D.CreateEllipseGeometry(this.Handle, ref ellipse));
}
+ public D2DGeometry CreateEllipseGeometry(D2DEllipse ellipse)
+ {
+ return new D2DGeometry(this, D2D.CreateEllipseGeometry(this.Handle, ref ellipse));
+ }
+
public D2DGeometry CreatePieGeometry(D2DPoint origin, D2DSize size, float startAngle, float endAngle)
{
var path = this.CreatePathGeometry();
diff --git a/src/D2DLibExport/D2DGraphics.cs b/src/D2DLibExport/D2DGraphics.cs
index b4dfa99f4..3c3fb5e10 100644
--- a/src/D2DLibExport/D2DGraphics.cs
+++ b/src/D2DLibExport/D2DGraphics.cs
@@ -490,6 +490,11 @@ public void FillPath(D2DGeometry path, D2DColor fillColor)
D2D.FillPathD(path.Handle, fillColor);
}
+ public void FillPath(D2DGeometry path, D2DBrush fillBrush)
+ {
+ D2D.FillPathWithBrush(path.Handle, fillBrush.Handle);
+ }
+
public void Clear(D2DColor color)
{
D2D.Clear(Handle, color);
diff --git a/src/D2DLibExport/D2DLib.cs b/src/D2DLibExport/D2DLib.cs
index d4bda2847..79b1c8f35 100644
--- a/src/D2DLibExport/D2DLib.cs
+++ b/src/D2DLibExport/D2DLib.cs
@@ -285,6 +285,9 @@ public static extern void DrawPath(HANDLE path, D2DColor strokeColor, FLOAT stro
[DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)]
public static extern void FillPathD(HANDLE path, D2DColor fillColor);
+
+ [DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)]
+ public static extern void FillPathWithBrush(HANDLE path, HANDLE fillBrush);
[DllImport(DLL_NAME, CallingConvention = CallingConvention.Cdecl)]
public static extern void FillGeometryWithBrush(HANDLE path, HANDLE brush);
diff --git a/src/D2DLibExport/D2DLibExport.csproj b/src/D2DLibExport/D2DLibExport.csproj
index da6c4faa0..21f38811f 100644
--- a/src/D2DLibExport/D2DLibExport.csproj
+++ b/src/D2DLibExport/D2DLibExport.csproj
@@ -13,4 +13,8 @@
+
+
+
+
\ No newline at end of file
diff --git a/src/d2dlib/Geometry.cpp b/src/d2dlib/Geometry.cpp
index b9ab40277..85035ead5 100644
--- a/src/d2dlib/Geometry.cpp
+++ b/src/d2dlib/Geometry.cpp
@@ -181,10 +181,10 @@ void AddPathArc(HANDLE ctx, D2D1_POINT_2F endPoint, D2D1_SIZE_F size, FLOAT swee
pathContext->sink->AddArc(&seg);
}
-void DrawPath(HANDLE pathCtx, D2D1_COLOR_F strokeColor, FLOAT strokeWidth, D2D1_DASH_STYLE dashStyle)
+void DrawPath(HANDLE geoCtx, D2D1_COLOR_F strokeColor, FLOAT strokeWidth, D2D1_DASH_STYLE dashStyle)
{
- D2DPathContext* pathContext = reinterpret_cast(pathCtx);
- D2DContext* context = pathContext->d2context;
+ D2DGeometryContext* geometryContext = reinterpret_cast(geoCtx);
+ D2DContext* context = geometryContext->d2context;
ID2D1Factory* factory = context->factory;
ID2D1RenderTarget* renderTarget = context->renderTarget;
@@ -206,27 +206,27 @@ void DrawPath(HANDLE pathCtx, D2D1_COLOR_F strokeColor, FLOAT strokeWidth, D2D1_
0.0f), NULL, 0, &strokeStyle);
}
- renderTarget->DrawGeometry(pathContext->path, strokeBrush, strokeWidth, strokeStyle);
+ renderTarget->DrawGeometry(geometryContext->geometry, strokeBrush, strokeWidth, strokeStyle);
SafeRelease(&strokeBrush);
SafeRelease(&strokeStyle);
}
-void DrawPathWithPen(HANDLE pathCtx, HANDLE strokePen, FLOAT strokeWidth)
+void DrawPathWithPen(HANDLE geoCtx, HANDLE strokePen, FLOAT strokeWidth)
{
D2DPen* pen = reinterpret_cast(strokePen);
- D2DPathContext* pathContext = reinterpret_cast(pathCtx);
- ID2D1RenderTarget* renderTarget = pathContext->d2context->renderTarget;
+ D2DGeometryContext* geometryContext = reinterpret_cast(geoCtx);
+ ID2D1RenderTarget* renderTarget = geometryContext->d2context->renderTarget;
if (pen->brush != NULL) {
- renderTarget->DrawGeometry(pathContext->path, pen->brush, strokeWidth, pen->strokeStyle);
+ renderTarget->DrawGeometry(geometryContext->geometry, pen->brush, strokeWidth, pen->strokeStyle);
}
}
-void FillPathD(HANDLE pathCtx, D2D1_COLOR_F fillColor)
+void FillPathD(HANDLE geoCtx, D2D1_COLOR_F fillColor)
{
- D2DPathContext* pathContext = reinterpret_cast(pathCtx);
- ID2D1RenderTarget* renderTarget = pathContext->d2context->renderTarget;
+ D2DGeometryContext* geometryContext = reinterpret_cast(geoCtx);
+ ID2D1RenderTarget* renderTarget = geometryContext->d2context->renderTarget;
if (fillColor.a > 0)
{
@@ -234,7 +234,7 @@ void FillPathD(HANDLE pathCtx, D2D1_COLOR_F fillColor)
renderTarget->CreateSolidColorBrush(fillColor, &fillBrush);
if (fillBrush != NULL) {
- renderTarget->FillGeometry(pathContext->path, fillBrush);
+ renderTarget->FillGeometry(geometryContext->geometry, fillBrush);
}
SafeRelease(&fillBrush);
@@ -376,13 +376,13 @@ void DrawPolygonWithBrush(HANDLE ctx, D2D1_POINT_2F* points, UINT count,
}
-void FillPathWithBrush(HANDLE ctx, HANDLE brushHandle)
+void FillPathWithBrush(HANDLE geoCtx, HANDLE brushHandle)
{
- D2DPathContext* pathContext = reinterpret_cast(ctx);
+ D2DGeometryContext* geoContext = reinterpret_cast(geoCtx);
D2DBrushContext* brushContext = reinterpret_cast(brushHandle);
- D2DContext* context = pathContext->d2context;
+ D2DContext* context = geoContext->d2context;
- context->renderTarget->FillGeometry(pathContext->path, brushContext->brush);
+ context->renderTarget->FillGeometry(geoContext->geometry, brushContext->brush);
}
void FillGeometryWithBrush(HANDLE ctx, HANDLE geoHandle, _In_ HANDLE brushHandle, _In_opt_ HANDLE opacityBrushHandle)
@@ -397,21 +397,21 @@ void FillGeometryWithBrush(HANDLE ctx, HANDLE geoHandle, _In_ HANDLE brushHandle
opacityBrushContext == NULL ? NULL : opacityBrushContext->brush);
}
-bool PathFillContainsPoint(HANDLE pathCtx, D2D1_POINT_2F point)
+bool PathFillContainsPoint(HANDLE geoCtx, D2D1_POINT_2F point)
{
- D2DPathContext* pathContext = reinterpret_cast(pathCtx);
+ D2DGeometryContext* geoContext = reinterpret_cast(geoCtx);
BOOL contain = FALSE;
- pathContext->path->FillContainsPoint(point, NULL, &contain);
+ geoContext->geometry->FillContainsPoint(point, NULL, &contain);
return contain == TRUE;
}
-bool PathStrokeContainsPoint(HANDLE pathCtx, D2D1_POINT_2F point, FLOAT strokeWidth, D2D1_DASH_STYLE dashStyle)
+bool PathStrokeContainsPoint(HANDLE geoCtx, D2D1_POINT_2F point, FLOAT strokeWidth, D2D1_DASH_STYLE dashStyle)
{
- D2DPathContext* pathContext = reinterpret_cast(pathCtx);
-
- ID2D1Factory* factory = pathContext->d2context->factory;
+ D2DGeometryContext* geoContext = reinterpret_cast(geoCtx);
+
+ ID2D1Factory* factory = geoContext->d2context->factory;
ID2D1StrokeStyle *strokeStyle = NULL;
if (dashStyle != D2D1_DASH_STYLE_SOLID)
@@ -427,7 +427,7 @@ bool PathStrokeContainsPoint(HANDLE pathCtx, D2D1_POINT_2F point, FLOAT strokeWi
}
BOOL contain = FALSE;
- pathContext->path->StrokeContainsPoint(point, strokeWidth, strokeStyle, NULL, &contain);
+ geoContext->geometry->StrokeContainsPoint(point, strokeWidth, strokeStyle, NULL, &contain);
SafeRelease(&strokeStyle);
@@ -435,14 +435,14 @@ bool PathStrokeContainsPoint(HANDLE pathCtx, D2D1_POINT_2F point, FLOAT strokeWi
}
-void GetGeometryBounds(HANDLE pathCtx, __out D2D1_RECT_F* rect)
+void GetGeometryBounds(HANDLE geoCtx, __out D2D1_RECT_F* rect)
{
- D2DPathContext* pathContext = reinterpret_cast(pathCtx);
- pathContext->path->GetBounds(NULL, rect);
+ D2DGeometryContext* geoContext = reinterpret_cast(geoCtx);
+ geoContext->geometry->GetBounds(NULL, rect);
}
-void GetGeometryTransformedBounds(HANDLE pathCtx, __in D2D1_MATRIX_3X2_F* mat3x2, __out D2D1_RECT_F* rect)
+void GetGeometryTransformedBounds(HANDLE geoCtx, __in D2D1_MATRIX_3X2_F* mat3x2, __out D2D1_RECT_F* rect)
{
- D2DPathContext* pathContext = reinterpret_cast(pathCtx);
- pathContext->path->GetBounds(mat3x2, rect);
+ D2DGeometryContext* geoContext = reinterpret_cast(geoCtx);
+ geoContext->geometry->GetBounds(mat3x2, rect);
}
diff --git a/src/d2dlib/Geometry.h b/src/d2dlib/Geometry.h
index 8341d984f..00d9fd3af 100644
--- a/src/d2dlib/Geometry.h
+++ b/src/d2dlib/Geometry.h
@@ -1,4 +1,4 @@
-/*
+/*
* MIT License
*
* Copyright (c) 2009-2021 Jingwood, unvell.com. All right reserved.
@@ -54,22 +54,22 @@ extern "C"
D2D1_COLOR_F strokeColor, FLOAT strokeWidth = 1,
D2D1_DASH_STYLE dashStyle = D2D1_DASH_STYLE::D2D1_DASH_STYLE_SOLID);
- D2DLIB_API void DrawPath(HANDLE pathCtx, D2D1_COLOR_F strokeColor, FLOAT strokeWidth, D2D1_DASH_STYLE dashStyle);
- D2DLIB_API void DrawPathWithPen(HANDLE pathCtx, HANDLE strokePen, FLOAT strokeWidth);
- D2DLIB_API void FillPathD(HANDLE pathCtx, D2D1_COLOR_F fillColor);
-
+ D2DLIB_API void DrawPath(HANDLE geoCtx, D2D1_COLOR_F strokeColor, FLOAT strokeWidth, D2D1_DASH_STYLE dashStyle);
+ D2DLIB_API void DrawPathWithPen(HANDLE geoCtx, HANDLE strokePen, FLOAT strokeWidth);
+ D2DLIB_API void FillPathD(HANDLE geoCtx, D2D1_COLOR_F fillColor);
+ D2DLIB_API void FillPathWithBrush(HANDLE geoCtx, HANDLE brushHandle);
D2DLIB_API void FillGeometryWithBrush(HANDLE ctx, HANDLE geoHandle,
__in HANDLE brushHandle, __in_opt HANDLE opacityBrushHandle = NULL);
- D2DLIB_API bool PathFillContainsPoint(HANDLE pathCtx, D2D1_POINT_2F point);
- D2DLIB_API bool PathStrokeContainsPoint(HANDLE pathCtx, D2D1_POINT_2F point, FLOAT strokeWidth = 1,
+ D2DLIB_API bool PathFillContainsPoint(HANDLE geoCtx, D2D1_POINT_2F point);
+ D2DLIB_API bool PathStrokeContainsPoint(HANDLE geoCtx, D2D1_POINT_2F point, FLOAT strokeWidth = 1,
D2D1_DASH_STYLE dashStyle = D2D1_DASH_STYLE::D2D1_DASH_STYLE_SOLID);
- D2DLIB_API void GetGeometryBounds(HANDLE pathCtx, __out D2D1_RECT_F* rect);
- D2DLIB_API void GetGeometryTransformedBounds(HANDLE pathCtx, __in D2D1_MATRIX_3X2_F* mat3x2, __out D2D1_RECT_F* rect);
+ D2DLIB_API void GetGeometryBounds(HANDLE geoCtx, __out D2D1_RECT_F* rect);
+ D2DLIB_API void GetGeometryTransformedBounds(HANDLE geoCtx, __in D2D1_MATRIX_3X2_F* mat3x2, __out D2D1_RECT_F* rect);
D2DLIB_API void DrawPolygon(HANDLE ctx, D2D1_POINT_2F* points, UINT count,
D2D1_COLOR_F strokeColor, FLOAT strokeWidth, D2D1_DASH_STYLE dashStyle, D2D1_COLOR_F fillColor);
D2DLIB_API void DrawPolygonWithBrush(HANDLE ctx, D2D1_POINT_2F* points, UINT count,
D2D1_COLOR_F strokeColor, FLOAT strokeWidth, D2D1_DASH_STYLE dashStyle, HANDLE brushHandle);
-}
\ No newline at end of file
+}