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" />
<PackageReference Include="SharpCutSvg" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=SharpCutSvg&version=1.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 edgesSharpCut
โ 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 | Versions 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.