CodingTrain / CodingTrain/Suggestion-Box

Cut shapes out of text by using an image as a cutting mask

Open
#1,727 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
570
Forks
85
PR merge metrics
No merged PRs in 30d

Description

Something like this:

Example image showing a skull shape cut out of text
(solarseven/Shutterstock.com)


Using Lorem Ipsum / random characters / the program's own source code / whatever you like, cut a shape out of the text using a monochrome image as a mask.

Drawing the text, converting it to an image, and using the mask image to cut out a shape would make it easy. So the challenge is... don't do that. If you look around the shape, you'll notice there are no partial characters, no letters that have been cut in half. It's not a simple cookie-cutter shape removing part of an image, it's as if the "masked" characters were never drawn.

I'm thinking maybe treat the mask image as a grid, with each cell being the dimensions of a character in a (monospaced) font, then you can determine whether a character at x, y should be drawn by examining the equivalent mask cell at x, y.

The more advanced challenge would then be to use a variable-width font, as in the image.

Now I'm off to try this myself for giggles.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.