3

I'm currently making a toy project that converts a string of text into a series of GitHub commits. The end result should look something like this:

GitHub Green dots example

The solution I am currently working on is to take a string of text and convert each character to a 7x7 array of boolean values, where true is a green dot, and false is not. Then I'll iterate over that to come up with an array of commits to send to GitHub.

For the first part, I've been searching for an npm package that takes text, like ascii characters and returns a bmp or similar image representing the text, but I haven't had any luck.

Does anybody know of a library that will do something like that? My main requirement is that I can set the 'resolution' of the output, so I can get a 7x7 image from it. Alternatively, if there is an entirely different solution, I'd be happy to hear that too.

Thanks

1 Answer 1

1

Since you are using node.js, you could use opencv4node.js. It has features to write text to an image, that are normally used to annotate images, but should work well for your case.

The image could be whatever grid size you prefer. Then you could iterate over the pixels and use their coordinates to determine the commits.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the suggestion! I just got it working and have rendered a cv.Mat object to a bmp file with some text I've entered. I should definitely be able to use this to generate commit data.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.