renamed segment

This commit is contained in:
Dylan Wilson
2018-04-03 22:07:52 +10:00
parent f523efabe4
commit a9abeff97e
6 changed files with 83 additions and 202 deletions
@@ -10,23 +10,22 @@ using MonoGame.Extended.TextureAtlases;
namespace Demo.Features.Screens
{
public class SelectDemoScreen : GuiScreen
public class SelectDemoScreen : Screen
{
private readonly IDictionary<string, DemoBase> _demos;
private readonly Action<string> _loadDemo;
public SelectDemoScreen(GuiSkin skin, IDictionary<string, DemoBase> demos, Action<string> loadDemo, Action exitGameAction)
: base(skin)
public SelectDemoScreen(IDictionary<string, DemoBase> demos, Action<string> loadDemo, Action exitGameAction)
{
_demos = demos;
_loadDemo = loadDemo;
var dialog = Skin.Create<GuiDialog>("dialog");
var grid = new GuiUniformGrid { Columns = 3 };
var dialog = Skin.Create<Dialog>("dialog");
var grid = new UniformGrid { Columns = 3 };
foreach (var demo in _demos.Values.OrderBy(i => i.Name))
{
var button = Skin.Create<GuiButton>("white-button", c =>
var button = Skin.Create<Button>("white-button", c =>
{
c.Text = demo.Name;
c.Margin = new Thickness(4);
@@ -108,7 +107,7 @@ namespace Demo.Features.Screens
};
dialog.Controls.Add(stackPanel);
dialog.Controls.Add(Skin.Create<GuiLabel>("label", c =>
dialog.Controls.Add(Skin.Create<Label>("label", c =>
{
c.Text = "Please confirm";
c.VerticalAlignment = VerticalAlignment.Top;
@@ -116,7 +115,7 @@ namespace Demo.Features.Screens
c.Offset = new Vector2(0, -30);
c.BackgroundRegion = Skin.NinePatches.FirstOrDefault(i => i.Name == "progress-bar-blue");
}));
dialog.Controls.Add(Skin.Create<GuiButton>("close-button", c =>
dialog.Controls.Add(Skin.Create<Button>("close-button", c =>
{
c.HorizontalAlignment = HorizontalAlignment.Right;
c.VerticalAlignment = VerticalAlignment.Top;
+1 -119
View File
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended", "MonoGame.Extended\MonoGame.Extended.csproj", "{41724C52-3D50-45BB-81EB-3C8A247EAFD1}"
EndProject
@@ -23,21 +23,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demos", "Demos", "{932F8931
Demos\README.md = Demos\README.md
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.SpaceGame", "Demos\Demo.SpaceGame\Demo.SpaceGame.csproj", "{D5314E38-8F5A-48A5-A092-BD8BBEACB5DD}"
ProjectSection(ProjectDependencies) = postProject
{28CD24BD-432C-4987-9E9D-65CFCF120EA0} = {28CD24BD-432C-4987-9E9D-65CFCF120EA0}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.Platformer", "Demos\Demo.Platformer\Demo.Platformer.csproj", "{A7A5E924-A49D-4052-ACA2-894161007B00}"
ProjectSection(ProjectDependencies) = postProject
{28CD24BD-432C-4987-9E9D-65CFCF120EA0} = {28CD24BD-432C-4987-9E9D-65CFCF120EA0}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.NuclexGui", "Demos\Demo.NuclexGui\Demo.NuclexGui.csproj", "{8003BA78-CB44-46B5-85A2-2A6440C3EFDC}"
ProjectSection(ProjectDependencies) = postProject
{28CD24BD-432C-4987-9E9D-65CFCF120EA0} = {28CD24BD-432C-4987-9E9D-65CFCF120EA0}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended.Collisions", "MonoGame.Extended.Collisions\MonoGame.Extended.Collisions.csproj", "{02562C6F-5BFB-467E-8A95-68B6CE2D635A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended.Gui", "MonoGame.Extended.Gui\MonoGame.Extended.Gui.csproj", "{8E425575-378A-4F83-88C9-F8BEBAD227C9}"
@@ -50,8 +35,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended.Content.P
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended.Content.Pipeline.Tests.Tiled", "Tests\MonoGame.Extended.Content.Pipeline.Tests.Tiled\MonoGame.Extended.Content.Pipeline.Tests.Tiled.csproj", "{90B096CB-61A5-485F-BA3E-2530166E5E72}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended.Gui.Tests", "Tests\MonoGame.Extended.Gui.Tests\MonoGame.Extended.Gui.Tests.csproj", "{43CBA868-9BFC-4E02-8A7A-142C603B087E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended.Tests", "Tests\MonoGame.Extended.Tests\MonoGame.Extended.Tests.csproj", "{CEF2144F-7E98-45A5-BE08-E6DBC307A5C1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended.Tiled.Tests", "Tests\MonoGame.Extended.Tiled.Tests\MonoGame.Extended.Tiled.Tests.csproj", "{A88FC71D-12E3-42A5-AFF3-89C6498C3C65}"
@@ -87,26 +70,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{F3E80350
NuGet\readme.txt = NuGet\readme.txt
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.StarWarrior", "Demos\Demo.StarWarrior\Demo.StarWarrior.csproj", "{52CC60A4-D806-46BF-B104-53E56A764B0E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.Features", "Demos\Demo.Features\Demo.Features.csproj", "{D8C6D896-5ABF-4823-84DA-F1191BEEC004}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.Features.WindowsOpenGL", "Demos\Demo.Features.Windows\Demo.Features.WindowsOpenGL.csproj", "{57C47653-BC51-43BA-98F4-1D0EEE78782D}"
ProjectSection(ProjectDependencies) = postProject
{BDAEDFAF-2EDA-4BCA-9675-3625456FAB78} = {BDAEDFAF-2EDA-4BCA-9675-3625456FAB78}
{28CD24BD-432C-4987-9E9D-65CFCF120EA0} = {28CD24BD-432C-4987-9E9D-65CFCF120EA0}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo.Features.WindowsDirectX", "Demos\Demo.Features.Windows\Demo.Features.WindowsDirectX.csproj", "{BDAEDFAF-2EDA-4BCA-9675-3625456FAB78}"
ProjectSection(ProjectDependencies) = postProject
{28CD24BD-432C-4987-9E9D-65CFCF120EA0} = {28CD24BD-432C-4987-9E9D-65CFCF120EA0}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sandbox", "Tests\Sandbox\Sandbox.csproj", "{9A920A4D-3794-4AB4-9A76-3C19407A1C5F}"
ProjectSection(ProjectDependencies) = postProject
{28CD24BD-432C-4987-9E9D-65CFCF120EA0} = {28CD24BD-432C-4987-9E9D-65CFCF120EA0}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Extended.Entities.Tests", "Tests\MonoGame.Extended.Entities.Tests\MonoGame.Extended.Entities.Tests.csproj", "{5B993DD9-A9B8-434C-B444-F1CFFB947F79}"
EndProject
Global
@@ -133,30 +96,6 @@ Global
{28CD24BD-432C-4987-9E9D-65CFCF120EA0}.Release|Any CPU.Build.0 = Release|Any CPU
{28CD24BD-432C-4987-9E9D-65CFCF120EA0}.Release|x86.ActiveCfg = Release|Any CPU
{28CD24BD-432C-4987-9E9D-65CFCF120EA0}.Release|x86.Build.0 = Release|Any CPU
{D5314E38-8F5A-48A5-A092-BD8BBEACB5DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5314E38-8F5A-48A5-A092-BD8BBEACB5DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5314E38-8F5A-48A5-A092-BD8BBEACB5DD}.Debug|x86.ActiveCfg = Debug|Any CPU
{D5314E38-8F5A-48A5-A092-BD8BBEACB5DD}.Debug|x86.Build.0 = Debug|Any CPU
{D5314E38-8F5A-48A5-A092-BD8BBEACB5DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5314E38-8F5A-48A5-A092-BD8BBEACB5DD}.Release|Any CPU.Build.0 = Release|Any CPU
{D5314E38-8F5A-48A5-A092-BD8BBEACB5DD}.Release|x86.ActiveCfg = Release|Any CPU
{D5314E38-8F5A-48A5-A092-BD8BBEACB5DD}.Release|x86.Build.0 = Release|Any CPU
{A7A5E924-A49D-4052-ACA2-894161007B00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A7A5E924-A49D-4052-ACA2-894161007B00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A7A5E924-A49D-4052-ACA2-894161007B00}.Debug|x86.ActiveCfg = Debug|Any CPU
{A7A5E924-A49D-4052-ACA2-894161007B00}.Debug|x86.Build.0 = Debug|Any CPU
{A7A5E924-A49D-4052-ACA2-894161007B00}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A7A5E924-A49D-4052-ACA2-894161007B00}.Release|Any CPU.Build.0 = Release|Any CPU
{A7A5E924-A49D-4052-ACA2-894161007B00}.Release|x86.ActiveCfg = Release|Any CPU
{A7A5E924-A49D-4052-ACA2-894161007B00}.Release|x86.Build.0 = Release|Any CPU
{8003BA78-CB44-46B5-85A2-2A6440C3EFDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8003BA78-CB44-46B5-85A2-2A6440C3EFDC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8003BA78-CB44-46B5-85A2-2A6440C3EFDC}.Debug|x86.ActiveCfg = Debug|Any CPU
{8003BA78-CB44-46B5-85A2-2A6440C3EFDC}.Debug|x86.Build.0 = Debug|Any CPU
{8003BA78-CB44-46B5-85A2-2A6440C3EFDC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8003BA78-CB44-46B5-85A2-2A6440C3EFDC}.Release|Any CPU.Build.0 = Release|Any CPU
{8003BA78-CB44-46B5-85A2-2A6440C3EFDC}.Release|x86.ActiveCfg = Release|Any CPU
{8003BA78-CB44-46B5-85A2-2A6440C3EFDC}.Release|x86.Build.0 = Release|Any CPU
{02562C6F-5BFB-467E-8A95-68B6CE2D635A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{02562C6F-5BFB-467E-8A95-68B6CE2D635A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{02562C6F-5BFB-467E-8A95-68B6CE2D635A}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -205,14 +144,6 @@ Global
{90B096CB-61A5-485F-BA3E-2530166E5E72}.Release|Any CPU.Build.0 = Release|Any CPU
{90B096CB-61A5-485F-BA3E-2530166E5E72}.Release|x86.ActiveCfg = Release|Any CPU
{90B096CB-61A5-485F-BA3E-2530166E5E72}.Release|x86.Build.0 = Release|Any CPU
{43CBA868-9BFC-4E02-8A7A-142C603B087E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43CBA868-9BFC-4E02-8A7A-142C603B087E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{43CBA868-9BFC-4E02-8A7A-142C603B087E}.Debug|x86.ActiveCfg = Debug|Any CPU
{43CBA868-9BFC-4E02-8A7A-142C603B087E}.Debug|x86.Build.0 = Debug|Any CPU
{43CBA868-9BFC-4E02-8A7A-142C603B087E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{43CBA868-9BFC-4E02-8A7A-142C603B087E}.Release|Any CPU.Build.0 = Release|Any CPU
{43CBA868-9BFC-4E02-8A7A-142C603B087E}.Release|x86.ActiveCfg = Release|Any CPU
{43CBA868-9BFC-4E02-8A7A-142C603B087E}.Release|x86.Build.0 = Release|Any CPU
{CEF2144F-7E98-45A5-BE08-E6DBC307A5C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CEF2144F-7E98-45A5-BE08-E6DBC307A5C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CEF2144F-7E98-45A5-BE08-E6DBC307A5C1}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -285,46 +216,6 @@ Global
{587CE536-216F-41A1-B223-AE502C125B09}.Release|Any CPU.Build.0 = Release|Any CPU
{587CE536-216F-41A1-B223-AE502C125B09}.Release|x86.ActiveCfg = Release|Any CPU
{587CE536-216F-41A1-B223-AE502C125B09}.Release|x86.Build.0 = Release|Any CPU
{52CC60A4-D806-46BF-B104-53E56A764B0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52CC60A4-D806-46BF-B104-53E56A764B0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52CC60A4-D806-46BF-B104-53E56A764B0E}.Debug|x86.ActiveCfg = Debug|Any CPU
{52CC60A4-D806-46BF-B104-53E56A764B0E}.Debug|x86.Build.0 = Debug|Any CPU
{52CC60A4-D806-46BF-B104-53E56A764B0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52CC60A4-D806-46BF-B104-53E56A764B0E}.Release|Any CPU.Build.0 = Release|Any CPU
{52CC60A4-D806-46BF-B104-53E56A764B0E}.Release|x86.ActiveCfg = Release|Any CPU
{52CC60A4-D806-46BF-B104-53E56A764B0E}.Release|x86.Build.0 = Release|Any CPU
{D8C6D896-5ABF-4823-84DA-F1191BEEC004}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D8C6D896-5ABF-4823-84DA-F1191BEEC004}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8C6D896-5ABF-4823-84DA-F1191BEEC004}.Debug|x86.ActiveCfg = Debug|Any CPU
{D8C6D896-5ABF-4823-84DA-F1191BEEC004}.Debug|x86.Build.0 = Debug|Any CPU
{D8C6D896-5ABF-4823-84DA-F1191BEEC004}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8C6D896-5ABF-4823-84DA-F1191BEEC004}.Release|Any CPU.Build.0 = Release|Any CPU
{D8C6D896-5ABF-4823-84DA-F1191BEEC004}.Release|x86.ActiveCfg = Release|Any CPU
{D8C6D896-5ABF-4823-84DA-F1191BEEC004}.Release|x86.Build.0 = Release|Any CPU
{57C47653-BC51-43BA-98F4-1D0EEE78782D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{57C47653-BC51-43BA-98F4-1D0EEE78782D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{57C47653-BC51-43BA-98F4-1D0EEE78782D}.Debug|x86.ActiveCfg = Debug|Any CPU
{57C47653-BC51-43BA-98F4-1D0EEE78782D}.Debug|x86.Build.0 = Debug|Any CPU
{57C47653-BC51-43BA-98F4-1D0EEE78782D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{57C47653-BC51-43BA-98F4-1D0EEE78782D}.Release|Any CPU.Build.0 = Release|Any CPU
{57C47653-BC51-43BA-98F4-1D0EEE78782D}.Release|x86.ActiveCfg = Release|Any CPU
{57C47653-BC51-43BA-98F4-1D0EEE78782D}.Release|x86.Build.0 = Release|Any CPU
{BDAEDFAF-2EDA-4BCA-9675-3625456FAB78}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BDAEDFAF-2EDA-4BCA-9675-3625456FAB78}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BDAEDFAF-2EDA-4BCA-9675-3625456FAB78}.Debug|x86.ActiveCfg = Debug|Any CPU
{BDAEDFAF-2EDA-4BCA-9675-3625456FAB78}.Debug|x86.Build.0 = Debug|Any CPU
{BDAEDFAF-2EDA-4BCA-9675-3625456FAB78}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BDAEDFAF-2EDA-4BCA-9675-3625456FAB78}.Release|Any CPU.Build.0 = Release|Any CPU
{BDAEDFAF-2EDA-4BCA-9675-3625456FAB78}.Release|x86.ActiveCfg = Release|Any CPU
{BDAEDFAF-2EDA-4BCA-9675-3625456FAB78}.Release|x86.Build.0 = Release|Any CPU
{9A920A4D-3794-4AB4-9A76-3C19407A1C5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A920A4D-3794-4AB4-9A76-3C19407A1C5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A920A4D-3794-4AB4-9A76-3C19407A1C5F}.Debug|x86.ActiveCfg = Debug|Any CPU
{9A920A4D-3794-4AB4-9A76-3C19407A1C5F}.Debug|x86.Build.0 = Debug|Any CPU
{9A920A4D-3794-4AB4-9A76-3C19407A1C5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A920A4D-3794-4AB4-9A76-3C19407A1C5F}.Release|Any CPU.Build.0 = Release|Any CPU
{9A920A4D-3794-4AB4-9A76-3C19407A1C5F}.Release|x86.ActiveCfg = Release|Any CPU
{9A920A4D-3794-4AB4-9A76-3C19407A1C5F}.Release|x86.Build.0 = Release|Any CPU
{5B993DD9-A9B8-434C-B444-F1CFFB947F79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B993DD9-A9B8-434C-B444-F1CFFB947F79}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B993DD9-A9B8-434C-B444-F1CFFB947F79}.Debug|x86.ActiveCfg = Debug|Any CPU
@@ -338,20 +229,11 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D5314E38-8F5A-48A5-A092-BD8BBEACB5DD} = {932F8931-4A8D-4205-BFCF-98E794207786}
{A7A5E924-A49D-4052-ACA2-894161007B00} = {932F8931-4A8D-4205-BFCF-98E794207786}
{8003BA78-CB44-46B5-85A2-2A6440C3EFDC} = {932F8931-4A8D-4205-BFCF-98E794207786}
{75D76507-9CB0-4A60-BE46-696DF6E7AA6C} = {E5A148A1-DE7B-4D17-ABE8-831B9673B863}
{90B096CB-61A5-485F-BA3E-2530166E5E72} = {E5A148A1-DE7B-4D17-ABE8-831B9673B863}
{43CBA868-9BFC-4E02-8A7A-142C603B087E} = {E5A148A1-DE7B-4D17-ABE8-831B9673B863}
{CEF2144F-7E98-45A5-BE08-E6DBC307A5C1} = {E5A148A1-DE7B-4D17-ABE8-831B9673B863}
{A88FC71D-12E3-42A5-AFF3-89C6498C3C65} = {E5A148A1-DE7B-4D17-ABE8-831B9673B863}
{F3E80350-2F27-4EDB-8BE9-0145643A5336} = {068B9F42-8B49-4FAF-9D8C-701862FAC799}
{52CC60A4-D806-46BF-B104-53E56A764B0E} = {932F8931-4A8D-4205-BFCF-98E794207786}
{D8C6D896-5ABF-4823-84DA-F1191BEEC004} = {932F8931-4A8D-4205-BFCF-98E794207786}
{57C47653-BC51-43BA-98F4-1D0EEE78782D} = {932F8931-4A8D-4205-BFCF-98E794207786}
{BDAEDFAF-2EDA-4BCA-9675-3625456FAB78} = {932F8931-4A8D-4205-BFCF-98E794207786}
{9A920A4D-3794-4AB4-9A76-3C19407A1C5F} = {E5A148A1-DE7B-4D17-ABE8-831B9673B863}
{5B993DD9-A9B8-434C-B444-F1CFFB947F79} = {E5A148A1-DE7B-4D17-ABE8-831B9673B863}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
@@ -64,7 +64,7 @@
<Compile Include="Point2.cs" />
<Compile Include="Ray2.cs" />
<Compile Include="PrimitivesHelper.cs" />
<Compile Include="Segment2D.cs" />
<Compile Include="Segment2.cs" />
<Compile Include="Size2.cs" />
<Compile Include="Serialization\ContentManagerJsonConverter.cs" />
<Compile Include="Serialization\TextureRegionService.cs" />
@@ -9,48 +9,48 @@ namespace MonoGame.Extended
/// </summary>
/// <seealso cref="IEquatable{T}" />
/// <seealso cref="IEquatableByRef{Segment2}" />
public struct Segment2D : IEquatable<Segment2D>, IEquatableByRef<Segment2D>
public struct Segment2 : IEquatable<Segment2>, IEquatableByRef<Segment2>
{
/// <summary>
/// The starting <see cref="Point2" /> of this <see cref="Segment2D" />.
/// The starting <see cref="Point2" /> of this <see cref="Segment2" />.
/// </summary>
public Point2 Start;
/// <summary>
/// The ending <see cref="Point2" /> of this <see cref="Segment2D" />.
/// The ending <see cref="Point2" /> of this <see cref="Segment2" />.
/// </summary>
public Point2 End;
/// <summary>
/// Initializes a new instance of the <see cref="Segment2D" /> structure from the specified starting and ending
/// Initializes a new instance of the <see cref="Segment2" /> structure from the specified starting and ending
/// <see cref="Point2" /> structures.
/// </summary>
/// <param name="start">The starting point.</param>
/// <param name="end">The ending point.</param>
public Segment2D(Point2 start, Point2 end)
public Segment2(Point2 start, Point2 end)
{
Start = start;
End = end;
}
/// <summary>
/// Initializes a new instance of the <see cref="Segment2D" /> structure.
/// Initializes a new instance of the <see cref="Segment2" /> structure.
/// </summary>
/// <param name="x1">The starting x-coordinate.</param>
/// <param name="y1">The starting y-coordinate.</param>
/// <param name="x2">The ending x-coordinate.</param>
/// <param name="y2">The ending y-coordinate.</param>
public Segment2D(float x1, float y1, float x2, float y2)
public Segment2(float x1, float y1, float x2, float y2)
: this(new Point2(x1, y1), new Point2(x2, y2))
{
}
// Real-Time Collision Detection, Christer Ericson, 2005. Chapter 5.1.2; Basic Primitive Tests - Closest Point on Line Segment to Point. pg 127-130
/// <summary>
/// Computes the closest <see cref="Point2" /> on this <see cref="Segment2D" /> to a specified <see cref="Point2" />.
/// Computes the closest <see cref="Point2" /> on this <see cref="Segment2" /> to a specified <see cref="Point2" />.
/// </summary>
/// <param name="point">The point.</param>
/// <returns>The closest <see cref="Point2" /> on this <see cref="Segment2D" /> to the <paramref name="point" />.</returns>
/// <returns>The closest <see cref="Point2" /> on this <see cref="Segment2" /> to the <paramref name="point" />.</returns>
public Point2 ClosestPointTo(Point2 point)
{
// Computes the parameterized position: d(t) = Start + t * (End Start)
@@ -76,10 +76,10 @@ namespace MonoGame.Extended
// Real-Time Collision Detection, Christer Ericson, 2005. Chapter 5.1.2.1; Basic Primitive Tests - Distance of Point to Segment. pg 127-130
/// <summary>
/// Computes the squared distance from this <see cref="Segment2D" /> to a specified <see cref="Point2" />.
/// Computes the squared distance from this <see cref="Segment2" /> to a specified <see cref="Point2" />.
/// </summary>
/// <param name="point">The point.</param>
/// <returns>The squared distance from this <see cref="Segment2D" /> to a specified <see cref="Point2" />.</returns>
/// <returns>The squared distance from this <see cref="Segment2" /> to a specified <see cref="Point2" />.</returns>
public float SquaredDistanceTo(Point2 point)
{
var startToEnd = End - Start;
@@ -98,17 +98,17 @@ namespace MonoGame.Extended
}
/// <summary>
/// Computes the distance from this <see cref="Segment2D" /> to a specified <see cref="Point2" />.
/// Computes the distance from this <see cref="Segment2" /> to a specified <see cref="Point2" />.
/// </summary>
/// <param name="point">The point.</param>
/// <returns>The distance from this <see cref="Segment2D" /> to a specified <see cref="Point2" />.</returns>
/// <returns>The distance from this <see cref="Segment2" /> to a specified <see cref="Point2" />.</returns>
public float DistanceTo(Point2 point)
{
return (float) Math.Sqrt(SquaredDistanceTo(point));
}
/// <summary>
/// Determines whether this <see cref="Segment2D" /> intersects with the specified <see cref="BoundingRectangle" />.
/// Determines whether this <see cref="Segment2" /> intersects with the specified <see cref="BoundingRectangle" />.
/// </summary>
/// <param name="rectangle">The bounding box.</param>
/// <param name="intersectionPoint">
@@ -116,7 +116,7 @@ namespace MonoGame.Extended
/// intersection was found; otherwise, the <see cref="Point2.NaN" />. This parameter is passed uninitialized.
/// </param>
/// <returns>
/// <c>true</c> if this <see cref="Segment2D" /> intersects with <paramref name="rectangle" />; otherwise,
/// <c>true</c> if this <see cref="Segment2" /> intersects with <paramref name="rectangle" />; otherwise,
/// <c>false</c>.
/// </returns>
public bool Intersects(RectangleF rectangle, out Point2 intersectionPoint)
@@ -160,7 +160,7 @@ namespace MonoGame.Extended
}
/// <summary>
/// Determines whether this <see cref="Segment2D" /> intersects with the specified <see cref="BoundingRectangle" />.
/// Determines whether this <see cref="Segment2" /> intersects with the specified <see cref="BoundingRectangle" />.
/// </summary>
/// <param name="boundingRectangle">The bounding box.</param>
/// <param name="intersectionPoint">
@@ -168,7 +168,7 @@ namespace MonoGame.Extended
/// intersection was found; otherwise, the <see cref="Point2.NaN" />. This parameter is passed uninitialized.
/// </param>
/// <returns>
/// <c>true</c> if this <see cref="Segment2D" /> intersects with <paramref name="boundingRectangle" />; otherwise,
/// <c>true</c> if this <see cref="Segment2" /> intersects with <paramref name="boundingRectangle" />; otherwise,
/// <c>false</c>.
/// </returns>
public bool Intersects(BoundingRectangle boundingRectangle, out Point2 intersectionPoint)
@@ -212,86 +212,86 @@ namespace MonoGame.Extended
}
/// <summary>
/// Compares two <see cref="Segment2D" /> structures. The result specifies
/// Compares two <see cref="Segment2" /> structures. The result specifies
/// whether the values of the <see cref="Start" /> and <see cref="End" />
/// fields of the two <see cref='Segment2D' />
/// fields of the two <see cref='Segment2' />
/// structures are equal.
/// </summary>
/// <param name="first">The first segment.</param>
/// <param name="second">The second segment.</param>
/// <returns>
/// <c>true</c> if the <see cref="Start" /> and <see cref="End" />
/// fields of the two <see cref="Segment2D" />
/// fields of the two <see cref="Segment2" />
/// structures are equal; otherwise, <c>false</c>.
/// </returns>
public static bool operator ==(Segment2D first, Segment2D second)
public static bool operator ==(Segment2 first, Segment2 second)
{
return first.Equals(ref second);
}
/// <summary>
/// Indicates whether this <see cref="Segment2D" /> is equal to another <see cref="Segment2D" />.
/// Indicates whether this <see cref="Segment2" /> is equal to another <see cref="Segment2" />.
/// </summary>
/// <param name="segment">The segment.</param>
/// <returns>
/// <c>true</c> if this <see cref="Segment2D" /> is equal to the <paramref name="segment" />; otherwise, <c>false</c>.
/// <c>true</c> if this <see cref="Segment2" /> is equal to the <paramref name="segment" />; otherwise, <c>false</c>.
/// </returns>
public bool Equals(Segment2D segment)
public bool Equals(Segment2 segment)
{
return Equals(ref segment);
}
/// <summary>
/// Indicates whether this <see cref="Segment2D" /> is equal to another <see cref="Segment2D" />.
/// Indicates whether this <see cref="Segment2" /> is equal to another <see cref="Segment2" />.
/// </summary>
/// <param name="segment">The segment.</param>
/// <returns>
/// <c>true</c> if this <see cref="Segment2D" /> is equal to the <paramref name="segment" /> parameter; otherwise,
/// <c>true</c> if this <see cref="Segment2" /> is equal to the <paramref name="segment" /> parameter; otherwise,
/// <c>false</c>.
/// </returns>
public bool Equals(ref Segment2D segment)
public bool Equals(ref Segment2 segment)
{
return (Start == segment.Start) && (End == segment.End);
}
/// <summary>
/// Returns a value indicating whether this <see cref="Segment2D" /> is equal to a specified object.
/// Returns a value indicating whether this <see cref="Segment2" /> is equal to a specified object.
/// </summary>
/// <param name="obj">The object to make the comparison with.</param>
/// <returns>
/// <c>true</c> if this <see cref="Segment2D" /> is equal to <paramref name="obj" />; otherwise, <c>false</c>.
/// <c>true</c> if this <see cref="Segment2" /> is equal to <paramref name="obj" />; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object obj)
{
if (obj is Segment2D)
return Equals((Segment2D) obj);
if (obj is Segment2)
return Equals((Segment2) obj);
return false;
}
/// <summary>
/// Compares two <see cref="Segment2D" /> structures. The result specifies
/// Compares two <see cref="Segment2" /> structures. The result specifies
/// whether the values of the <see cref="Start" /> and <see cref="End" />
/// fields of the two <see cref="Segment2D" />
/// fields of the two <see cref="Segment2" />
/// structures are unequal.
/// </summary>
/// <param name="first">The first point.</param>
/// <param name="second">The second point.</param>
/// <returns>
/// <c>true</c> if the <see cref="Start" /> and <see cref="End" />
/// fields of the two <see cref="Segment2D" />
/// fields of the two <see cref="Segment2" />
/// structures are unequal; otherwise, <c>false</c>.
/// </returns>
public static bool operator !=(Segment2D first, Segment2D second)
public static bool operator !=(Segment2 first, Segment2 second)
{
return !(first == second);
}
/// <summary>
/// Returns a hash code of this <see cref="Segment2D" /> suitable for use in hashing algorithms and data
/// Returns a hash code of this <see cref="Segment2" /> suitable for use in hashing algorithms and data
/// structures like a hash table.
/// </summary>
/// <returns>
/// A hash code of this <see cref="Segment2D" />.
/// A hash code of this <see cref="Segment2" />.
/// </returns>
public override int GetHashCode()
{
@@ -302,10 +302,10 @@ namespace MonoGame.Extended
}
/// <summary>
/// Returns a <see cref="string" /> that represents this <see cref="Segment2D" />.
/// Returns a <see cref="string" /> that represents this <see cref="Segment2" />.
/// </summary>
/// <returns>
/// A <see cref="string" /> that represents this <see cref="Segment2D" />.
/// A <see cref="string" /> that represents this <see cref="Segment2" />.
/// </returns>
public override string ToString()
{
@@ -17,7 +17,7 @@ namespace MonoGame.Extended.Gui.Tests.Controls
{
var availableSize = new Size2(800, 480);
var context = Substitute.For<IGuiContext>();
var button = new GuiButton();
var button = new Button();
var desiredSize = button.GetDesiredSize(context, availableSize);
Assert.That(desiredSize, Is.EqualTo(Size2.Empty));
@@ -25,7 +25,7 @@ namespace MonoGame.Extended.Tests.Primitives
[TestCaseSource(nameof(ConstructorTestCases))]
public void Constructor(Point2 startingPoint, Point2 endingPoint)
{
var segment = new Segment2D(startingPoint, endingPoint);
var segment = new Segment2(startingPoint, endingPoint);
Assert.AreEqual(startingPoint, segment.Start);
Assert.AreEqual(endingPoint, segment.End);
}
@@ -35,20 +35,20 @@ namespace MonoGame.Extended.Tests.Primitives
get
{
yield return
new TestCaseData(new Segment2D(), new Point2(), new Point2()).SetName(
new TestCaseData(new Segment2(), new Point2(), new Point2()).SetName(
"The closest point on the empty segment to the zero point is the zero point.");
yield return
new TestCaseData(new Segment2D(new Point2(0, 0), new Point2(200, 0)), new Point2(-100, 200),
new TestCaseData(new Segment2(new Point2(0, 0), new Point2(200, 0)), new Point2(-100, 200),
new Point2(0, 0)).SetName(
"The closest point on a non-empty segment to a point which is projected beyond the start of the segment is the segment's starting point.")
;
yield return
new TestCaseData(new Segment2D(new Point2(0, 0), new Point2(200, 0)), new Point2(400, 200),
new TestCaseData(new Segment2(new Point2(0, 0), new Point2(200, 0)), new Point2(400, 200),
new Point2(200, 0)).SetName(
"The closest point on a non-empty segment to a point which is projected beyond the end of the segment is the segment's ending point.")
;
yield return
new TestCaseData(new Segment2D(new Point2(0, 0), new Point2(200, 0)), new Point2(100, 200),
new TestCaseData(new Segment2(new Point2(0, 0), new Point2(200, 0)), new Point2(100, 200),
new Point2(100, 0)).SetName(
"The closest point on a non-empty segment to a point which is projected inside the segment is the projected point.")
;
@@ -57,7 +57,7 @@ namespace MonoGame.Extended.Tests.Primitives
[Test]
[TestCaseSource(nameof(ClosestPointTestCases))]
public void ClosestPoint(Segment2D segment, Point2 point, Point2 expectedClosestPoint)
public void ClosestPoint(Segment2 segment, Point2 point, Point2 expectedClosestPoint)
{
var actualClosestPoint = segment.ClosestPointTo(point);
Assert.AreEqual(expectedClosestPoint, actualClosestPoint);
@@ -68,20 +68,20 @@ namespace MonoGame.Extended.Tests.Primitives
get
{
yield return
new TestCaseData(new Segment2D(), new Point2(), 0).SetName(
new TestCaseData(new Segment2(), new Point2(), 0).SetName(
"The squared distance of the zero point to the empty segment is 0.");
yield return
new TestCaseData(new Segment2D(new Point2(0, 0), new Point2(20, 0)), new Point2(-10, 20), 500)
new TestCaseData(new Segment2(new Point2(0, 0), new Point2(20, 0)), new Point2(-10, 20), 500)
.SetName(
"The squared distance of a point projected beyond the start of a non-empty segment is the squared distance from the segment's starting point to the point.")
;
yield return
new TestCaseData(new Segment2D(new Point2(0, 0), new Point2(20, 0)), new Point2(40, 20), 400)
new TestCaseData(new Segment2(new Point2(0, 0), new Point2(20, 0)), new Point2(40, 20), 400)
.SetName(
"The squared distance of a point projected beyond the end of a non-empty segment is the squared distance from the segment's ending point to the point.")
;
yield return
new TestCaseData(new Segment2D(new Point2(0, 0), new Point2(20, 0)), new Point2(10, 25), 625).SetName
new TestCaseData(new Segment2(new Point2(0, 0), new Point2(20, 0)), new Point2(10, 25), 625).SetName
(
"The squared distance of a point projected inside a non-empty segment is the squared distance from the projected point to the point.")
;
@@ -90,7 +90,7 @@ namespace MonoGame.Extended.Tests.Primitives
[Test]
[TestCaseSource(nameof(SquaredDistanceToPointTestCases))]
public void SquaredDistanceToPoint(Segment2D segment, Point2 point,
public void SquaredDistanceToPoint(Segment2 segment, Point2 point,
float expectedDistance)
{
var actualDistance = segment.SquaredDistanceTo(point);
@@ -102,18 +102,18 @@ namespace MonoGame.Extended.Tests.Primitives
get
{
yield return
new TestCaseData(new Segment2D(), new BoundingRectangle(), true, Point2.Zero).SetName(
new TestCaseData(new Segment2(), new BoundingRectangle(), true, Point2.Zero).SetName(
"The empty segment intersects the empty bounding box.");
yield return
new TestCaseData(new Segment2D(new Point2(-75, -75), new Point2(75, -75)),
new TestCaseData(new Segment2(new Point2(-75, -75), new Point2(75, -75)),
new BoundingRectangle(new Point2(), new Size2(50, 50)), false, Point2.NaN).SetName(
"A non-empty segment outside a non-empty bounding box does not intersect the bounding box.");
yield return
new TestCaseData(new Segment2D(new Point2(0, 0), new Point2(25, 0)), new BoundingRectangle(new Point2(), new Size2(50, 50)),
new TestCaseData(new Segment2(new Point2(0, 0), new Point2(25, 0)), new BoundingRectangle(new Point2(), new Size2(50, 50)),
true, new Point2(0, 0)).SetName(
"A non-empty segment inside a non-empty bounding box intersects the bounding box.");
yield return
new TestCaseData(new Segment2D(new Point2(-100, 0), new Point2(100, 0)),
new TestCaseData(new Segment2(new Point2(-100, 0), new Point2(100, 0)),
new BoundingRectangle(new Point2(), new Size2(50, 50)),
true, new Point2(-50, 0)).SetName(
"A non-empty segment crossing a non-empty bounding box intersects the bounding box.");
@@ -122,7 +122,7 @@ namespace MonoGame.Extended.Tests.Primitives
[Test]
[TestCaseSource(nameof(IntersectsBoundingRectangleTestCases))]
public void IntersectsBoundingRectangle(Segment2D segment, BoundingRectangle boundingRectangle, bool expectedResult,
public void IntersectsBoundingRectangle(Segment2 segment, BoundingRectangle boundingRectangle, bool expectedResult,
Point2 expectedIntersectionPoint)
{
Point2 actualIntersectionPoint;
@@ -145,18 +145,18 @@ namespace MonoGame.Extended.Tests.Primitives
get
{
yield return
new TestCaseData(new Segment2D(), new Segment2D(), true).SetName("Empty segments are equal.")
new TestCaseData(new Segment2(), new Segment2(), true).SetName("Empty segments are equal.")
;
yield return
new TestCaseData(
new Segment2D(new Point2(0, 0), new Point2(float.MaxValue, float.MinValue)),
new Segment2D(new Point2(0, 0),
new Segment2(new Point2(0, 0), new Point2(float.MaxValue, float.MinValue)),
new Segment2(new Point2(0, 0),
new Point2(float.MinValue, float.MaxValue)), false).SetName(
"Two different non-empty segments are not equal.");
yield return
new TestCaseData(
new Segment2D(new Point2(0, 0), new Point2(float.MinValue, float.MaxValue)),
new Segment2D(new Point2(0, 0),
new Segment2(new Point2(0, 0), new Point2(float.MinValue, float.MaxValue)),
new Segment2(new Point2(0, 0),
new Point2(float.MinValue, float.MaxValue)), true).SetName(
"Two identical non-empty segments are equal.");
}
@@ -164,7 +164,7 @@ namespace MonoGame.Extended.Tests.Primitives
[Test]
[TestCaseSource(nameof(EqualityTestCases))]
public void Equality(Segment2D segment1, Segment2D segment2, bool expectedToBeEqual)
public void Equality(Segment2 segment1, Segment2 segment2, bool expectedToBeEqual)
{
Assert.IsTrue(Equals(segment1, segment2) == expectedToBeEqual);
Assert.IsTrue(segment1 == segment2 == expectedToBeEqual);
@@ -180,16 +180,16 @@ namespace MonoGame.Extended.Tests.Primitives
get
{
yield return
new TestCaseData(new Segment2D(), null, false).SetName("A segment is not equal to a null object.");
new TestCaseData(new Segment2(), null, false).SetName("A segment is not equal to a null object.");
yield return
new TestCaseData(new Segment2D(), new object(), false).SetName(
new TestCaseData(new Segment2(), new object(), false).SetName(
"A segment is not equal to an instantiated object.");
}
}
[Test]
[TestCaseSource(nameof(InequalityTestCases))]
public void Inequality(Segment2D segment, object obj, bool expectedToBeEqual)
public void Inequality(Segment2 segment, object obj, bool expectedToBeEqual)
{
Assert.IsTrue(segment.Equals(obj) == expectedToBeEqual);
}
@@ -199,22 +199,22 @@ namespace MonoGame.Extended.Tests.Primitives
get
{
yield return
new TestCaseData(new Segment2D(), new Segment2D(), true).SetName(
new TestCaseData(new Segment2(), new Segment2(), true).SetName(
"Two empty segments have the same hash code.");
yield return
new TestCaseData(new Segment2D(new Point2(0, 0), new Point2(50, 50)),
new Segment2D(new Point2(0, 0), new Point2(50, 50)), true).SetName(
new TestCaseData(new Segment2(new Point2(0, 0), new Point2(50, 50)),
new Segment2(new Point2(0, 0), new Point2(50, 50)), true).SetName(
"Two indentical non-empty segments have the same hash code.");
yield return
new TestCaseData(new Segment2D(new Point2(0, 0), new Point2(50, 50)),
new Segment2D(new Point2(50, 50), new Point2(50, 50)), false).SetName(
new TestCaseData(new Segment2(new Point2(0, 0), new Point2(50, 50)),
new Segment2(new Point2(50, 50), new Point2(50, 50)), false).SetName(
"Two different non-empty segments do not have the same hash code.");
}
}
[Test]
[TestCaseSource(nameof(HashCodeTestCases))]
public void HashCode(Segment2D segment1, Segment2D segment2, bool expectedThatHashCodesAreEqual)
public void HashCode(Segment2 segment1, Segment2 segment2, bool expectedThatHashCodesAreEqual)
{
var hashCode1 = segment1.GetHashCode();
var hashCode2 = segment2.GetHashCode();
@@ -229,11 +229,11 @@ namespace MonoGame.Extended.Tests.Primitives
get
{
yield return
new TestCaseData(new Segment2D(),
new TestCaseData(new Segment2(),
string.Format(CultureInfo.CurrentCulture, "{0} -> {1}", new Point2(),
new Point2())).SetName(
"The empty segment has the expected string representation using the current culture.");
yield return new TestCaseData(new Segment2D(new Point2(5.1f, -5.123f), new Point2(5.4f, -5.4123f)),
yield return new TestCaseData(new Segment2(new Point2(5.1f, -5.123f), new Point2(5.4f, -5.4123f)),
string.Format(CultureInfo.CurrentCulture, "{0} -> {1}", new Point2(5.1f, -5.123f),
new Point2(5.4f, -5.4123f))).SetName(
"A non-empty segment has the expected string representation using the current culture.");
@@ -242,7 +242,7 @@ namespace MonoGame.Extended.Tests.Primitives
[Test]
[TestCaseSource(nameof(StringCases))]
public void String(Segment2D segment, string expectedString)
public void String(Segment2 segment, string expectedString)
{
var actualString = segment.ToString();
Assert.AreEqual(expectedString, actualString);