MonoPrimitives 0.9.1
dotnet add package MonoPrimitives --version 0.9.1
NuGet\Install-Package MonoPrimitives -Version 0.9.1
<PackageReference Include="MonoPrimitives" Version="0.9.1" />
<PackageVersion Include="MonoPrimitives" Version="0.9.1" />
<PackageReference Include="MonoPrimitives" />
paket add MonoPrimitives --version 0.9.1
#r "nuget: MonoPrimitives, 0.9.1"
#:package MonoPrimitives@0.9.1
#addin nuget:?package=MonoPrimitives&version=0.9.1
#tool nuget:?package=MonoPrimitives&version=0.9.1
MonoPrimitives
Immediate-mode 2D and 3D primitive drawing for MonoGame, plus the small set of helpers a fast prototype usually needs — camera, input, easing, color, noise, and collision/raycast tests — so you don't have to pull in a handful of separate external libraries for those.
Built for prototypes: simulations (boids, cellular automata, predator-prey, pandemic models, terrain), generative art, and small retro-style game demos. Not a game engine, and not aimed at shipping a full commercial game.
Install
dotnet add package MonoPrimitives
Or scaffold a whole starter project (Camera2D, letterboxed 1080p virtual resolution, MSAA, input, a RenderContext bundle) with the dotnet new template — not yet published as its own package, so install it from a clone of this repo for now:
dotnet new install ./templates/PrimitiveBase
dotnet new primitivebase -n YourGame
One NuGet package, one assembly, one DLL — 2D and 3D both come with it, no separate sub-packages to resolve. Internally it's still organized into three namespaces so nothing is duplicated between them:
| Namespace | Source folder | What's there |
|---|---|---|
MonoPrimitives |
src/Core/ |
Shared: PrimitiveInput, Easing, Palette/ColorUtil, Noise, RandomUtil, FontGlyphs5x7, Vector2Extensions, RectangleF, FrameLimiter, FastTexture, FpsCounter, ScreenshotUtil, ObjectPool<T>, RingBuffer<T>, Cooldown |
MonoPrimitives.Primitives2D |
src/2D/ |
Primitive2DBatch, Camera2D + ViewportAdapter2D, Collision2D, Trail2D, UnitCircleLut |
MonoPrimitives.Primitives3D |
src/3D/ |
Primitive3DBatch, Camera3D, Collision3D, Trail3D, TrigLut, Vector3Extensions |
Quick start
using MonoPrimitives.Primitives2D;
private Primitive2DBatch _batch;
protected override void LoadContent()
{
_batch = new Primitive2DBatch(GraphicsDevice);
}
protected override void Draw(GameTime gameTime)
{
_batch.Begin();
_batch.FillCircle(new Vector2(400, 300), 50, Color.Red);
_batch.DrawRectangle(100, 100, 200, 80, Color.White, Color.Black, thickness: 4);
_batch.End();
base.Draw(gameTime);
}
using MonoPrimitives.Primitives3D;
private Primitive3DBatch _batch;
private Camera3D _camera;
protected override void LoadContent()
{
_batch = new Primitive3DBatch(GraphicsDevice);
_camera = new Camera3D(
position: new Vector3(6, 6, 6),
target: Vector3.Zero,
up: Vector3.Up,
fovy: 50f
);
}
protected override void Draw(GameTime gameTime)
{
_batch.Begin(_camera);
_batch.FillSphere(Vector3.Zero, 1f, Color.Red);
_batch.End();
base.Draw(gameTime);
}
Every shape follows the same Fill<Shape> (solid) / Border<Shape> (outline, grows inward) / Draw<Shape> (both) pattern, in both 2D and 3D.
Documentation
Each class has its own guide — start with whichever one covers what you're touching, or see Guide/README.md for a "brand new here" reading order:
Drawing
Primitive2DBatch— every 2D shape (rectangles, circles, ellipses, capsules, polygons, sectors/rings, splines), gradients, shadows, rounded/chamfered corners.Primitive3DBatch— every 3D shape (cubes, spheres, cylinders, capsules, torus, planes, heightmaps), flat-shading lighting, splines.DebugFont5x7— a built-in bitmap debug font, 2D and 3D (billboarded).
Camera & viewport
Camera2D & Viewport— pan/rotate/zoom, bounds, follow, shake, and theViewportAdapter2Dfamily (letterboxing/scaling for resolution independence).Camera3D— the 3D counterpart: 5 behaviour modes, free-fly/orbit/first-/third-person controllers.
Input
PrimitiveInput— keyboard/mouse/gamepad polling, vibration, typed text, and rawKeyboardState/MouseState/GamePadStateaccess for anything not wrapped.
Collision
Collision2D— every 2D overlap/ray check by shape.PolygonUtil—IsConvex(does my polygon qualify for SAT?) andTriangulate(ear clipping, for your own mesh/collision/nav data).Collision3D— sphere/box/capsule/plane/triangle/quad overlap and raycasts.
Math & utilities
MathUtil—Remap/DeltaAngle/LerpAngle/PingPong, the scalar helpersMathHelperdoesn't have.Easing— 31 tweening curves for one-shot animations with a known duration.Noise— seedable Perlin noise, fBm, ridge, and turbulence.RandomUtil— seedable distribution sampling (Gaussian, Poisson, Binomial, uniform disc/sphere, weighted picks).Color— a curated color palette plus hex/HSV conversion and adjustment.Trail— a fading position-history trail, 2D and 3D.UnitCircleLut/TrigLut— the trig-free lookup tables the shape batches are themselves built on, for your own curved geometry.VectorExtensions— angle/rotation/approach/clamp helpers on MonoGame's ownVector2, plusVector3Extensions(3D) in the same guide.RectangleF— a float-precision counterpart to MonoGame's integer-onlyRectangle.RingBuffer— a generic fixed-capacity ring buffer for your own history/log/sample-window need.ObjectPool— a generic object pool for anything spawned/discarded often enough to want reuse over reallocation.
App helpers
FrameLimiter— sleep+spin frame pacing, more precise thanIsFixedTimeStepalone.FastTexture— raw-GL texture upload, 2.5-2.7x faster thanSetDatafor frequent updates.FpsCounter— rolling-average FPS measurement.ScreenshotUtil— one-call back-buffer capture to.png/.jpg.TextureUtil— procedural texture generation (solid/gradient/checkerboard/fromNoise) plus resize/crop/flip/tint/combine transforms.Cooldown— a simple countdown struct for attack cooldowns, spawn timers, input debouncing.WindowUtil— minimize/maximize/restore, opacity, window icon, multi-monitor info, clipboard text, and captured-cursor mouse-look.
For the project's own internals (architecture map, conventions, the reasoning behind non-obvious choices), see Design/README.md.
Examples
samples/MonoPrimitives.Sample— a visual-regression gallery of every 2D and 3D shape, camera-controlled.examples/test/— one focused demo per non-drawing component: collision, input, viewport adapters, noise, particle trails, text.examples/demos/— small complete games built on the library (Breakout, Tetris, Asteroids in 2D and 3D, a platformer, Snake, a boids simulation).
What this isn't
- No physics resolution — collision checks detect overlaps, they never resolve them.
- No texture/model loading, no window management — that's MonoGame's own
Game/content pipeline. - No scene graph — every draw call is immediate; nothing is retained between frames.
Inspiration
This library borrows ideas from several places rather than inventing its own conventions from scratch:
- Apos.Shapes —
Fill/Border/Drawper shape, the core naming convention the whole drawing API is built on, comes from here: Apos.Shapes uses that exact three-verb split (FillCircle/BorderCircle/DrawCircle, and so on for every shape it has). - raylib — the other biggest influence, drawn on more than the rest:
Camera3D's movement/rotation math is a direct port ofrcamera.h, andCollision3D'sGetRayCollision*naming and result struct follow raylib's own collision module. - raylib-cs — its C# bindings keep raylib's own function names as-is (
DrawCircleV,DrawRectangleV) but swap raylib's custom math types for .NET's ownSystem.Numerics.Vector2/Vector3— the same instinct behind this library using MonoGame's ownVector2/Vector3/Colorrather than defining its own. - MonoGame.Extended —
Camera2D/ViewportAdapter2D's design (letterbox/scaling viewport adapters composed with a camera) follows itsOrthographicCamera/ViewportAdaptershape. - Godot — several individual methods are confirmed against Godot's own equivalents where raylib has no answer:
PrimitiveInput.GetAxis's tie-to-zero behavior matchesInput.get_axis,DebugFont5x7's cylindrical text billboarding matchesLabel3D's default billboard mode,RandomUtil.NextWeightedIndexmatchesRandomNumberGenerator.rand_weighted_pick. - libGDX —
PolygonUtil.Triangulatematches itsEarClippingTriangulator, andCoverViewportAdapter2Dfills the same gap as itsScaling.fillmode (uniform scale, crop the overflow, never show bars) — a real third viewport-fit option neither raylib nor MonoGame.Extended's own adapters covered. - Processing / p5.js — the underlying philosophy: draw a shape with one call, no setup ceremony, fast enough to iterate on an idea in a sketch rather than a project.
Noise's API shape (seedable, sample-anywhere) is the same idea as Processing's ownnoise().
None of the above are dependencies — MonoPrimitives only depends on MonoGame itself. They're referenced here as the design lineage, not as libraries this one wraps or requires.
Status
Published on NuGet, pre-1.0 — the API can still change between minor versions as gaps get closed. See Design/ROADMAP.md for known gaps and deliberate deferrals, and CHANGELOG.md for what changed in each version.
License
MIT — see LICENSE.
| 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. |
-
net8.0
- MonoGame.Framework.DesktopGL (>= 3.8.5.1)
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 |
|---|---|---|
| 0.9.1 | 111 | 9/5/2026 |
| 0.9.0 | 86 | 9/1/2026 |
| 0.8.5 | 118 | 8/27/2026 |
| 0.8.4 | 113 | 8/27/2026 |
| 0.8.3 | 126 | 8/25/2026 |
| 0.8.2 | 103 | 8/25/2026 |
| 0.8.0 | 103 | 8/25/2026 |
| 0.7.5 | 103 | 8/24/2026 |
| 0.7.0 | 104 | 8/24/2026 |
| 0.6.0 | 112 | 8/24/2026 |
| 0.5.7 | 92 | 8/24/2026 |
| 0.5.6 | 100 | 8/24/2026 |
| 0.5.5 | 96 | 8/24/2026 |
| 0.5.0 | 107 | 8/24/2026 |
| 0.4.0 | 107 | 8/24/2026 |
| 0.3.0 | 113 | 8/22/2026 |
| 0.2.5 | 104 | 8/21/2026 |
| 0.2.0 | 94 | 8/21/2026 |
| 0.1.0 | 109 | 8/21/2026 |