Meziantou.Framework.VectorGraphics
1.0.1
Prefix Reserved
dotnet add package Meziantou.Framework.VectorGraphics --version 1.0.1
NuGet\Install-Package Meziantou.Framework.VectorGraphics -Version 1.0.1
<PackageReference Include="Meziantou.Framework.VectorGraphics" Version="1.0.1" />
<PackageVersion Include="Meziantou.Framework.VectorGraphics" Version="1.0.1" />
<PackageReference Include="Meziantou.Framework.VectorGraphics" />
paket add Meziantou.Framework.VectorGraphics --version 1.0.1
#r "nuget: Meziantou.Framework.VectorGraphics, 1.0.1"
#:package Meziantou.Framework.VectorGraphics@1.0.1
#addin nuget:?package=Meziantou.Framework.VectorGraphics&version=1.0.1
#tool nuget:?package=Meziantou.Framework.VectorGraphics&version=1.0.1
Meziantou.Framework.VectorGraphics
Describes a drawing as a scene of shapes, paths, texts, images and groups, writes it as deterministic SVG, and measures, wraps and truncates texts with the metrics of Helvetica or any OpenType font. Meziantou.Framework.Charts and Meziantou.Framework.Diagrams lay themselves out into a scene; Meziantou.Framework.Imaging.VectorGraphics draws it as an image.
Usage
var scene = new Scene(width: 200, height: 80, fontFamily: AfmTextMeasurer.Default.FontFamily) { Title = "A box", Background = SceneColor.White };
// Shapes are filled and stroked; texts are positioned by their baseline
scene.Root.Add(new SceneRectangle(10, 10, 180, 60) { Fill = (SceneColor)"#e0f2fe", Stroke = (SceneColor)"#0369a1", StrokeWidth = 2, CornerRadius = 8 });
scene.Root.Add(new SceneText(100, 45, "Hello", new SceneFont(16, Weight: SceneFont.BoldWeight), (SceneColor)"#0c4a6e") { Anchor = SceneTextAnchor.Middle });
// Paths use the commands of SVG
var arrow = new PathBuilder().MoveTo(20, 60).LineTo(60, 60).LineTo(55, 55).MoveTo(60, 60).LineTo(55, 65).Build();
scene.Root.Add(new ScenePath(arrow) { Stroke = (SceneColor)"#0369a1" });
var svg = SvgSceneRenderer.Render(scene);
Wrap a text to fit a width:
var measurer = AfmTextMeasurer.Default;
var font = new SceneFont(12);
// At most 100 pixels per line, broken between words, and at the line feeds of the text
var lines = TextFitting.Wrap(measurer, "A label that is too long for its box\nSecond paragraph", font, maxWidth: 100);
Assert.Equal(["A label that is too", "long for its box", "Second paragraph"], lines);
// Or shortened with an ellipsis
Assert.Equal("A label that i…", TextFitting.Truncate(measurer, "A label that is too long", font, maxWidth: 80));
| 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. net11.0 is compatible. |
-
net10.0
- Meziantou.Framework.Fonts (>= 1.0.10)
-
net11.0
- Meziantou.Framework.Fonts (>= 1.0.10)
NuGet packages (5)
Showing the top 5 NuGet packages that depend on Meziantou.Framework.VectorGraphics:
| Package | Downloads |
|---|---|
|
Meziantou.Framework.Avatar
Generate deterministic avatar images from names and bigrams, as SVG or as vector scenes to draw as PNG |
|
|
Meziantou.Framework.Charts
Grammar-of-graphics chart library that renders deterministic SVG: bar, line, area, scatter, pie, radar, gauge, packed circles, treemap, sunburst, histogram, box plot, heatmap, waterfall, funnel, candlestick, choropleth maps and more, built from marks, scales, coordinates and transforms. |
|
|
Meziantou.Framework.Diagrams
Diagrams written as deterministic SVG, inspired by Mermaid: 25 diagram types of Mermaid, from flowcharts, class, sequence, entity relationship, C4 and architecture diagrams to Gantt charts, mind maps, Venn diagrams and Wardley maps, laid out automatically, with the themes of Mermaid. |
|
|
Meziantou.Framework.Imaging.VectorGraphics
Draws the scenes of Meziantou.Framework.VectorGraphics (charts, diagrams) with Meziantou.Framework.Imaging: images in any format (PNG, WebP, JPEG...), or vector drawing on a canvas, with embedded Liberation Sans fonts. |
|
|
Meziantou.Framework.Pdf.VectorGraphics
Draws the scenes of Meziantou.Framework.VectorGraphics (charts, diagrams) as PDF with Meziantou.Framework.Pdf: vector shapes, gradients and text, with subsets of the fonts of the scene embedded. |
GitHub repositories
This package is not used by any popular GitHub repositories.