Mtf.Drawing
1.0.9
dotnet add package Mtf.Drawing --version 1.0.9
NuGet\Install-Package Mtf.Drawing -Version 1.0.9
<PackageReference Include="Mtf.Drawing" Version="1.0.9" />
<PackageVersion Include="Mtf.Drawing" Version="1.0.9" />
<PackageReference Include="Mtf.Drawing" />
paket add Mtf.Drawing --version 1.0.9
#r "nuget: Mtf.Drawing, 1.0.9"
#:package Mtf.Drawing@1.0.9
#addin nuget:?package=Mtf.Drawing&version=1.0.9
#tool nuget:?package=Mtf.Drawing&version=1.0.9
Mtf.Drawing
Mtf.Drawing is a modern, C#-based 2D geometry and rendering library designed to simplify the mathematical manipulation and GDI+ rendering of shapes.
The project strictly separates the geometric definition of shapes (data and logic) from their physical display (rendering), ensuring the code remains clean, testable, and highly maintainable.
📦 Key Features
- Geometric Shapes (Math/Geometry):
CircleF,LineF,RectF,OrientedRectF,PolylineF,TextLayout. - Spatial Transformations: Support for moving (
Move), scaling (Resize), and rotating (Rotate) via theIShapeinterface. - Collision Detection: Built-in
ContainsandIntersectsmethods for shapes. - GDI+ Rendering: Dedicated
Primitiveclasses (CirclePrimitive,RectanglePrimitive,LinePrimitive, etc.) handle drawing graphics onto aGraphicscanvas. - Screen Sampling: A specialized
InverseRectanglePrimitivefor color inversion utilizing the Win32 API.
🏗️ Architecture
The library is structured into three main namespaces:
1. Mtf.Drawing.Interfaces
Contains the foundational interfaces that provide the building blocks of the system:
IShape: The core definition of geometric shapes (requiring a center point, move, rotate, resize, and containment checks).IPrimitive: The base for all renderable objects, enforcing the implementation ofDrawOnGraphics(Graphics g, Color color).
2. Mtf.Drawing.Geometry
A collection of immutable (or functionally modifiable) readonly record struct and class types. These classes contain no drawing logic, only pure mathematics.
- They utilize the
GeometryMathstatic helper class for complex calculations (e.g., rotating points).
3. Mtf.Drawing.Render
These classes (e.g., CirclePrimitive, TextPrimitive) bridge the gap between in-memory geometry and visual output, binding the data to the System.Drawing.Graphics object.
🚀 Usage Example
Creating and Transforming Geometry
using Mtf.Drawing.Geometry;
using System.Drawing;
// Create a circle
var circle = new CircleF(new PointF(10, 10), 5);
// Move and scale the shape
var movedCircle = circle.Move(15, 20);
var scaledCircle = movedCircle.Resize(2.0f);
// Collision detection
bool isHit = scaledCircle.Contains(new PointF(25, 30));
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- System.Drawing.Common (>= 10.0.8)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Mtf.Drawing:
| Package | Downloads |
|---|---|
|
Mtf.Games
Lightweight C# arcade game framework with classic 2D games and extensible rendering abstractions. |
|
|
Mtf.Maui.Drawing
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.