Copyright 2024 Abhishek A Udupa
This is a simple string-art generation algorithm I made with basic knowledge of mathematics and computer graphics and implemented using the C programming language, from scratch. I made a series of videos on YouTube explaining the process in detail and the code in this repository stays true to that tutorial.
There are a couple of C files in the main directory and the archive corresponding to various YouTube videos in the series.
The code in archive/grayscale.c
converts a given color BMP image to grayscale BMP image of the same size. I've explained it in detail here.
The code in archive/canvas_maker.c
takes an input BMP image and spits out another BMP image that is completely whitewashed. This corresponds to the this video.
The code in archive/thread-generator.c
takes an input BMP image (of same width and height. The program doesn't check this though) and generates another BMP image of the same size which has all possible threads strung between all possible nail-pairs. This file has various functions whose working is explained in details in part-2, part-3 and part-4 of the series.
The code in string-art.c
is of our primary interest as it contains the algorithm for generating the string art. This takes a BMP input image (of equal width and height) and outputs its string art representation. This file corresponds to this video, in which I've given a thorough explanation of its working.
This part is still a work in-progress: I'm yet to show how to optimize the program and to make it converge faster and better. I'm planning to do that in part-6.
None of the programs in this repo follow safe programming techniques such as bounds checking, null checking etc and will crash upon encountering unexpected inputs (if you do not pass the name of the image as an argument, for example). Since I've wrote these programs with the intent to demonstrate the working of the algorithm, I did not bother writing secure code. If you're planning to use this in an unsafe environment, I highly suggest you fortify your programs.