nannou Creative Coding Toolkit

repository·master·Indexed 27 days ago

https://github.com/nannou-org/nannou

An open-source creative-coding toolkit for Rust built on the Bevy game engine. nannou provides a suite of specialized crates for graphics (nannou_draw, nannou_wgpu), audio (nannou_audio), MIDI (nannou_midi), OSC (nannou_osc), video (nannou_video), webcam capture (nannou_webcam), and laser projection (nannou_laser). It includes nannou_core for headless or embedded applications and nannou_isf for Interactive Shader Format support.

Tokens
31.3K
Snippets
63
Records
267
Agent score
92%

What's inside nannou

  1. Overview of nannou_laser

    master
    nannou_laser is a cross-platform API designed for laser DAC (Digital-to-Analog Converter) detection and data streaming. It provides a unified interface to interact with various laser protocols, allowing developers to stream 2D vector images or raw data streams to laser hardware.
  2. Overview of nannou_webcam

    master

    nannou_webcam is a webcam API designed for the nannou creative coding framework. It provides cross-platform webcam capture by using nokhwa on native platforms and MediaStreamTrackProcessor on WebAssembly (WASM).

    Key features include:

    • Automatic discovery of cameras as entities.
    • Streaming of video frames as Bevy Image assets.
  3. Overview of nannou_audio

    master

    nannou_audio is the audio API for the nannou creative coding framework. It provides a high-level interface for handling audio tasks in nannou applications. It is built on top of cpal, a pure-Rust, cross-platform audio library.

    Key features include:

    • Access to available system audio devices.
    • Ability to spawn multiple input and output audio streams.
    • A simple builder API for establishing streams with sensible defaults.
    • Consistent buffer sizes for input and output streams across different back-ends.
    • A non-blocking API designed for ease of use.
  4. Overview of nannou_osc

    master

    nannou_osc provides a simple OSC (Open Sound Control) API for the nannou creative coding framework. It acts as a thin, zero-cost abstraction over std::net::UdpSocket and uses the rosc crate for low-level protocol encoding and decoding.

    Key features include:

    • Simple Sender and Receiver APIs for UDP sockets.
    • Reasonable default UDP address bindings.
    • Type-safe distinction between "connected" and "unconnected" senders and receivers.
    • Both blocking and non-blocking Iterator APIs for the Receiver type.
  5. Overview of nannou_midi

    master
    nannou_midi provides a MIDI API for the nannou creative coding framework. It uses midir for cross-platform MIDI I/O and is inspired by bevy_midi. MIDI ports are automatically discovered as entities, and connections are managed through the Entity Component System (ECS).
  6. Overview of nannou creative-coding toolkit

    master

    nannou is an open-source creative-coding toolkit for Rust. It provides tools for creating graphics, user interfaces, and low-level GPU access. The library enables you to create windows, draw to them, and handle user interactions like mouse movement and keyboard presses.

    Key features include:

    • Window management and drawing APIs.
    • Event handling (mouse, keyboard).
    • User interface tools.
    • Low-level GPU access.

    nannou is built on the Bevy game engine and is exposed as a Bevy plugin. This allows you to use the nannou sketch/app API either as a standalone tool or integrated within the broader Bevy ecosystem.

  7. Use nannou_wgpu for WebGPU integration

    master

    The nannou_wgpu crate provides integration for the WebGPU specification via the wgpu crate. It re-exports the entire wgpu crate, allowing you to use standard WebGPU APIs within nannou.

    When accessing this through nannou::wgpu, the following features are enabled by default:

    • image: Enables interoperation with the image crate, including functions for uploading textures from image files.
    • capturer: Provides the wgpu::TextureCapturer API to simplify downloading textures from the GPU and saving them as image files (useful for recording window contents).
  8. Use nannou_draw for 2D and 3D graphics

    master
    The nannou_draw crate provides the Draw API, a simple and expressive way to draw 2D and 3D graphics. It is built on top of the Bevy game engine. The NannouDrawPlugin handles the rendering of meshes, text, textures, and shaders generated by the Draw API using Bevy's renderer.
  9. Explore Nannou Tutorials

    master

    Nannou provides a wide range of tutorials categorized by functional area to help you build creative coding projects. Depending on your experience level and project goals, you can follow paths for:

    • Basics: Learning the anatomy of a Nannou app, drawing sketches, and understanding window coordinates.
    • Drawing: Using the Draw API for 2D shapes, animation, images, 3D shapes, and meshes.
    • Windowing: Managing custom windows, multiple windows, fullscreen modes, and window positioning.
    • Audio: Setting up input/output, device selection, file playback, synthesis, and audio visualization.
    • Video: Drawing, recording, and manipulating video playback.
    • WGPU: Low-level graphics programming including pipelines, compute, fragment, and vertex shaders.
    • Specialized Hardware: Projection mapping (quad-warping), LASER DACs (detection and interpolation), DMX (via sACN), and Serial over USB.
    • Communication: OSC (Open Sound Control) for sending and receiving messages.
  10. Use nannou_video for video playback in Bevy

    master

    The nannou_video crate provides a Bevy plugin, NannouVideoPlugin, designed for decoding and playing back video within the Bevy engine.

    Key features:

    • Native Platforms: Uses video-rs for decoding.
    • Web (WASM): Uses web media APIs.
    • Integration: Streams decoded frames directly as Bevy Image assets.
  11. Use nannou_derive procedural macros via the nannou crate

    master

    The nannou_derive crate provides procedural macros for the nannou framework, such as the #[shader_model] attribute used to define custom shader models for the Draw API.

    Instead of depending on nannou_derive directly, you should typically use the main nannou crate. The macros are re-exported via the nannou crate's prelude, making them available for use in your creative coding projects automatically when you import the prelude.

  12. Access Nannou documentation and resources

    master

    Nannou provides several resources for different stages of development:

    • Getting Started: For beginners, covering Rust installation and starting your first project.
    • Tutorials: Practical guides for specific tasks like sound output, drawing shapes, or laser connectivity.
    • API Reference: The authoritative source-code documentation for all Nannou APIs, hosted on docs.rs/nannou.
    • Developer Reference: Information on Nannou's architecture and how to contribute to the project.
    • Showcases: Examples of projects built using the toolkit.