8 ms·
Replacing Photoshop with NSString
- ygra 12y agoMy go-to choice for this has been SVG. For shapes as the ones in the post it's trivial to write by hand and equally trivial to generate various amounts of raster images in various sizes. It's been quite helpful for preparing Android and iOS app icons without constantly having to revise half a dozen different images whenever one changed. It's also easy to change opacity or colour of the shapes/strokes for generating icons for different themes (Holo Dark and Holo Light on Android need different colours, for example).
- paupino_masano 12y agoI haven't checked lately but traditionally SVG wasn't available with UIImage yet was with NSImage. This often lead to custom drawing code for vectors on iOS.
- ygra 12y agoI used it only as source for the differently-sized raster images. I sort-of inherited an Android and iOS app at that workplace and just went with what was there. But given that the app used OpenGL I'm not sure there even was a possibility of a vector format to use.
- jheriko 12y agowhy does OpenGL rule out vector formats? there aren't that many great libraries out there for doing it cross platform, but if you treat them as platform dependencies it should be easier... you can probably google and find loads, but to get you started a little... the main one I have experience of is 'cairo' which is quite a powerful library for all kinds of drawing things. there is an android build config (although its a bit old now) here: https://github.com/anoek/android-cairo https://github.com/anoek/android-cairo - it is however not great for iOS or OS X... i've not used, but heard good things about 'sugar' as well: http://sourceforge.net/projects/libsugar/ http://sourceforge.net/projects/libsugar/
- ygra 12y agoIt doesn't rule it out per se, but just rendering a texture is much easier, with fewer dependencies. Android toolbar icons are PNG, not SVG. Most renderers have trouble with all but the simplest SVGs (filters, etc. can be a pain in the ass – Inkscape renders them nicely to PNG and I just don't have to worry). There's a trade-off everywhere and all my solution did was take input SVGs and render the PNGs in various sizes which we previously had to maintain by hand. If rendering vector graphics would have been a major competitive advantage to the app I'm sure it would have been considered ;-)
- jheriko 12y agosure. you are right. i do wonder how long it will take for Apple to come around to mipmapping and trilinear filtering to tackle their very normal problem of multiple resolutions. it seems to work well enough in all their use cases for the last 20 years or so... :)
- grimmdude 12y agoVery cool. I like the idea of using a text editor as an image editor.
- archagon 12y agoI am really surprised that there haven't been more efforts in this direction. As a programmer who's recently been dabbling more in graphics, I hate having to fiddle with knobs and redo my work when I often know exactly what needs to be done and how to do it. If I need to draw an oval 10 times, I shouldn't have to copy and paste it, forcing me to redo the entire thing if I decide to make a change; I should be able to define the oval in script and use a loop to position it exactly how I want! I wish there was an editor with an interface as great as (say) Pixelmator's, but with an optional script window that let you write and edit the code for your vector graphics if you need to. Something PostScript powered, maybe? (PaintCode does something like this, but it's more of a one-way, vector-to-code mapping. Bloom promises to do a lot of this, but I haven't used it in a while.[1]) [1]: http://thebloomapp.com/features/ http://thebloomapp.com/features/
- teleclimber 12y ago> If I need to draw an oval 10 times, I shouldn't have to copy and paste it, forcing me to redo the entire thing if I decide to make a change Indeed you shouldn't! That's why all serious image manipulation programs have this capability built in. Most of them also let you write your own plugins for those cases where you need more than what the interface provides. I think going to all-code drawing is more limiting than freeing. It seems more like a case of having a hammer and seeing that everything can be made to look like a nail.
- archagon 12y agoWell, I'm not advocating all-code drawing! What I'm suggesting is a WYSIWYG editor like any other, but with a 1-to-1 script mapping for all the commands under the hood. If you want to generate an oval in code, go for it; but you can also create one using the oval tool (and edit it later in script if you change your mind). As for plugins, that's not really integrated into the workflow in the way I'm envisioning. I shouldn't have to write heavy code just to experiment with a quick artistic idea! Think web development. It should be as simple as editing a JS file and refreshing the page.
- agumonkey 12y agoNice idea. Can't help but to think of Emacs artist-mode: http://tanehp.ec-net.jp/heppoko-lab/diary/artist_mode_test.png http://tanehp.ec-net.jp/heppoko-lab/diary/artist_mode_test.p...
- milen 12y agoShameless plug - Monodraw [1] is perfectly suited to create the ASCII diagrams for this. I'm planning to add special support for ASCII Image if there's enough demand - so definitely let me know. [1] http://monodraw.helftone.com http://monodraw.helftone.com
- charles_parnot 12y agoI will write the promised README, btw :)
- skrebbel 12y agoWow. That looks like a dream come true. (if only it worked on my computer) I guess a Windows or Linux version is never going to happen? I'd love to be able to run this.
- milen 12y agoUnfortunately, it's very unlikely. I'm a Mac developer and that's why Monodraw is written for OS X (in Obj-C). I'm a supporter of all platforms but I do not have any cross-platform desktop GUI skills.
- pjc50 12y agoWindows or Linux people who want to do ASCII art should do it in DOSBOX with THEDRAW: http://www.syaross.org/thedraw/ http://www.syaross.org/thedraw/
- oneeyedpigeon 12y agoWow, monodraw is a really polished app. That's a fascinating business model, too - your own idea, or inspired by another? Are you planning on giving users notice when the beta period is about to end? I'm not 100% sure I'll really get regular use out of it, but I'm tempted to buy a copy anyway, mainly because I think you deserve reward for the effort that's obviously gone into it. If I could wish for anything it would be this: is it even remotely possible for shapes from a plain text file to be interpreted as monodraw objects, rather than just one big text field?
- arctangos 12y agoa) This is a remarkably neat idea. b) It probably shouldn't have to exist. ... which just about sums up the Objective-C experience
- soup10 12y agoI'm going to join you here in the grey. Objective-C is a disaster of a language on many levels. Portable C++ is the smarter and better choice(and those few cases where it isn't is solely because of intentional and unethical design decisions by apple to lock you into their platform).
- christoph 12y agoI know you & the parent have both been down-voted, but it would be great if you could explain some rationale behind why Objective C is such a disaster in your opinion(s)? When I first started learning it, I absolutely _hated_ it. With a burning passion. It is probably now my current favourite and most productive language. I seem to very rarely write buggy/poor/badly structured code and almost never hit compiler errors/hard crashes unless they are something relatively obscure. It's quite common for me to write 1k+ lines of code, hit build and have exactly what I wanted compile & work pretty much first time.
- archagon 12y agoNot OP, and I agree that Objective-C is great. However, it is potentially troubling, from a performance standpoint, that practically everything is allocated on the heap. There's no support in the language for stack-allocated objects, for example. Now that I've used Swift in production, I also really miss generics. Casting to and from containers gets really annoying and unsafe!
- gurkendoktor 12y ago> practically everything is allocated on the heap It has gotten a lot better thanks to tagged pointers: https://www.mikeash.com/pyblog/friday-qa-2012-07-27-lets-build-tagged-pointers.html https://www.mikeash.com/pyblog/friday-qa-2012-07-27-lets-bui... Objective C is mostly used for UI code, and I think it's a fantastic language for that, with its Ruby-like weak typing and strong metaprogramming capabilities.
- lepht 12y agoIt'd be interesting to combine this with monodraw: http://monodraw.helftone.com/ http://monodraw.helftone.com/
- Zezima 12y agoGuess we can expect a full NSImage export feature in the full version. I just started using Monodraw and this was the first thing that came to mind as well.
- cordite 12y agoThis is a work of art in of its self, never mind the icons made. It is also inspiring for ascii to graphics representation utilities as well. I wonder if this could be extended to make shape holder content, where in the art you can specify the stretch locations and protected zones. (kinda like how you can do a boxy like configuration on images for dynamic content inside via CSS3)
- command_tab 12y agoI imagine it could work like Android 9-patch PNG drawables, which have an extra ring of pixels around the perimeter that mark content zones and stretching zones.
- halosghost 12y agoActually, something very like this has been done for a long time (the XPM): https://en.wikipedia.org/wiki/X_PixMap https://en.wikipedia.org/wiki/X_PixMap All the best,
- daeken 12y agoXPM is only for resolution-specific rasters. His technique allows for bezier paths, arbitrary fills, etc and is resolution-independent. It's pretty clever, IMO.
- halosghost 12y agoI didn't say what the author did was bad, uncool or not clever. But it certainly isn't a revolutionary thing that's never been done before. Additionally, XPM sucks (I'm aware), and I've been wishing for a significant update to it for a long while :P
- skrebbel 12y agoDid you read the article at all? It's hardly even comparable.
- halosghost 12y agoI'm confused; how is this not comparable? It's creating a pixmap directly from strings. I'm not saying this project is bad or uncool, I'm just saying this isn't a completely new idea.
- matiaspiipari 12y agoThe ASCIImage rendering code described in the post we're discussing is actually resolution independent vector graphics. You can draw neatly pixel aligned stuff with it, as is shown in the screenshots, but it's vector graphics.
- halosghost 12y ago
- brianpgordon 12y agoI did something very similar to render scaled ASCII-art text (a la Figlet): https://github.com/briangordon/vector-figlet https://github.com/briangordon/vector-figlet
- deleted 12y ago[deleted]
- matiaspiipari 12y agoThere's more info about Charles' ASCIImage at http://asciimage.org http://asciimage.org , including an OSX based editor for the file format it that we put together with Charles during NSConference (direct download link to the ASCIImage Super Studio editor: https://rink.hockeyapp.net/apps/8ac351501c5c3db78ececb2f7e26062f https://rink.hockeyapp.net/apps/8ac351501c5c3db78ececb2f7e26...)
- charles_parnot 12y agoHi, all. I am the blog post author, blown away by the attention this 1-day hack is getting! I am the author of Findings, a lab notebook app for scientists. Check it out and show it to others: http://findingsapp.com http://findingsapp.com I also created this page: http://asciimage.org http://asciimage.org, with my friend @mz2. There is a simple editor as well called ASCIImage Super Studio. And check out Monodraw, I love it!! http://monodraw.helftone.com http://monodraw.helftone.com (see comment here: https://news.ycombinator.com/item?id=9240942 https://news.ycombinator.com/item?id=9240942)
- aidos 12y agoReally cool concept. Well done. I didn't quite understand how the single points worked. It seemed to me that your definition for, say, 3 single points was the same as a triangle. How does it know which is which? Or do the curves have to be closed?
- charles_parnot 12y agoWhen you skip a character, you move on to next shape. So, 1-2-3 5-6-7 = 2 triangles But 1 3 5 = 3 points
- aidos 12y agoI think I was thrown off by the example which used 1,1,1,1 for the sphere and 2, 3 to represent isolated points. But they're consecutive. Unless I'm missing something?
- deleted 12y ago[deleted]
- charles_parnot 12y agoah, damn, you're right!
- charles_parnot 12y ago
- adamtj 12y agoThis looks vaguely like xpm, but monochrome and vectorized. xpm is an image format that is also valid C code, so you can #include "image.xpm" in your C source code. https://en.wikipedia.org/wiki/X_PixMap#Comparison_with_other_formats https://en.wikipedia.org/wiki/X_PixMap#Comparison_with_other...
- wtallis 12y agoThis isn't monochrome. Stroke and fill colors can be specified per-shape, just not in the diagram itself.
- grkvlt 12y agoXPM isn't monochrome either, though. I always thought XPM was an elegant hack, since I could just #include my icons into the C source for my Xt or Motif applications. I don't miss the rest of Xt and Motif, particularly the pseudo-object-oriented C style code, or the twenty kilograms of O'Reilly books containing the documentation!
- mrspeaker 12y agoAlso kinda like XBM, a file format that was happily supported in the browser - and you could create the images in JavaScript! http://www.mrspeaker.net/2005/03/27/xmb-images/ http://www.mrspeaker.net/2005/03/27/xmb-images/ - unfortunately, IE was first to discontinue it in 2006 (http://www.mrspeaker.net/2006/09/04/the-end-of-xbm/ http://www.mrspeaker.net/2006/09/04/the-end-of-xbm/), and Firefox followed. My guess is it was too obvious of a security hole vector for an image format that no one actually used ;)
- infogulch 12y agoWhat if you allowed composing multiple "layers" into a single output to make different parts of an otherwise busy diagrams more clear? For example, I found the bug one particularly obfuscated: · · · · 3 · · · · · · · · · · · · · · · · · · · · · · 7 · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 1 3 · · 1 · · · · · · · · · · 5 · · 5 · · · · · · · · · · · B · · · · · · · 2 · · · 7 · · · · 2 · · · · · · · · · · · · · · · · · · · · · · · · 1 · · · 1 · · · · · · · · · · · · · · · · · · · · · B · 9 · · · · · 8 · · · 8 · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · C · · · · · · · · · · · · · · · · · · · · · · · · · · 9 · · · · · · · · A · · · · · · · · · · · · · · 2 · · · · · · · · 2 · · · · · · · C · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · A · · · · · But if you split it into two diagrams it becomes much more clear what's going on: · · · · · · · · · · · · · · · · · · · · · · 3 · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 7 · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 1 · · · 1 · · · · · · · · · · · · · · 3 · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 5 · · 5 · · · · · · · · · · · B · · · · · · · 2 · · · · · · · · 2 · · · · · · · · · · · · 7 · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 1 · · · 1 · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · B · 9 · · · · · · · · · · · · · · · · · · · · · · · 8 · · · 8 · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · C · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 9 · · · · · · · · · · · · · · · · · · · · · · · · · · A · · · · · · · · · · · · · · 2 · · · · · · · · 2 · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · C · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · A · · · · · Especially if you name them. Here, "body" and "legs". Edit: add spaces for clarity. Edit2: use cdot.
- charles_parnot 12y agoTBH, the bug is an example of where this hack should not be used :D
- woah 12y agoIs it really slow to draw these waiting for compile each time?
- david-given 12y agoJudging by the first example, I'd guess it's probably creating an NSBezierPath and then letting OSX actually do the rasterisation later.
- charles_parnot 12y agoExactly
- tehwebguy 12y agoThis reminds me of the sprites I made in QuickBasic with 2-digit color codes. Very cool!
- ebbv 12y agoYeah I was going to say the same thing. I did that well over 20 years ago when I was a kid.
- thom 12y agoYeah, the chevron in the article would just be: DRAW "BM+3,+1 R1 F4 D1 G4 L1 U1 E3 U1 H3 U1" You could change the scale with "Sn" so you could draw any size, and there were commands to fill shapes etc. There was a similar language for music as well, they were both nice little DSLs.
- tres 12y agoIt would be awesome to extend this into a library based on FontAwesome; create an abstraction layer which would allow easy reference like CSS.
- robbiep 12y agoIt sure would... fontAwesome ios libraries (mostly using NSImage) are all awful and broken
- anigbrowl 12y agoI don't wish to sound rude, because this is great work by the author, but isn't this reinventing the wheel? Why not just use SVG? It might be somewhat less efficient for the very simplest images, but doing raster layers in code and including things like bezier handling seems perversely complex.
- supercoder 12y agoBecause this lets you 'code' the icon visually , rather than describing the steps to draw. It's a brilliantly simple but effective ideas. Very tempted to use it in my next project.
- anigbrowl 12y agoBut why not just draw it instead of, well, typing it in ASCII? Once you start doing layers and blending and so on, you're just asking for misalignment errors, surprises when your bezier paths turn out to generate little unwanted loops and so on... It seemed like the author's original problem was having to do so over and over to deal with different pixel densities, but this is exactly the sort of problem SVG exists to solve. I do admire the technical skill, I just don't get the attraction of compiling ascii art into a vector image for anything practical, for much the same reason that I wouldn't want to use Photoshop or Illustrator to write code.
- charles_parnot 12y agoI only use it for very simple icons (square, couple of lines, etc)
- anigbrowl 12y agoThat makes sense. I apologize for coming off as so negative, I really do think it's very clever.
- charles_parnot 12y ago
- JoshTriplett 12y agoThis is really impressive! For the actual drawing, I'm wondering if the cairo library and drawing model would help. It effectively gives you the move-to line-to curve-to drawing, with some additional capabilities. A simple script around cairo seems like it would cover many more cases, and then this ASCIImage mechanism will help generate those scripts.
- wtallis 12y agoWhat extra capabilities do you think cairo would provide that could be exposed through the ASCII-art mechanism without overly complicating it? This thing is already choosing to not expose the full functionality of the NSBezierPath drawing APIs.
- JoshTriplett 12y agoI'm not suggesting extending the ASCII art mechanism. I'm just suggesting that compared to the API shown in the first example, cairo makes simple line-art quite trivial to write as code. Specific features that would make sense to have available rather than drawing art in an image editor: Line width, to draw the chevron without having to draw two adjacent lines. Dotted/dashed lines.
- chj 12y agoWhat a powerful way to represent graphics in code. I am definitely using this. Thank you!
- cpncrunch 12y agoIt would be nice to have an html5 version that draws into a Canvas.
- charles_parnot 12y agoBe my guest :-) I added the js port on asciimage.org. There is a Go version as well I will link to.
- cpncrunch 12y agoNice. I was half considering doing it myself, but it looks like it's already done :) I'm considering using this to redesign the UI on one of my products. Hiring a designer is a huge pain, but this is a viable alternative.
- vinceyuan 12y agoCool and useful!
- pjbrunet 12y agoThis is how we did DOS VGA fonts ~1990. Draw the pixels right in the code (everything was monospace) and write that array directly to video memory. Mode 13 (320x200x256) video memory was sequential, easy to animate. Also you could do palette scrolling. Consequently, Mode 13 was the best video mode for games http://en.wikipedia.org/wiki/Mode_13h http://en.wikipedia.org/wiki/Mode_13h
- thom 12y agoIn the 80s I made most of my games by using the Amstrad's font support to draw sprites in a similar fashion. :)
- Vektorweg 12y agoThis reminds me of the ASCII-fied arrow notation. http://scrambledeggsontoast.github.io/2014/09/28/needle-announce/ http://scrambledeggsontoast.github.io/2014/09/28/needle-anno...
- vbezhenar 12y agoI wonder what's better from the point of final user (app size, app starting speed, app performance, memory usage): png or this drawing code? I suspect that PNG should work better. And programmer can easily generate multiple PNG from single hand-written SVG.
- charles_parnot 12y agoYes, PNG is probably using less memory. For a few small icons, though, it's negligible either way.
- matiaspiipari 12y agoIf speed / memory is of essence, it's simple enough to pre-render this .asciimage kind of data with the code @cparnot has made available at https://github.com/cparnot/ASCIImage https://github.com/cparnot/ASCIImage. I whipped up a quick commandline tool for the purpose as part of https://github.com/mz2/ASCIImage-Super-Studio https://github.com/mz2/ASCIImage-Super-Studio: https://twitter.com/mz2/status/579283430858465280 https://twitter.com/mz2/status/579283430858465280 It could of course be rendered to a PDF or TIFF or other Cocoa supported image file format, consider that just a 5-minute hack to demonstrate the idea.
- myfonj 12y agoNot speaking about processing costs, this could be nice format for storing the data. Consider the example from page: 1 2 3 4 5 6 7 a · 1 2 · · · · b · A # # · · · c · · # # # · · e · · · 9 # 3 · f · · · 8 # 4 · h · · # # # · · i · 7 # # · · · j · 6 5 · · · · It is textually 58 characters of data: 7 ·12·····A···············9·3····8·4·········7······65···· (Axis headers and whitespace ommited, two characters added to keep the row width information.) It is almost the same size of the smallest possible SVG polygon of similar shape consisting of 59 characters: data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"><polygon points="0,0 2,0 5,3 5,5 2,8 0,8 0,6 2,5 2,3 0,2"/></svg> Using even the simplest coordinates notation it could look like 24 characters: a2a3e6f4j5j6i7f6e9b2f cf (Three characters added to keep "Close and fill" information.) Smallest 7×8 px PNG with the same image is 96 bytes large: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAcAAAAIAQMAAAAPyndFAAAABlBMVEX///8AAABVwtN+AAAAFUlEQVQI12NIYChgsGCQAUILICsBABJQAkm4hriIAAAAAElFTkSuQmCC
- Kiro 12y ago> Because of “retina”, you also have to create separate files for 1x, 2x, and now 3x-scale OT but why do you need three different and not just go with the 3x which you scale down?
- dirtyaura 12y agoDesigners have more possibilities with 3x and 2x than with 1x as you can draw small details. If you scale them to 1x, the icon will look blurry, because the details doesn't scale well. If you want high level of polish, you typically make at least some touches to the scaled down icons. Of course, in the context of the original ascii art icons, that level of polish doesn't matter.
- twsted 12y agoI like it very much. I would push this even further: I see it as a sort of "Markdown for simple vector graphics", with tools able to convert it to SVG and other formats.
- charles_parnot 12y agoNice way to think about it. I agree.
- locusm 12y agoThats cool, reminded me of PaintCode which I keep meaning to try out. http://www.paintcodeapp.com/ http://www.paintcodeapp.com/
- robin_reala 12y agoWe used PaintCode on our recent iOS game in conjunction with RubyMotion. My colleague wrote a blog post about it: http://paulsturgess.co.uk/blog/2015/03/03/using-paintcode-to-dynamically-create-images-in-the-ios-football-manager-game-title-challenge/ http://paulsturgess.co.uk/blog/2015/03/03/using-paintcode-to...
- jheriko 12y agothis is quite cool. reminds me of making levels for games using ascii art in code... but taken to a whole other level :)
- SunboX 12y agoCan't understand why there's no good SVG implementation in Objective-C / Swift. SVG makes Web-Dev or even C# / XAML so much easier.
- sah2ed 12y agoVery cool work! A great link I found in the article's comments for generating dot-matrix text: http://www.omgtldr.com/.matrix/ http://www.omgtldr.com/.matrix/
- gus_massa 12y agoFeature request: With 4 repeated numbers in the corners, draw a filled rectangle instead of a filled ellipse: Circle Square ..#1#.. 2#####2 .#####. ####### ####### ####### 1#####1 ####### ####### ####### .#####. ####### ..#1#.. 2#####2
- charles_parnot 12y agoI actually did consider this when writing the "parser" but it was complicated enough that it was just getting in the way of my goal of having the simplest code and specs that got the job done. Also using 1-2-3-4 is simple enough that I decided it was not worth the extra rule.
- myfonj 12y agoFeature idea: BRUSH. After finishing a shape or stroke, call it a brush and drag it. Brush from a shape (like in the example chevron): . 2 3 . . . . . 1 4B# . . . . . # # # . . . . . # # # . . . . # # 5 . . . # # # . . . # # # . . . . # 6 . . . . Brush from single line stroke (like a 'calligraphic pen'): . 1b# # # # 2 1 # # # # # . . . . . # . . . . . # . . . . . # . . . . . 3 # # # # 4 # # # # # # . This would also ease creating complex strokes with rounded corners: with ellipses or other rounded shapes as a brushes.
- bakul 12y agoThis seemed like a fun little project so I created https://github.com/bakul/avg.git https://github.com/bakul/avg.git -- a Go package that converts an "ascii vector graphic" string vector into a shape vector.
- charles_parnot 12y agoawesome!
- charles_parnot 12y agoI added a link to it on asciimage.org