Skip to main content

Brainfuck Art

Python Versions Test Status Documentation Status PyPI version

Brainfuck Art is a Python library developed as a hobby project for generating images with hidden Brainfuck code. Inspired by htmlfuck, the library provides functionality to encode text into Brainfuck, convert images to ASCII art, and export the output in HTML, SVG, or PDF formats.

Coffee

Example

You can download this example as pdf Coffee-pdf, copy the content (Ctrl+A) and paste in a brainfuck interpreter like this one to recover the content.

Features

  • Text to Brainfuck: Convert any text into Brainfuck code.
  • ASCII Art Generation: Transform images into color blocks.
  • Multiple Output Formats: Export your creations as HTML, SVG, or PDF.
  • Command-Line Interface (CLI): Generate and export art from the terminal.
  • Python API: Integrate Brainfuck Art into your Python projects with ease.

Installation

To install Brainfuck Art, ensure you have Python 3.9 or higher, and run:

pip install brainfuck_art

Command-Line Usage

You can use Brainfuck Art directly from the command line to create art with hidden Brainfuck code:

# Download the example image
curl -L -o coffee.png https://github.com/pablomm/brainfuck-art/blob/main/docs/assets/coffee.png\?raw\=true

# Generate Art with hidden text
brainfuck-art coffee.png -t "I love coffee" -o "coffee.pdf" -W 100 -H 100

Main Options

  • -t, --text: Text to encode as Brainfuck code.
  • -o, --output: The output file name (with extension).
  • -W, --width: Width of the output in characters.
  • -H, --height: Height of the output in characters.
  • -f, --filetype: File type for output (html, svg, pdf).

Python API Usage

You can also use Brainfuck Art as a Python package to programmatically generate Brainfuck code, interpret it, and create visual art.

Generate Brainfuck Code

from brainfuck_art import text_to_bf

code = text_to_bf("brainfuck")
print(code)

Example output:

'>+++++++[>++++++++++++++<-]>.<++++[>++++<-]>.<++++[>----<-]>-.++++++++.+++++.--------.+++++++++++++++.<+++[>------<-]>.++++++++.'

Execute Brainfuck Code

from brainfuck_art import execute_bf

output, tape = execute_bf(code)
print(output)  # Outputs: brainfuck

Generate ASCII Art with Hidden Text

from brainfuck_art import image_to_matrix, save_matrix_to_svg

text = "I love coffee"
text_matrix, color_matrix = image_to_matrix("coffee.png", text=text)
save_matrix_to_svg(text_matrix, color_matrix, output_file="coffee.svg")

You can also save the output in PDF or HTML formats using the same approach.

License

Brainfuck Art is licensed under the MIT License. See the LICENSE file for more details.

Metadata

Release files for brainfuck-art 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for brainfuck-art 1.0.0
File Size Uploaded Provenance Actions
brainfuck_art-1.0.0.tar.gz 14.7 kB Without provenance Details for brainfuck_art-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for brainfuck-art 1.0.0
File Interpreter ABI Platform Actions
brainfuck_art-1.0.0-py3-none-any.whl Python 3 none any Details for brainfuck_art-1.0.0-py3-none-any.whl

Total release size: 29.7 kB

Release files / brainfuck_art-1.0.0.tar.gz

Download URL brainfuck_art-1.0.0.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
26cf8da19bf32626109ef809457f4af134977e393a136a5be287db4f93ba0342
BLAKE2b-256 checksum
How to use checksums
70f3d0dd5b74da80cd20bcdfa93fc01e00b0ea7ace03aa4bb06bd5ed91627a4f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / brainfuck_art-1.0.0-py3-none-any.whl

Download URL brainfuck_art-1.0.0-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35116ab60a3ca2087cc2dc84492dd61482d36f8bed8d3a509786f3a042c96d82
BLAKE2b-256 checksum
How to use checksums
ad20745440c7b3675e29d73fbe5902e2dd9364a04526ff4dfbd7fb0ff78bb028
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.0 CPython/3.12.5

Security for brainfuck-art 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page