SharpCutSvg 1.2.0

dotnet add package SharpCutSvg --version 1.2.0
                    
NuGet\Install-Package SharpCutSvg -Version 1.2.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="SharpCutSvg" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharpCutSvg" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="SharpCutSvg" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SharpCutSvg --version 1.2.0
                    
#r "nuget: SharpCutSvg, 1.2.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.
#addin nuget:?package=SharpCutSvg&version=1.2.0
                    
Install SharpCutSvg as a Cake Addin
#tool nuget:?package=SharpCutSvg&version=1.2.0
                    
Install SharpCutSvg as a Cake Tool

SharpCut

SharpCut is a modern, precise C# library for generating and manipulating 2D vector shapes for laser cutting, CNC, and more. It supports compound shapes, edge merging, geometric utilities, and clean SVG export.

๐Ÿ“ฆ Available on NuGet


โœจ Features

  • Define axis-aligned rectangles and custom shapes
  • Compose compound shapes with automatic edge overlap removal
  • Build clean, deduplicated closed paths
  • Export compact SVG output with one path per shape
  • Control stroke width, color, units
  • Automatically size SVG documents to fit content
  • Fully typed with nullable reference types enabled
  • No dependencies โ€“ works cross-platform with .NET 8+

๐Ÿ“ฆ Example Usage

Basic Shape to SVG

using SharpCut;
using SharpCut.Models;

// Define a simple rectangle
Rectangle rectangle = new Rectangle(0, 0, 100, 50);

// Create document, add the shape, resize and export
SvgDocument svg = new SvgDocument();
svg.Add(rectangle, copy: true);
svg.ResizeToFitContent(margin: 5, offsetContent: true);

string content = svg.Export();

Compound Shape with Finger Joints

using SharpCut;
using SharpCut.Models;
using SharpCut.Builders;

// Base panel
Rectangle panelBase = new Rectangle(x: 5, y: 5, width: 160, height: 50);

// Small vertical finger joint shape
Rectangle cut = new Rectangle(width: 3, height: 25);

// Distribute tabs evenly along the bottom of the base panel
List<Rectangle> placedCuts = cut.PlaceCopiesOnPoints(
    points: panelBase.GetEdge(Side.Bottom).GetDistributedPoints(2),
    origin: Origin.BottomCenter
);

// Build compound shape and clean overlapping edges
CompoundShape compoundShape = new CompoundShape(panelBase, placedCuts);

// Export to SVG
SvgDocument svg = new SvgDocument(strokeWidth: 0.1f, unit: "mm");
svg.Add(compoundShape, copy: true);
svg.ResizeToFitContent(margin: 5, offsetContent: true);

string exportedSvg = svg.Export();

๐Ÿงฑ Structure

  • SharpCut.Models โ€“ geometry: Point, Edge, Rectangle, Shape, CompoundShape, Origin, Side
  • SharpCut.Builders โ€“ logic: ShapeBuilder for deduplicating edges
  • SharpCut โ€“ output: SvgDocument for exporting shapes as SVG

๐Ÿงช Testing

SharpCut uses MSTest with comprehensive coverage:

  • EdgeTests
  • PointTests
  • RectangleTests
  • ShapeTests
  • ShapeBuilderTests
  • SvgDocumentTests

Run tests via:

dotnet test

๐Ÿ›  Requirements

  • .NET 8
  • No external dependencies

๐Ÿ“„ License

MIT License (You can do whatever you want with the code, please feel free to contribute if you have any improvement suggestions)

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.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
1.2.0 153 4/20/2025
1.1.0 84 4/19/2025
1.0.0 96 4/19/2025