Harmony.codea - a procedural drawing tool

“The difficulty is that rendering a bezier at the moment is quite costly - you have to triangulate it at a fine enough mesh that it appears smooth. It’s okay if the path is quite long, but with lots of short paths then it gets messy and slow.”

You might already have a solution for that problem. When I think about common drawing techniques, hatching (or cross-hatching) is the only one I can recall that uses a lot of short paths. In fact, I could see where it would easily blow up a program trying to make everything into beziers. For anyone not familiar with hatching, it is simply a technique where the artist lays down a series of short, parallel strokes (or sometimes parallel lines crossed with perpendicular, parallel lines) to give the appearance of a shaded area. To identify hatching, have the app watch for individual, consecutive, parallel strokes. If the user draws three or more of these lines, you can presume the artist is hatching and you can trash the bezier information. As luck would have it, many of the current brushes in Harmony can detect the presence of another line drawn closeby; Harmony draws nice webs between them. This same intelligence could be used to detect hatching.

As another option (or in addition to the above option), you can make a user-defined parameter that gives the artist the choice of what length of line becomes the crossing point of when it is a line and when it becomes a bezier curve. Personally, I don’t care if my short lines have no control handles. If I don’t like them, I can delete them and draw new ones. It’s the long lines that need the bezier stuff. And by making that crossing line user-configurable, it becomes my own fault if the results are not to my liking.

I like doing it by length of line, or even by line type. A pen draws a line as we currently have it defined by a series of points. Then a completely different tool gives you a path which by design will have a small number of elements some of which could be beziers.

Rotatable text boxes will be in the next update (next time I’m at my laptop).

@Andrew_Stacey… Can’t wait for the update. By the way, will there be time, in your future schedule, to show us how the Brush, BrushEx, and Drawable classes work? I can’t figure out how you’re doing it. Note: if I’m the only one interested, I don’t want to waste your time.


Okay… I retract my request. I would have hoped, by now, that others on this forum would have chimed in (i.e. yes!.. yes!.. please @Andrew… please make us a brush tutorial), but I appear to be the only one. It may be that everyone else understands it already. I’ll just work through it and ask questions when I get stuck.

@Ric_Esrey Not sure how many are still reading this thread!

Anyway, latest code is now updated including rotateable text boxes. Use two fingers to rotate (and translate). This works both in “edit” mode and non-edit mode. There’s a glitch somewhere that means it sometimes ignores the first touch.

As for the brushes, that code really goes back to @shrike. I’ve adapted and extended, but kept the same basic model.

Ok, ding dong, this is Fred chiming in to say this has been a great thread. It been a great example of collaboration generating some great code.

Thanks @Fred, it’s nice to know others are interested in the non-game development part of this forum. @Andrew, thanks for the update. BTW, you have a procedure that allows users to save a picture and then call it back as a background in Harmony. Is there a way to use your text box scale and rotate functions on them?

@Fred Thanks for the encouragement. Collaboration is fun and it’s nice to know others are watching too.

@Ric_Esrey The background can only be rotated or flipped. But you can load pictures and move, scale, rotate them. That’s already there: slect “Add Picture” (or the nearest option) from the drawing menu. Same controls as the text nodes.

New version includes the “flow lines” code (see relevant thread for explanation).

Ooh great! I was just playing with them and am about to tackle downloading Harmony from your web site.

Umm, @Andrew_Stacey, is there an easy way to grab all these files at once, without using bzr? I have just got to grips with GitHub… Thanks!

git can import from bzr (I’ve been told). You can also get .zip files from http://www.math.ntnu.no/~stacey/documents/Codea/AESLibrary.zip and http://www.math.ntnu.no/~stacey/documents/Codea/AESHarmony.zip. If you give me a couple of mintues, I’ll write a Codea-to-single-file perl script to put them into the right format for a single file cut-and-paste.

Hey thanks, @Andrew_Stacey! A zip should be fine for my purposes.

Well, I figured out a single file exporter anyway, so they’re also as single files. Just replace the .zip by .lua in the links above.

I love flow lines - they seem like the stands of a peacock feather…

Don’t seem able to embed images from Dropbox, but anyway here’s a couple of simple examples:

https://www.dropbox.com/s/i5aopgwy50grzhw/Swirls.png

https://www.dropbox.com/s/gfe7e6lf5oml1ig/Swirls2.png

Beautiful pictures!

.@Andrew_Stacey, I just installed your latest version of Harmony and your library. Yet, the color picker (or is it colour picker) doesn’t work for me anymore. Now, there’s a grey box half in front of the colouour palette and the scroll bars are not drawing correctly. Do you think this problem is due to the new Codea version?

@Ric_Esrey It’s been a while … I do remember there being a change with the colour picker. Specifically, there was a change in how scale affected lines and ellipses (something to do with strokeWidth). I fixed it at one point but it may be that a more recent update of Codea has broken it again. I’ll check on my iPad again to be sure and then check that my published code is the most up to date.

(This might take a couple of days due to Reduced Internet Access.)

Are you on Codea 1.5(.X)?

Yes… it has been a while @Andrew_Stacey. Unfortunately, I haven’t been able to download your Harmony and Library code since late October. I’ve been deployed to Afghanistan where Reduced Internet Access is a way of life. Just this past week, however, the IT shop upgraded the satellite so we can do more than just check email. Of course, the first thing I did was to update Codea (to version 1.5.1) and download your procedural drawing files.