Popularity
5.8
Declining
Activity
0.0
-
700
48
133

Code Quality Rank: L3
Programming language: C#
License: MIT License
Tags: iOS     Android     Pcl     Mac     Graphics     Vector     Drawing     Xamarin     Imaging     Draw     Image     Svg     Png     Render    
Latest version: v0.5.0

NGraphics alternatives and similar packages

Based on the "Graphics" category.
Alternatively, view NGraphics alternatives based on common mentions on social networks and blogs.

  • Live-Charts

    Simple, flexible, interactive & powerful charts, maps, and gauges for .Net, LiveCharts2 can now practically run everywhere WPF, WinForms, Xamarin, Avalonia, WinUI, UWP.
  • ScottPlot

    Interactive plotting library for .NET
  • The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
    Promo workos.com
    WorkOS Logo
  • Oxyplot

    A cross-platform plotting library for .NET
  • LiveCharts2

    Simple, flexible, interactive & powerful charts, maps and gauges for .Net, LiveCharts2 can now practically run everywhere Maui, Uno Platform, Blazor-wasm, WPF, WinForms, Xamarin, Avalonia, WinUI, UWP.
  • OpenTK

    The Open Toolkit library is a fast, low-level C# wrapper for OpenGL, OpenAL & OpenCL. It also includes windowing, mouse, keyboard and joystick input and a robust and fast math library, giving you everything you need to write your own renderer or game engine. OpenTK can be used standalone or inside a GUI on Windows, Linux, Mac.
  • Silk.NET

    The high-speed OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, WebGPU, and DirectX bindings library your mother warned you about.
  • Helix Toolkit

    Helix Toolkit is a collection of 3D components for .NET.
  • Veldrid

    A low-level, portable graphics library for .NET.
  • Win2D

    Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration. It is available to C#, C++ and VB developers writing apps for the Windows Universal Platform (UWP). It utilizes the power of Direct2D, and integrates seamlessly with XAML and CoreWindow.
  • LibVLCSharp

    Cross-platform .NET/Mono bindings for LibVLC
  • Interactive Data Display for WPF

    Interactive Data Display for WPF is a set of controls for adding interactive visualization of dynamic data to your application. It allows to create line graphs, bubble charts, heat maps and other complex 2D plots which are very common in scientific software. Interactive Data Display for WPF integrates well with Bing Maps control to show data on a geographic map in latitude/longitude coordinates. The controls can also be operated programmatically.
  • LibTessDotNet

    C# port of the famous GLU Tessellator - prebuilt binaries now available in "releases" tab
  • SciChart

    Highest rated & Fastest WPF Charts, used by F1, NASA and more
  • RealTimeGraphX

    High performance real-time graph for WPF & UWP
  • VectSharp

    A light library for C# vector graphics
  • Aspose.Drawing

    Aspose.Drawing for .NET Examples
  • AssimpNet

    A cross-platform .NET Standard wrapper for the Open Asset Importer ("Assimp"). The library enables importing, processing, and exporting of 3D models for rendering in graphics/game applications. Over 40 formats are supported for importing (e.g. OBJ, FBX, GLTF, 3DS, Collada) and a subset of those formats can be exported to (e.g. OBJ, GLTF, 3DS, Collada). Mesh processing features allow for mesh data to be generated or optimized for real-time rendering.

Do you think we are missing an alternative of NGraphics or a related project?

Add another 'Graphics' Package

README

NGraphics

NuGet Package Build

NGraphics is a cross platform library for rendering vector graphics on .NET. It provides a unified API for both immediate and retained mode graphics using high quality native renderers.

You can use it for cross platform rendering of UI widgets. Or as the basis for graphically rich interactive views. Or maybe you just want an easy way to import and export SVG and PNG files. Either way, I'm sure you'll find something interesting here.

Installation

Install NGraphics from nuget.

Getting Started

The most important class is ICanvas. Uses canvases to render vector graphics (rectangles, ellipses, paths) to "something". Sometimes canvases are views on the screen, sometimes they are images -- you never really know.

We can draw a little house easily enough:

var canvas = Platforms.Current.CreateImageCanvas (new Size (100), scale: 2);

var skyBrush = new LinearGradientBrush (Point.Zero, Point.OneY, Colors.Blue, Colors.White);
canvas.FillRectangle (new Rect (canvas.Size), skyBrush);
canvas.FillEllipse (10, 10, 30, 30, Colors.Yellow);
canvas.FillRectangle (50, 60, 60, 40, Colors.LightGray);
canvas.FillPath (new PathOp[] { 
    new MoveTo (40, 60),
    new LineTo (120, 60),
    new LineTo (80, 30),
    new ClosePath ()
}, Colors.Gray);

canvas.GetImage ().SaveAsPng (GetPath ("Example1.png"));

