Tuesday, March 17, 2015 [Tweets] [Favorites]

Replacing Photoshop With NSString

Charles Parnot:

This “drawing” described very nicely what I wanted to do, better than any comment I could ever write for any kind of code, in fact. That ASCII art was a great way to show directly in my code what image would be used in that part of the UI, without having to dig into the resources folder. The actual drawing code suddenly seemed superfluous. What if I could just pass the ASCII art into NSImage directly?

[…]

Xcode does not compile ASCII art, so I decided I would write the necessary ‘ASCII art compiler’ myself. OK, I did not write a compiler, but a small fun project called ‘ASCIImage’! It works on iOS and Mac as a simple UIImage / NSImage category with a couple of factory methods. It is open-source and released under the MIT license on GitHub.

So cool, and it looks like a good excuse to play with Monodraw. It also takes care of the fiddly drawing stuff:

Without anti-aliasing, it is tricky to get the correct pixels to turn black. For this, I found that one should use a thicker line width for 45-degree lines, equal to the diagonal of a 1-pt square: the square root of 2. This width works fine for other angles, including horizontal and vertical lines, thus drawing of the lines is done using this width for aliased rendering, instead of the 1-pt width for anti-aliased rendering.

Update (2015-03-25): Charles Parnot:

The response has been overwhelmingly positive, with lots of excitement, oohs, wows and aaahs. That’s an incredibly fun experience for me.

Here are a few related items to follow-up on all this[…]

There are comments on Hacker News and Reddit.

1 Comment

Thanks! I was shocked by the excitement around the blitz talk I gave with this, here at NSConf. Much more excitement than with PARStore 2 years ago ;-)

Using Monodraw with it won't be without friction. There is still quite a bit of constraints on the strings you need to pass ASCIImage that I never bothered to address because it is supposed to be a simple hack for simple icons.

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment