Skip to content

Commit

Permalink
Split graphics in 2 libraries a core and a full one (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellerbach authored May 5, 2023
1 parent 1428ca6 commit 9a47997
Show file tree
Hide file tree
Showing 158 changed files with 5,695 additions and 3,578 deletions.
1 change: 1 addition & 0 deletions ManagedDrivers/Gc9A01/nanoFramework.Graphics.Gc9A01.nfproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\nanoFramework.Graphics.Core\nanoFramework.Graphics.Core.nfproj" />
<ProjectReference Include="..\..\nanoFramework.Graphics\nanoFramework.Graphics.nfproj" />
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\nanoFramework.Graphics.Core\nanoFramework.Graphics.Core.nfproj" />
<ProjectReference Include="..\..\nanoFramework.Graphics\nanoFramework.Graphics.nfproj" />
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\nanoFramework.Graphics.Core\nanoFramework.Graphics.Core.nfproj" />
<ProjectReference Include="..\..\nanoFramework.Graphics\nanoFramework.Graphics.nfproj" />
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\nanoFramework.Graphics.Core\nanoFramework.Graphics.Core.nfproj" />
<ProjectReference Include="..\..\nanoFramework.Graphics\nanoFramework.Graphics.nfproj" />
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\nanoFramework.Graphics.Core\nanoFramework.Graphics.Core.nfproj" />
<ProjectReference Include="..\..\nanoFramework.Graphics\nanoFramework.Graphics.nfproj" />
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\nanoFramework.Graphics.Core\nanoFramework.Graphics.Core.nfproj" />
<ProjectReference Include="..\..\nanoFramework.Graphics\nanoFramework.Graphics.nfproj" />
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
Expand Down
1 change: 1 addition & 0 deletions ManagedDrivers/St7735/nanoFramework.Graphics.St7735.nfproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\nanoFramework.Graphics.Core\nanoFramework.Graphics.Core.nfproj" />
<ProjectReference Include="..\..\nanoFramework.Graphics\nanoFramework.Graphics.nfproj" />
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
Expand Down
2 changes: 1 addition & 1 deletion ManagedDrivers/St7789/St7789.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace nanoFramework.UI.GraphicDrivers
/// <summary>
/// ST7735 managed graphic driver.
/// </summary>
public static class St7735
public static class St7789
{
private static GraphicDriver _driver;

Expand Down
1 change: 1 addition & 0 deletions ManagedDrivers/St7789/nanoFramework.Graphics.St7789.nfproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\nanoFramework.Graphics.Core\nanoFramework.Graphics.Core.nfproj" />
<ProjectReference Include="..\..\nanoFramework.Graphics\nanoFramework.Graphics.nfproj" />
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
Expand Down
99 changes: 99 additions & 0 deletions Tests/ColorTests/ColorTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Copyright (c) .NET Foundation and Contributors
// Portions Copyright (c) Microsoft Corporation. All rights reserved.
// See LICENSE file in the project root for full license information.

using nanoFramework.TestFramework;
using System.Drawing;

namespace nanoFramework.UI
{
[TestClass]
public class ColorTests
{
[TestMethod]
public void ColorTestBasicSerialization()
{
// Arrange
var col = Color.Red;

// Act
var col2 = Color.FromHex(col.ToString());

// Assert
Assert.AreEqual(col, col2);
}

[TestMethod]
public void ColorTestColorSerialization()
{
// Arrange
var col = "Red";

// Act
var col2 = Color.FromName(col);

// Assert
Assert.IsNotNull(col2);
Assert.AreEqual(Color.Red, col2);
}

[TestMethod]
public void ColorTestColorCaseSerialization()
{
// Arrange
var col = "rEd";

// Act
var col2 = Color.FromName(col);

// Assert
Assert.IsNotNull(col2);
Assert.AreEqual(Color.Red, col2);
}

[TestMethod]
public void ColorEqualTest()
{
// Arrange
var col1 = Color.Red;
var col2 = Color.Red;

Assert.AreEqual(col1, col2);
Assert.IsTrue(col1 == col2);
}

[DataRow(new object[] { (byte)0b0000_0111, (byte)0b0000_0011, (byte)0b0000_0111, (ushort)0x0000 })]
[DataRow(new object[] { (byte)0b0000_1111, (byte)0b0000_0111, (byte)0b0000_1111, (ushort)0b0000_1000_0010_0001 })]
[DataRow(new object[] { (byte)0b0000_1111, (byte)0b0000_0111, (byte)0b1000_1111, (ushort)0b0000_1000_0011_0001 })]
[DataRow(new object[] { (byte)0b0000_1111, (byte)0b1000_0111, (byte)0b1000_1111, (ushort)0b0000_1100_0011_0001 })]
[DataRow(new object[] { (byte)0b1000_1111, (byte)0b1000_0111, (byte)0b1000_1111, (ushort)0b1000_1100_0011_0001 })]
public void TestBgr565(byte b, byte g, byte r, ushort correctResult)
{
// Arrange
var col = Color.FromArgb(255, r, g, b);

// Act
var result = col.ToBgr565();

// Assert
Assert.AreEqual(correctResult, result);
}

[DataRow(new object[] { (byte)0b0000_0111, (byte)0b0000_0011, (byte)0b0000_0111, (byte)ColorOrder.Rgb, (byte)8, (byte)8, (byte)8, (uint)0b0000_0111_0000_0011_0000_0111 })]
[DataRow(new object[] { (byte)0b0000_0111, (byte)0b0000_0011, (byte)0b0000_0111, (byte)ColorOrder.Rgb, (byte)5, (byte)6, (byte)5, (uint)0b0000_0000_0000_0000_0000_0000 })]
[DataRow(new object[] { (byte)0b0000_1111, (byte)0b0000_0111, (byte)0b0000_1111, (byte)ColorOrder.Rgb, (byte)5, (byte)6, (byte)5, (uint)0b0000_0000_0000_1000_0010_0001 })]
[DataRow(new object[] { (byte)0b0000_1111, (byte)0b0000_0111, (byte)0b0000_1111, (byte)ColorOrder.Rgb, (byte)8, (byte)6, (byte)5, (uint)0b0000_0000_0111_1000_0010_0001 })]
[DataRow(new object[] { (byte)0b0000_1111, (byte)0b0000_0111, (byte)0b0000_1111, (byte)ColorOrder.Rbg, (byte)8, (byte)6, (byte)5, (uint)0b0000_0000_0111_1000_0100_0001 })]
public void TestRgbFormat(byte r, byte g, byte b, byte order, byte numR, byte numG, byte numB, uint correctResult)
{
// Arrange
var col = Color.FromArgb(0, r, g, b);

// Act
var result = col.ToRgbFormat((ColorOrder)order, numR, numG, numB);

// Assert
Assert.AreEqual(correctResult, result);
}
}
}
55 changes: 55 additions & 0 deletions Tests/ColorTests/ColorTests.nfproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<NanoFrameworkProjectSystemPath>$(MSBuildExtensionsPath)\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
</PropertyGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" />
<ItemGroup>
<ProjectCapability Include="TestContainer" />
</ItemGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<ProjectGuid>cc585116-52d9-4fa0-bf8d-6f8e1c9894ff</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<FileAlignment>512</FileAlignment>
<RootNamespace>ColorTests</RootNamespace>
<AssemblyName>NFUnitTest</AssemblyName>
<IsCodedUITest>False</IsCodedUITest>
<IsTestProject>true</IsTestProject>
<TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
</PropertyGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
<PropertyGroup>
<RunSettingsFilePath>$(MSBuildProjectDirectory)\nano.runsettings</RunSettingsFilePath>
</PropertyGroup>
<ItemGroup>
<Compile Include="ColorTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="mscorlib">
<HintPath>..\..\packages\nanoFramework.CoreLibrary.1.14.2\lib\mscorlib.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.TestFramework">
<HintPath>..\..\packages\nanoFramework.TestFramework.2.1.71\lib\nanoFramework.TestFramework.dll</HintPath>
</Reference>
<Reference Include="nanoFramework.UnitTestLauncher">
<HintPath>..\..\packages\nanoFramework.TestFramework.2.1.71\lib\nanoFramework.UnitTestLauncher.exe</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="nano.runsettings" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\nanoFramework.Graphics.Core\nanoFramework.Graphics.Core.nfproj" />
</ItemGroup>
<ItemGroup>
<Content Include="packages.lock.json" />
</ItemGroup>
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
</Project>
16 changes: 16 additions & 0 deletions Tests/ColorTests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("nanoFramework.Graphics.Core.Tests")]
[assembly: AssemblyCompany("nanoFramework Contributors")]
[assembly: AssemblyProduct("nanoFramework.Graphics.Tests")]
[assembly: AssemblyCopyright("Copyright © nanoFramework Contributors 2020")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
14 changes: 14 additions & 0 deletions Tests/ColorTests/nano.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<ResultsDirectory>.\TestResults</ResultsDirectory><!-- Path relative to solution directory -->
<TestSessionTimeout>120000</TestSessionTimeout><!-- Milliseconds -->
<TargetFrameworkVersion>net48</TargetFrameworkVersion>
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
<nanoFrameworkAdapter>
<Logging>None</Logging> <!--Set to the desired level of logging for Unit Test execution. Possible values are: None, Detailed, Verbose, Error. -->
<IsRealHardware>False</IsRealHardware><!--Set to true to run tests on real hardware. -->
</nanoFrameworkAdapter>
</RunSettings>
5 changes: 5 additions & 0 deletions Tests/ColorTests/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="nanoFramework.CoreLibrary" version="1.14.2" targetFramework="netnano1.0" />
<package id="nanoFramework.TestFramework" version="2.1.71" targetFramework="netnano1.0" developmentDependency="true" />
</packages>
19 changes: 19 additions & 0 deletions Tests/ColorTests/packages.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"version": 1,
"dependencies": {
".NETnanoFramework,Version=v1.0": {
"nanoFramework.CoreLibrary": {
"type": "Direct",
"requested": "[1.14.2, 1.14.2]",
"resolved": "1.14.2",
"contentHash": "j1mrz4mitl5LItvmHMsw1aHzCAfvTTgIkRxA0mhs5mSpctJ/BBcuNwua5j3MspfRNKreCQPy/qZy/D9ADLL/PA=="
},
"nanoFramework.TestFramework": {
"type": "Direct",
"requested": "[2.1.71, 2.1.71]",
"resolved": "2.1.71",
"contentHash": "V2SYltqAwkw2ZSAZlyG515qIt2T3PL7v8UMF0GrknmTleA0HJ1qNHDXw4ymaV+RVrMexP9c27UuzQZBAKFxo9Q=="
}
}
}
}
35 changes: 35 additions & 0 deletions nanoFramework.Graphics.Core.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
<metadata>
<id>nanoFramework.Graphics.Core</id>
<version>$version$</version>
<title>nanoFramework.Graphics.Core</title>
<authors>nanoframework</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="file">LICENSE.md</license>
<releaseNotes>
</releaseNotes>
<developmentDependency>false</developmentDependency>
<readme>docs\README.md</readme>
<projectUrl>https://github.com/nanoframework/nanoFramework.Graphics.Core</projectUrl>
<icon>images\nf-logo.png</icon>
<repository type="git" url="https://github.com/nanoframework/nanoFramework.Graphics.Core" commit="$commit$" />
<copyright>Copyright (c) .NET Foundation and Contributors</copyright>
<description>This package includes the nanoFramework.Graphics.Core assembly for .NET nanoFramework C# projects.</description>
<tags>nanoFramework C# csharp netmf netnf nanoFramework.Graphics.Core</tags>
<dependencies>
<dependency id="nanoFramework.CoreLibrary" version="1.14.2" />
</dependencies>
</metadata>
<files>
<file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.dll" target="lib\nanoFramework.Graphics.Core.dll" />
<file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.pdb" target="lib\nanoFramework.Graphics.Core.pdb" />
<file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.pdbx" target="lib\nanoFramework.Graphics.Core.pdbx" />
<file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.pe" target="lib\nanoFramework.Graphics.Core.pe" />
<file src="nanoFramework.Graphics.Core\bin\Release\nanoFramework.Graphics.Core.xml" target="lib\nanoFramework.Graphics.Core.xml" />
<file src="assets\readme.txt" target="" />
<file src="README.md" target="docs\" />
<file src="assets\nf-logo.png" target="images" />
<file src="LICENSE.md" target="" />
</files>
</package>
Loading

0 comments on commit 9a47997

Please sign in to comment.