Platforms.Current.CreateImageCanvas is just our tricky way to get a platform-specific ICanvas that we can rendered on. IImageCanvases are special because you can call GetImage to get an image of the drawing when you are done. We use a scale of 2 to render retina graphics and keep this README looking good.

Paths are drawn using standard turtle graphics.

Pens and Brushes

When drawing, you have a choice of pens to stroke the object with or brushes to fill it with.

Anyway.

Pens can be any color and any width.

var canvas = Platforms.Current.CreateImageCanvas (new Size (120*5, 120), scale: 2);

canvas.Translate (20, 20);
for (var i = 0; i < 5; i++) {
    canvas.DrawEllipse (
        new Rect (new Size (80)),
        pen: Pens.DarkGray.WithWidth (1 << i),
        brush: Brushes.LightGray);
    canvas.Translate (120, 0);
}

canvas.GetImage ().SaveAsPng (GetPath ("PenWidths.png"));

Brushes can be solid colors or trippy multi-color gradients (linear and radial!)

There is no multi-layering within elements, so you will have to draw them a few times with different brushes to get complex effects.

Colors

What would a graphics library be without a Color class? Well, this one is a struct. Colors are light-weight, have fun with them.

Normally you will use the RGBA constructor of color: new Color (r, g, b, a) where each value can range from 0 to 1.

If you're not normal, you might prefer the web notation: Color.FromRGB (0xBEEFEE).

Retained Mode

Sometimes it's nice to hang onto the graphical elements themselves so that you can change them later, or perhaps cache them from an expensive-to-compute draw operation, or maybe you just want to sing to them. Whatever your needs, NGraphics exposes the following graphical elements:

  • Rectangles are best used for drawing rectangles.
  • Ellipses can also be used to draw ovals and circles.
  • Paths can draw anything that you can imagine, and more. Lines, curves, turtles, they're all for the taking.
var circle = new Ellipse (new Rectangle (Point.Zero, new Size (10)));

ICanvas canvas = ...;
circle.Draw (canvas);

Platforms

  • Android (Xamarin) using Android.Graphics
    • CanvasCanvas wraps a Android.Graphics.Canvas
  • iOS (Xamarin) using CoreGraphics
    • CGContextCanvas wraps a CoreGraphics.CGContext
  • Mac (Xamarin) using CoreGraphics
    • CGContextCanvas wraps a CoreGraphics.CGContext
  • .NET 4.5 using System.Drawing
    • GraphicsCanvas wraps a System.Drawing.Graphics
  • Windows Store 8.1 using Direct2D
    • RenderTargetCanvas wraps a SharpDX.Direct2D1.RenderTarget
  • Windows Phone 8.1 using Direct2D
    • RenderTargetCanvas wraps a SharpDX.Direct2D1.RenderTarget
  • Universal Windows Platform (UWP) using Direct2D
    • RenderTargetCanvas wraps a SharpDX.Direct2D1.RenderTarget

Editor

To speed up the process of drawing with code, NGraphics ships with a code editor and live preview for OS X. Download the editor from the Releases page.

Any C# file that can be independently compiled can be used. The advantage of this editor over Xamarin Studio is that you can work on your drawings without having to wait for your whole project to compile and run.

Simply compile and run the project NGraphics.Editor or download the editor to get started.

Examples

For more examples, check out the images in the TestResults directory and the test code that generated them.

Icon

The NGraphics icon can be rendered using a simple repeating path:

var size = new Size (64);
var canvas = Platforms.Current.CreateImageCanvas (size, scale: 2);
canvas.SaveState ();
canvas.Scale (size);
canvas.Translate (1 / 8.0, 0);

var p = new Path ();
p.MoveTo (0, 1);
p.LineTo (0, 0);
p.LineTo (0.5, 1);
p.LineTo (0.5, 0);

var colors = new [] {
    "#DCDCDD",
    "#C5C3C6",
    "#46494C",
    "#4C5C68",
    "#68A5E2",
};
foreach (var c in colors) {
    p.Pen = new Pen (c, 1 / 4.0);
    p.Draw (canvas);
    canvas.Translate (1 / 16.0, 0);
}

canvas.GetImage ().SaveAsPng (GetPath ("Icon.png"));

Cats

NGraphics also supports scaling cats:

var img = GetResourceImage ("cat.png");
var canvas = Platform.CreateImageCanvas (new Size (100, 200), transparency: true);
canvas.DrawImage (img, new Rect (new Size (50)));
canvas.DrawImage (img, new Rect (new Point (50, 0), new Size (50)));
canvas.DrawImage (img, new Rect (new Point (0, 50), new Size (50, 150)));
canvas.DrawImage (img, new Rect (new Point (50, 50), new Size (50, 150)));
canvas.GetImage ().SaveAsPng (GetPath ("ImageCanvas.Cats"));

License

The MIT License (MIT)

See [LICENSE](LICENSE) for details.


*Note that all licence references and agreements mentioned in the NGraphics README section above are relevant to that project's source code only.