This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Particle.Maui is a cross-platform .NET MAUI library for displaying particle effects (confetti, etc.). Originally created as Particle.Forms (Xamarin) by Marius Muntean, ported to MAUI by Jeff Bowman (Particle.Maui), and now maintained at mos379/Particles.Maui for .NET 9/.NET 10. Distributed as the NuGet package particles.maui.
There are no build scripts — use standard .NET CLI or open the solution in Visual Studio.
# Build the library (also generates the NuGet package automatically)
dotnet build Src/Particle.Maui/Particle.Maui.csproj
# Build in Release (generates .nupkg in bin/Release/)
dotnet build Src/Particle.Maui/Particle.Maui.csproj -c Release
# Run the sample app (requires a target platform)
# Open Sample/Particle.Maui.Sample/Particle.Maui.Sample.sln in Visual Studio
# and select a target device/platformThere are no test projects. The sample app in Sample/ serves as the integration test.
ParticleView (Src/Particle.Maui/ParticleView.cs) is the central class — a MAUI ContentView that hosts an SKCanvasView (SkiaSharp) and drives a 16ms animation loop (~60 FPS). It:
- Manages the particle collection (thread-safe with
_particleLock) - Calls
IParticleGeneratorimplementations to spawn particles - Delegates to
RateBasedParticleRequesterfor smooth rate-controlled spawning - Handles touch input (tap and drag) to trigger particle bursts
The library is designed to be extended at two seams:
-
Custom Particles — Extend
ParticleBaseand implementDraw(SKCanvas canvas). The base class handles position, velocity, rotation, opacity, and size lifecycle; subclasses only need to render their shape. SeeRectParticle,EllipseParticle, and theDemo2/logo particles for examples. -
Custom Generators — Implement
IParticleGeneratorto control what particles are created and with what properties. Assign toParticleView.TouchParticleGeneratororParticleView.FallingParticleGenerator. Built-in generators:SimpleParticleGenerator(360° radiate),FallingParticleGenerator(downward 45–135°),RandomParticleGenerator(wraps another generator with random color/type selection).
Defined in ParticleViewProperties.cs — all are bindable and XAML-compatible:
| Property | Default | Purpose |
|---|---|---|
IsActive |
true |
Shows/hides the particle view |
IsRunning |
true |
Pauses/resumes the animation loop |
HasFallingParticles |
false |
Enables continuous falling particles |
FallingParticlesPerSecond |
60 |
Rate of falling particles |
AddParticlesOnTap |
false |
Burst on tap |
TapParticleCount |
30 |
Particles per tap |
AddParticlesOnDrag |
false |
Emit while dragging |
DragParticleCount |
60 |
Particles per drag event |
DragParticleMoveType |
Fall |
Fall or Radiate |
UseSKGLView |
false (true on Android) |
Use GPU-accelerated GL view |
ShowDebugInfo |
false |
Overlay FPS/particle count |
Non-bindable: TouchParticleGenerator, FallingParticleGenerator, CanvasSize.
Multi-targets .NET 9 and .NET 10:
net9.0-android,net10.0-androidnet9.0-ios,net10.0-ios(14.2+)net9.0-maccatalyst,net10.0-maccatalyst(14.0+)net9.0-windows10.0.19041.0,net10.0-windows10.0.19041.0(Windows 10+)
Microsoft.Maui.Controls is conditionally referenced: v9.0.100 for net9.0, v10.0.20 for net10.0.
Microsoft.Maui.Controlsv10.0.20SkiaSharp.Views.Maui.Controlsv3.119.2SkiaSharp.Views.Maui.Corev3.119.2
Building the library project automatically generates the .nupkg (GeneratePackageOnBuild=true). Current version: 2.0.0. Package ID: Particles.Maui.
- Call
IsRunning = falsewhen a page is not visible, andtruewhen it reappears — this stops the animation loop. - Rotation matrices are cached in
ParticleBaseto reduce per-frame allocation. SKGLView(UseSKGLView=true) provides better GPU performance, especially on Android.