Imp 0.0.2-alpha
dotnet add package Imp --version 0.0.2-alpha
NuGet\Install-Package Imp -Version 0.0.2-alpha
<PackageReference Include="Imp" Version="0.0.2-alpha" />
<PackageVersion Include="Imp" Version="0.0.2-alpha" />
<PackageReference Include="Imp" />
paket add Imp --version 0.0.2-alpha
#r "nuget: Imp, 0.0.2-alpha"
#addin nuget:?package=Imp&version=0.0.2-alpha&prerelease
#tool nuget:?package=Imp&version=0.0.2-alpha&prerelease
Imp
Imp is a lightweight, sprite-based rendering framework for F#, supporting both OpenGL (desktop) and WebGL (web). Inspired by Elmish and React Native, it provides a declarative way to build high-performance 2D applications with a functional architecture.
๐น Why "Imp"? The name comes from an Imp, a small mischievous creatureโjust similar to a sprite! Imp is designed to be a fast and lightweight sprite renderer for building graphical applications.
๐ Try the demo: davidtme.github.io/imp
Features
- ๐ฎ Sprite-Based Rendering โ Optimized for rendering 2D sprites efficiently.
- ๐ Elmish-Like Architecture โ Write declarative UI code, similar to React Native in F#.
- ๐ฅ Cross-Platform Support โ OpenGL for desktop apps and WebGL for browser-based applications.
- ๐จ Declarative Scene Composition โ Manage scenes and sprites with a structured, functional approach.
- ๐ GPU-Accelerated Performance โ Leverages OpenGL/WebGL for smooth, high-performance rendering.
- ๐ฆ Web-Based & Local Asset Management โ Load and manage textures, sprites, and other resources effortlessly.
- ๐ก F#-First Development โ Functional, type-safe, and expressive API.
- ๐ Fable Integration โ Uses Fable to compile F# to JavaScript for seamless web development.
Example Usage
With Imp, you can quickly set up a WebGL scene:
module Client.SimpleWeb.App
// Import required modules for application setup and rendering
open Imp
open Imp.Setup
// Define the name of the texture to be used in the application
let texture = "f-sharp-logo"
// Initialize a data manager for handling web-based data operations
let dataManager = WebDataManager(baseUrl = ".")
// Register the texture name with the data manager
dataManager.AddTextureName(texture)
// Define a function to create the main view of the application
let sampleView () =
// The view function serves as the root container for the scene
view () {
// The sceneRenderer sets up the rendering environment, including the background color
sceneRenderer (backgroundColor = { R = 29; G = 41; B = 61 }) {
// The singleRenderer renders individual sprites one at a time
singleRenderer () {
// Define a sprite with its position, dimensions, and texture properties
sprite (
x = 50, // Horizontal position of the sprite
y = 50, // Vertical position of the sprite
z = 0, // Depth position of the sprite
width = 255, // Width of the sprite in pixels
height = 255, // Height of the sprite in pixels
texture = texture, // Name of the texture to apply to the sprite
textureX = 0, // X-coordinate of the texture region to use
textureY = 0, // Y-coordinate of the texture region to use
textureWidth = 255, // Width of the texture region to use
textureHeight = 255 // Height of the texture region to use
)
}
}
}
// Create a WebGL display for rendering the application
let display = WebGLDisplay(elementId = "App", width = 800, height = 600) // Specify the HTML element and display dimensions
// Attach the data manager, the root view, and an optional per-frame callback to the display
display.AttachView dataManager (sampleView ()) None
// Start the rendering loop for the display
display.Run()
Getting Started
Clone the repository and explore the sample applications to see Imp in action!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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. |
-
net9.0
- Fable.Browser.Dom (>= 2.18.1)
- Fable.Browser.WebGL (>= 1.3.0)
- Fable.Core (>= 4.4.0)
- Fable.Fetch (>= 2.7.0)
- Fable.Promise (>= 3.2.0)
- FSharp.Core (>= 9.0.201)
- Silk.NET.Input (>= 2.22.0)
- Silk.NET.OpenGL (>= 2.22.0)
- Silk.NET.Windowing (>= 2.22.0)
- StbImageSharp (>= 2.30.15)
- System.Text.Json (>= 9.0.2)
- Thoth.Json (>= 10.4.1)
- Thoth.Json.Net (>= 12.0.0)
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.0.2-alpha | 369 | 17 days ago |