Sunday 3 July 2011

Sketchtasy

We've released a different kind of app to our usual fare this week:  Sketchtasy!  This is a very basic drawing app for the iPad that offers pressure-sensitive input so the thickness of the lines you draw depends on how hard you are pressing on the screen.

Sketchtasy was designed to be as simple as possible.  It offers a full screen drawing panel and the ability to select a color from a palette that you can create from a huge selection of colors.  The only other feature is the ability to import a photo from your album and use it as a background so you can trace over it, and then remove the photo to reveal the final sketch...and that's it.  Nothing else stands in the way between you and your drawing so it's quick and easy to use.

Some readers might be interested in the technical aspects.

There are several noteworthy functions that combine to create the overall effect.  Firstly, the pressure sensitivity is based on an algorithm that constantly measures the accelerometer and works out an "average" touch pressure, which is then converted into a line thickness.  This isn't as simple as it sounds because the accelerometer only measures the amount of movement in a time period and not the pressure at any given moment, so we had to work out a way to translate the acceleration.

Secondly, to achieve good performance the new drawing strokes are rendered to an internal bitmap image.  While drawing the screen, this pre-rendered image is displayed first followed by only the latest stroke.  This is fairly standard practice for iOS drawing apps.  However, Sketchtasy also retains the original vectors of each drawing stroke and while at the moment it's only used for the Undo function, it technically makes it possible for us to implement an "infinite zoom" function or print at extremely high resolutions so we'll probably implement these in a future version.

Finally, however, the time it takes to process the accelerometer and translate it into pressure combined with the pre-rendering means that the touch responsiveness isn't as smooth as you'd think (or that we'd like).  We ended up using a quadratic bezier spline to interpolate the movement between adjacent points so that a smooth curve is displayed.

The end result is a drawing app where the thickness of the lines can change throughout the same stroke because of the touch pressure applied.  We think it adds a new element to the existing drawing apps that are out there - it was certainly a lot of fun to develop!

0 comments:

Post a Comment