https://github.com/tairasu/pbm-to-jack
A PBM to Jack function converter
https://github.com/tairasu/pbm-to-jack
converter html jack-language nand2tetris pbm single-page-app
Last synced: 5 months ago
JSON representation
A PBM to Jack function converter
- Host: GitHub
- URL: https://github.com/tairasu/pbm-to-jack
- Owner: tairasu
- License: mit
- Created: 2024-06-08T07:08:44.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-08T09:47:56.000Z (about 2 years ago)
- Last Synced: 2025-02-04T19:46:26.524Z (over 1 year ago)
- Topics: converter, html, jack-language, nand2tetris, pbm, single-page-app
- Language: HTML
- Homepage: https://pbm2jack.netlify.app
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PBM to Jack Converter
## Overview
This project provides a single HTML file to convert PBM (Portable Bitmap) files to Jack language functions, specifically designed for the [Nand2Tetris](https://www.nand2tetris.org/) project. The tool reads a PBM file and generates a Jack function to draw the image in memory.
## Requirements
- The PBM file must be of type P1 (plain PBM format).
- The image width must be a multiple of 16 pixels.
## Usage
1. Open the `index.html` file in a web browser or use the netlify link (https://pbm2jack.netlify.app/).
2. Select a PBM file.
3. The converted Jack code will be displayed in the output textarea.
## How It Works
1. The user selects a PBM file.
2. The file is read and processed:
- Comments and empty lines are filtered out.
- The file type is checked to ensure it's P1.
- The image dimensions are extracted and validated.
- The pixel data is concatenated into a single string.
3. The pixel data is processed column by column, converting each 16-bit wide column into a signed decimal integer.
4. A Jack function is generated to draw the image in memory.
## Contributions
Contributions are welcome. Please fork the repository and submit a pull request with your improvements.
## License
This project is licensed under the MIT License.