P5Sharp 1.0.8

dotnet add package P5Sharp --version 1.0.8
                    
NuGet\Install-Package P5Sharp -Version 1.0.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="P5Sharp" Version="1.0.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="P5Sharp" Version="1.0.8" />
                    
Directory.Packages.props
<PackageReference Include="P5Sharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add P5Sharp --version 1.0.8
                    
#r "nuget: P5Sharp, 1.0.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package P5Sharp@1.0.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=P5Sharp&version=1.0.8
                    
Install as a Cake Addin
#tool nuget:?package=P5Sharp&version=1.0.8
                    
Install as a Cake Tool

P5Sharp Logo

P5Sharp is a creative coding library for .NET and .NET MAUI, inspired by the popular p5.js framework.
It brings the intuitive and expressive style of p5.js to the C# world — powered by SkiaSharp for rendering and built-in HOT RELOAD for Android, iOS, and Windows.
Enjoy a smooth, real-time development experience.

🌐 GitHub: https://github.com/Akos-Kovacs-Dev/P5Sharp
📺 YouTube: https://www.youtube.com/@P5Sharp
🧩 P5Sharp Sync Extension (Hot Reload for iOS/Android):
https://marketplace.visualstudio.com/items?itemName=AkosKovacs.P5SharpSync


📽 Demo Videos

Demo 1
Demo 2


🚀 Setup Guide

Requirements:

  • Visual Studio with .NET MAUI workload installed
  • .NET 8 SDK

Installation:

  1. Install the NuGet package: P5Sharp
  2. (Optional for mobile hot reload) Install the P5SharpSync extension from the Visual Studio Marketplace

🛠 Configure MauiProgram.cs

using P5Sharp;

builder.UseP5Sharp(new P5SharpConfig
{
    IP = "xxx.xxx.x.x",     // Get from the P5SharpSync extension (or localhost)
    Port = 1234             // Get from the extension or set manually
});

Note: Make sure the P5SharpSync server is running before launching your app (unless using local TCP mode).


💻 Local TCP Server (Windows Only)

For a faster development experience on Windows, you can skip the Visual Studio extension and use a local TCP server:

builder.UseP5Sharp(new P5SharpConfig
{
    LocalTPCServer = true,    
    IP = "xxx.xxx.x.x", //your ip
    Port = 1234                                // Use any available port
});

⚠️ Only available for Windows.
🚫 Do NOT run P5SharpSync at the same time when using LocalTPCServer.


✏️ Creating a Sketch

In Visual Studio:

  • Right-click your project
  • Select Add → New File → P5Sketch

This generates a new class that inherits from SketchBase.
This is your sketch entry point, like setup() and draw() in p5.js.


✏️ Creating a P5Object

In Visual Studio:

  • Right-click your project
  • Select Add → New File → P5Object

This generates a new class that inherits from P5Object.

P5Objects are reusable, modular components that can encapsulate their own logic (similar to objects in p5.js). You can define Setup, Draw, OnTouch, and other overrides in each P5Object.


🧠 Using P5Objects in your Sketch

In your main sketch class (which inherits from SketchBase), you can include and draw your P5Object like this:

public class YourSketch : SketchBase
{
    MyP5Object obj;

    public override void Setup()
    {
        obj = new MyP5Object();
        obj.Setup();
    }

    public override void Draw()
    {
        obj.OnDraw(this); // Pass the SketchBase context (which has canvas, width, height, etc.)
    }
}

🔄 The OnDraw(this) call ensures your P5Object gets full access to the current canvas context and sketch environment.

You can organize your sketch into multiple files and import them in your P5SketchView using either FilesCsv or P5Objects.


🧩 Splitting Code with P5Objects

You can break up your sketch into multiple files and classes.
For example:

Update your XAML like this:

<p5:P5SketchView
    P5Objects="/Animations/MySketch/MyP5Object.cs"
    FrameRate="60"
    Sketch="{sketch:MySketch}" /> <!-- main Sketch> 

P5Sharp will automatically resolve these classes to their file paths using reflection.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.8 103 7/19/2025
1.0.7 168 7/17/2025
1.0.6 163 7/15/2025
1.0.5 130 7/13/2025
1.0.3 107 7/11/2025
1.0.2 108 7/11/2025
1.0.1 162 7/6/2025

Comments added.