I just finished a first version of an AsciiImage-Implementation for Delphi. It’s available on Github. For those not familiar with it:
2 Month ago, Charles Parnot posted an article about using simple Ascii-Art for rendering images. For a more detailed look on how things work, take a look at his Post: Replacing Photoshop with NSString
The basics are quite simple. You define an array of strings and fill it with a sequence of Chars representing shapes. The AsciiImage uses this string array to paint an actual image made of Shapes(Ellipsis, Lines, Dots and Polygons). The valid characters for sequences are(in THIS order):
1-9 A-Z a-z
All other characters are IGNORED. And this is how they are used to form shapes:
- if it’s a Character-Sequence (like 1, 2, 3 or 9, A, B), it’s a Polygon. As soon as this sequence breaks (like 1, 2, 3, 4, 6) or is broken up by another type of shape, the Polygonsequence ends. A Polygon with only one Character is rendered as dot.
- if a character occurs twice, it creates a line
- if a character occurs 3 or more times, it forms an ellipsis with a boundingbox which fits around all characters.
This can look like this:
The Memo contains the Ascii-Sequence and on the right is the resulting image. The image is an upscaled version(like Vectorgraphics, it scales!). By looking at the grid, you see how the upscaled version snaps to the native-resolution:
You can go quite crazy with it and do more complex shapes, too:
For more complex shapes like this lock, it is required to alter each shape(modifying Fill and StrokeColor). The source behind this example looks like this:
AsiiImage derives from TGraphic, which allows us to use it in any normal Draw-Operation for a Canvas. A normal Draw paints it with it’s native resolution, StretchDraw generates a scaled version. The OnDraw-Callback is used to alter each shapes apperiance. You get the Shape-Index and a set of properties you can modify.
And as a final image, here is an example from an older implementation of my AsciiImage, which is even more fancy:
And the callback to specify Shape-Properties:
that looks very interesting. Is the demo application available for download? 🙂
Currently not. Working on a few other things but plan to add a Demo at a later time(maybe i’ll prioritize it)
Thanks for your answer!
It’s not really urgent. 🙂 I guess the demo would make it easier to understand what this article really is about.
have you read the linked article at the top? That one explains it a lot better and in more detail what an AsciiImage is.
I have. 🙂
Oh okay o.O
As i am working on the FireMonkey-Implementation, i might add something to toy around with for the next update.
Wow, nice fun stuff indeed. I can’t wait to find a real life usecase and put this to good work.