p5.asciify Documentation

website·Indexed 33 days ago

https://p5.textmode.art

A TypeScript library for p5.js that converts textures and 2D rendering into ASCII representations. It features a flexible rendering pipeline with support for brightness-based and edge-detection renderers, custom ASCII conversion, and export formats including JSON and SVG.

Tokens
35.1K
Snippets
192
Records
283
Agent score
61%

What's inside p5.asciify

  1. Overview of p5.asciify ASCII conversion library

    p5.asciify is an open-source (MIT License) JavaScript library used to create real-time text-based art and animations. It is built on top of p5.js and utilizes WebGL to ensure high-performance rendering and advanced graphics capabilities during the ASCII conversion process.
  2. Overview of p5.asciify features

    p5.asciify is an add-on library for p5.js designed to transform canvases and textures in WEBGL mode into dynamic ASCII/textmode representations in real-time. Key capabilities include:

    • Renderer Management: Create pipelines using pre-built renderers (e.g., 'brightness' or 'edge' based) or custom renderers to control individual cell characters and colors.
    • Asciifier Management: Apply different rendering pipelines to multiple textures or the main canvas in parallel.
    • Font & Grid Control: Manage font size and metrics, and implement responsive grids based on canvas dimensions or custom column/row counts.
    • Compatibility: Uses GLSL ES 1.0, ensuring support for both WebGL1 and WebGL2 contexts.
    • Export Options: Export ASCII art as .txt, .svg, or .json files.
    • Plugin System: Support for creating and sharing reusable custom renderers.
  3. Overview of P5AsciifierManager

    P5AsciifierManager is a singleton class that manages the p5.asciify library. It handles the initialization of ASCII rendering, coordinates with the p5.js rendering lifecycle, and manages one or more P5Asciifier instances. It can be accessed via the p5asciify object or by calling P5AsciifierManager.getInstance().
  4. Use the p5asciify manager object

    The p5asciify object (of type P5AsciifierManager) is the main entry point for the library and is automatically initialized when the library is included. It manages P5Asciifier instances, which convert the main canvas or specific textures into ASCII representations. By default, it includes one P5Asciifier instance applied to the main canvas, but additional instances can be created to apply different ASCII conversion pipelines to different textures in parallel.
  5. Understand p5.asciify's ASCII conversion process

    p5.asciify converts textures into ASCII representations by using a set of framebuffers. Each framebuffer controls specific properties of the ASCII grid cells. The library reads these framebuffers after the sketch's draw() function executes and merges them to render the final output. For custom renderers, the final ASCII representation is determined solely by the values populated in these framebuffers, ignoring the actual canvas or texture content.
  6. Use p5.asciify in TypeScript projects

    p5.asciify is written in TypeScript and provides first-class, type-safe support. It can be used in TypeScript projects without any additional configuration, as type definitions for all features are provided out of the box.