RotatedGrid 0.1.0

dotnet add package RotatedGrid --version 0.1.0                
NuGet\Install-Package RotatedGrid -Version 0.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RotatedGrid" Version="0.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RotatedGrid --version 0.1.0                
#r "nuget: RotatedGrid, 0.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RotatedGrid as a Cake Addin
#addin nuget:?package=RotatedGrid&version=0.1.0

// Install RotatedGrid as a Cake Tool
#tool nuget:?package=RotatedGrid&version=0.1.0                

Rotated grids in C#

🎨 For halftone dithering and more.

This project provides an enumerator for creating grid coordinates at a specified frequency along a rotated grid. This can come in useful e.g. when you want to create halftone dithering grids for CMYK processing.

This is a port of the rotated-grid Rust crate. The following screenshot is taken from that repo; this repository does not contain any visualization code.

<div align="center" style="text-align: center"> <img src="https://raw.githubusercontent.com/sunsided/rotated-grid/main/readme/grid.png" alt="CMYK grid examples" /> </div>

Examples

Enumeration on an aligned grid (0 degrees rotation). The points are evenly spaced by dx=2 and dy=3, centered inside a 10×7 rectangle. No offset is used.

const float width = 10.0F;
const float height = 7.0F;

var grid = new GridPositionIterator(width, height, 2.0F, 3.0F, 0.0F, 0.0F, Angle.Zero);

var coordinates = new List<GridCoord>();
while (grid.MoveNext())
{
    coordinates.Add(grid.Current);
}

coordinates.Count.Should().Be(15);
coordinates.Should().ContainInOrder(
    // First row
    new GridCoord(1.0F, 0.5F),
    new GridCoord(3.0F, 0.5F),
    new GridCoord(5.0F, 0.5F),
    new GridCoord(7.0F, 0.5F),
    new GridCoord(9.0F, 0.5F),
    // Second row row
    new GridCoord(1.0F, 3.5F),
    new GridCoord(3.0F, 3.5F),
    new GridCoord(5.0F, 3.5F),
    new GridCoord(7.0F, 3.5F),
    new GridCoord(9.0F, 3.5F),
    // Third row
    new GridCoord(1.0F, 6.5F),
    new GridCoord(3.0F, 6.5F),
    new GridCoord(5.0F, 6.5F),
    new GridCoord(7.0F, 6.5F),
    new GridCoord(9.0F, 6.5F)
    );

Enumeration on a rotated grid; in the example below, 45 degrees rotation are used:

const float width = 10.0F;
const float height = 7.0F;
const float angle = 45.0F;

var grid = new GridPositionIterator(width, height, 2.0F, 2.0F, 0.0F, 0.0F, Angle.FromDegrees(angle));

var coordinates = new List<GridCoord>();
while (grid.MoveNext())
{
    coordinates.Add(grid.Current);
}

coordinates.Count.Should().Be(17);
coordinates.Should().ContainInOrder(
    // First row
    new GridCoord(0.7573595F, 2.0857863F),
    new GridCoord(2.1715730F, 0.6715729F),
    // Second row
    new GridCoord(0.7573595F, 4.9142137F),
    new GridCoord(2.1715730F, 3.5000000F),
    new GridCoord(3.5857863F, 2.0857863F),
    new GridCoord(5.0000000F, 0.6715729F),
    // Third row
    new GridCoord(2.1715730F, 6.3284273F),
    new GridCoord(3.5857863F, 4.9142137F),
    new GridCoord(5.0000000F, 3.5000000F),
    new GridCoord(6.4142137F, 2.0857863F),
    new GridCoord(7.8284273F, 0.6715729F),
    // Fourth row
    new GridCoord(5.0000000F, 6.3284273F),
    new GridCoord(6.4142137F, 4.9142137F),
    new GridCoord(9.2426405F, 2.0857863F),
    // Fifth row
    new GridCoord(7.8284273F, 6.3284273F),
    new GridCoord(9.2426405F, 4.9142137F)
);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0 190 7/28/2023