Skip to content

A fast and customizeable p5.js ascii renderer utilizing a GLSL shader

License

Notifications You must be signed in to change notification settings

humanbydefinition/p5js-ascii-renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

p5.js ASCII renderer

header

This repository contains a p5.js ASCII renderer that uses a GLSL fragment shader to convert a WebGL scene into an ASCII grid. The shader works by sampling the brightness at various points in the scene. Based on the sampled brightness, it determines the appropriate ASCII character to render at each point, creating a unique ASCII representation of the scene.

The goal of this project is to provide a starting point for those interested in creating ASCII art using p5.js. The WebGL scene in this project only features a simple 3D box which is being rotated based on the current frame count, but you can let your creativity run wild and asciify any of your p5.js creations.

  • The rotating 3D box animation is based on creative coding courses from timrodenbroeker.de, which I can highly recommend as a starting point for beginners who are new to the realm of creative coding.

If there are any questions regarding this project, feel free to reach out to me via email ([email protected]) or instagram (@humanbydefinition).

Demo

Note: The demo should work on all types of devices and screens, even though you can't hide the overlay without a keyboard. Let me know if you experience any issues!

Features

  • 🎮 Control Adjust parameters during run-time through an overlay.
  • 🎬 Capture Capture and export the canvas into various image formats, aswell as videos in gif- or webm-format.
  • 🎨 Customize Upload your own fonts & customize font size, character set, colors, grid dimensions and more during run-time.
  • ♻️ Re-use Import and export presets in JSON-format for re-use.

Structure

  • /: Contains index.html, sketch.js, characterset.js (used for creating a 2D texture from a font file), and grid2d.js (used for managing grid dimensions).
  • assets/: Contains font file(s).
  • libraries/: Contains libraries unavailable on CDNs like jsdelivr.com, that are redistributable under the MIT License.
  • shaders/: Contains the GLSL shader for ASCII rendering.
  • ui/: Contains the code for the Tweakpane user interface.
  • utilities/: Contains utility functions, specifically for translating color formats.

Installation

To get started with the p5.js ASCII Renderer, follow these steps to set up a local or remote web server and run the project:

  1. Clone the Repository:
    git clone https://github.com/humanbydefinition/p5js-ascii-renderer.git
    cd p5js-ascii-renderer
    
  2. Set Up a Web Server:
    • For local development, you need a web server to run the project. Refer to the p5.js Wiki for detailed instructions on setting up a local server.
  3. Open the Project:
    • Once the server is set up, open index.html in your browser to see the renderer in action.

Personally, as described in the above wiki article, I recommend using VS Code with the Live Server extension for a smooth development experience.

Dependencies

For a complete list of dependencies, please refer to the repositories linked above.

Assets

Besides this awesome font, I am unfortunately not allowed to redistribute any other fonts here. However, here are some other textmode/pixel fonts that have been successfully tested without any issues:

Font Description
C64 Pro Mono Includes all 304 unique C64 glyphs.
DOS/V re. JPN12 Japanese versions of IBM (PC-)DOS / MS-DOS.
Retromoticons Bitmap emoticon dingbat font containing 77 glyphs.
og-emoji-font Based on the original DoCoMo emoji set, designed in 1999 by Shigetaka Kurita.
pixelated-wingdings Pixelated/8-bit version of the Wingdings font.
FROGBLOCK-V2.1 Monospaced 8x8 textmode font with 256 glyphs.
CHUNKY 8x8 textmode font with 366 glyphs.
Kitchen Sink Monospaced 8x8 textmode font with 256 glyphs.
CozetteVector 6x13 bitmap programming font.
PixelCode Monospace pixel art style programming font.
ark-pixel-font Open source pan-Chinese, Japanese and Korean pixel font.
Vonwaon Chinese pixel font with thousands of glyphs.
unscii-16 Bitmapped Unicode fonts based on classic system fonts.

Feel free to test your favorite fonts, but keep in mind that the current implementation for creating a 2D character tile map texture from a p5.Font object may not work properly with all fonts. For fonts not mentioned here, characters might overlap into other tiles on the texture.

If you have font suggestions to share, I'd love to hear them! 😊

Contributing

Contributions are welcome. Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for more details.