-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option to convert XY to Hex/RGB for issue #320
- Loading branch information
1 parent
95a1124
commit 6add85d
Showing
7 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
src/HueApi.ColorConverters.Tests/HueApi.ColorConverters.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net9.0</TargetFramework> | ||
<LangVersion>latest</LangVersion> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="3.6.3" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="3.6.3" /> | ||
<PackageReference Include="coverlet.collector" Version="6.0.2"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\HueApi.ColorConverters\HueApi.ColorConverters.csproj" /> | ||
<ProjectReference Include="..\HueApi\HueApi.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
22 changes: 22 additions & 0 deletions
22
src/HueApi.ColorConverters.Tests/XyPositionExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using HueApi.ColorConverters.Original.Extensions; | ||
using HueApi.Models; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
|
||
namespace HueApi.ColorConverters.Tests | ||
{ | ||
[TestClass] | ||
public sealed class XyPositionExtensionsTests | ||
{ | ||
[TestMethod] | ||
public void TestHexRgb() | ||
{ | ||
var position = new XyPosition { X = 1, Y = 1 }; | ||
var hex = position.ToHex(); | ||
var rgb = position.ToRGBColor(); | ||
|
||
Assert.IsNotNull(hex); | ||
Assert.IsNotNull(rgb); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/HueApi.ColorConverters/Original/Extensions/XyPositionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using HueApi.Models; | ||
|
||
namespace HueApi.ColorConverters.Original.Extensions | ||
{ | ||
public static class XyPositionExtensions | ||
{ | ||
public static string ToHex(this XyPosition position) | ||
{ | ||
return HueColorConverter.HexFromXy(position.X, position.Y); | ||
} | ||
|
||
public static RGBColor ToRGBColor(this XyPosition position) | ||
{ | ||
return new RGBColor(position.ToHex()); | ||
} | ||
|
||
public static RGBColor ToRGBColor(this XyPosition position, string model) | ||
{ | ||
return HueColorConverter.ColorFromXY(new CGPoint(position.X, position.Y), model ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters