My book on Python and Qt programming — which has always been plagued by availability problems and a publisher who managed to fail to get it into Amazon — is finally obsolete: Mark Summerfield’s Rapid GUI Programming with Python and Qt has just been published by Prentice Hall. I haven’t read it, but I’m quite confident that it’ll be an excellent book.
Category: hacking
The Design and Evolution of C++
By Bjarne Stroustrup
Since October 2003 I have learned to appreciate the C++ programming language. In fact, the better I get acquainted with C++, the more I like it. So, after having read Practical C++ by Ouailline, C++ in a Nutshell by Lischmer, Accelerated C++ by Koenig and Moo and a few others, and after having touched half a million lines of C++, I thought it time to go to the master for instruction.
Which is why I bought a second-hand copy of The Design and Evolution of C++, and later also The C++ Programming Language. Even though it’s an old book, dating back to 1994 (stone age, practically, no mention of Java or Python in this book), TDaEoC++ was exactly right for me. I like reading the combination of a historical treatment and a discussion per “feature” or “problem area” much more than a language specification or a tutorial-style book. I feel I’ve got a much better understanding of why things are the way they are in C++.
Of course, it’s also an advantage that Stroustrup is a clear and entertaining author: not too dry, but not trying to be overly funny either. If I wanted to niggle I’d say that Stroustrup is a little too defensive, although that’s understandable given the flak that C++ has been getting since its inception.
Open Source Game Development: Qt Games for KDE, PDAs, and Windows
In Krita 2.0, we will be using OpenGL much more than we already do in Krita 1.5, so I need to learn. When ordering the two basic books, OpenGL Programming Guide and OpenGL Shading Language, Amazon gave me Open Source Game Development, Qt Games for KDE, PDAs, and Windows as a related choice.
I was a bit surprised: a whole book on coding games for KDE? But, well, it had an introductory chapter on OpenGL, and I thought that might help me ease into the topic.
It turns out this book is a really excellent, well-written concise and clear introduction to coding for KDE. Not just for coding games, but the whole thing. The ideal beginner’s introduction for people who are interested in coding for KDE. Of course, it doesn’t deal with CMake yet, although there is quite decent coverage of Qt4. And the OpenGL chapter is just what I needed, too.
Buy this book, is my advice!
Hibernate in Action
Hibernate in Action is a really, really good book. In my previous life as a Python hacker I spent quite a few evenings hacking together an object/relational mapping framework much like hibernate, only in python. This book starts with a very good, very thorough, very clear introduction to the whole problem of mapping objects to relational databases. The remaining chapters are clear, concise, well-paced and well-written, too. My next book on a Java topic is going to be a Manning book, too.
It’s a bit of a pity then that Hibernate is a typical Java library. It comes with a slew of dependencies, it needs ant, but doesn’t build out of the box. The readme isn’t accurate enough to fix that, you need to go to the faq to find out which libs are missing… Oh, well, I’m going to try to port a Java app I’ve just finished to Hibernate anyway, to see if it works.
Physically-Based Modeling Techniques for Interactive Digital Painting
By William Valentine Baxter III
This dissertation is the single most important advance in digital art since the first paint application by Shoup. In contrast with earlier academic work, like Curtis and Salesin on water colour painting, or Cockshott on oil paint simulation or any of the other research papers published and collected in volumes like Non-Photorealistic Rendering (Gooch and Gooch), Bill Baxter has not just investigated his topic and written some text, but he has created a real, usable, interactive application that has been tested by actual artists. The other researchers have never reached that stage — well, maybe we should count Raph Levien’s Wet Dream, which is derived from Curtis et al.
In this dissertation, Baxter describes the following advances in the art of painting on a computer:
- A three-dimensional brush model, based on a simulation of the physical properties of real brushes.
- Not one, but three successful models of paint as an artistic substance.
- Rendering paint and mixing paint in a way that simulates the way paint actually works, instead of just fudging it with RGB.
- A way to use a force-feedback stylus to give the user the impression that he is holding a real brush.
As I said in an earlier blog entry, no other paint application needs to apply. Corel Painter is junk compared to the possibilities of a rich application model like this. Art Rage is a toy, and a very weak one, too. Twistedbrush is a joke… I could go on, say something scathing about the very idea to use a vector application to create an artistic image for instance, but I will stop here.
Of course, once you’ve got IMPaSTo (irregular capitalization rules), you’re not done yet. Something similarly rich and physical for watercolors, pencils, chalk, pen & ink, charcoal, brush & ink needs to be done, and preferably in such a way that you can mix materials and surfaces; I tend to combine oils with fine details in India ink.
This dissertation is, apart from presenting a truly great vista of what painting with a computer could be — and should be — remarkable in that it is also very clearly organized and very well-written. I still couldn’t grasp the math (what does an upside-down capital delta mean?), but that’s to be expected of someone who never had any decent maths, even at secondary school. But the principles were clear, the way Baxter uses — and I suspect sometimes abuses — OpenGL and shader routines to simulate and render paint was an eye-opener.
So it’s a pity the code isn’t going to be open-sourced — I can understand it, it has the potential of becoming a commercial hit — but I’d have loved to peek at the actual source…
Wet and Sticky: A Novel Model for Computer-based Painting
By Malcolm Tundle Cockshott
I got a PDF copy of the microfiched version of this 1991 dissertation from the website of Bill Baxter. This is one of the first works on making painting on the computer something approaching real painting, with real viscous, thick paint.
The dissertation is a riveting read — that’s to say, I finished it in two evenings. It’s light on math, and in the microfiche version all screenshots have turned to blurs and none of the colour plates have survived.
The basic idea behind wet & sticky is to add attributes other than colour to the individual pixels — liquid content, weight, drying speed — and to give each pixel a substrate with an absorbency factor and a gravity. (That’s a fun thing: you can have clusters of pixels with a gravity opposed to the main run of gravity.). Then there’s an automaton,
more or less a permanently running filter, that moves paint around according to gravity and some other rules, and that dries paint up.
There exists an implementation of this model, originally created for a Sun box in 1991, and never really released; but when I asked Dr. Cockshott whether it would be possible to open source the software he said he’d like that to happen, and when I mailed one of the original authors (Dr. David England — the other is Kevin Waite — he immediately mailed me a zipfile
with all the original source, released under the GPL.
I spent an evening porting the source over to Linux — an easy task really, the makefiles were a bit borked and there was a copy of netpbm included that we could do without, that was all. I didn’t manage to get the OpenGL interface working, just the old Athena widgets interface. Good grief… Unix GUI toolkits have come some way since 1991… In any case, being 1991 code, this wouldn’t run in my true-colour display, so I restarted X with an 8-bit visual and started
playing a bit:
I didn’t make an animation, but the paint is slowly dripping downwards in a quite realistic movement, and if you manage to make a few marks on the canvas before the application crashes, you can see it giving a pretty effect to your brush strokes.
Of course, this code (a mere 2000 lines of Kernighan & Ritchie C) is only a research example. But it’s clear enough that I think I can incorporate it as a separate color model into Krita; that will give us an opportunity to really exercise Casper Boemann’s new tile code, because now we have fourteen channels of which three are floats (or maybe doubles) and the rest small ints; I want to have the filter run in a separate thread (or maybe async using timers) so it can offload work to the second processor, and there needs to be a way for a color model plugin to add stuff to the gui; a settings docker, a special colour mixing
palette and some other things. Quite a challenge — and I really should be finishing the littlecms integration, and the selections, but this is so much fun — and the reason I started hacking on Krita in the first place…
Non-Photorealistic Rendering
By Bruce and Amy Gooch
When I bought a Wacom tablet my intention was to use it to sketch maps for my novel-in-progress. Quite soon I discovered that it came with an application that purported to imitate, simulate or fake real artist’s media, like charcoal, paint and ink.
Author: Bruce and Amy Gooch
- Title: Non-Photorealistic Rendering
- Pages: 243
- Published: 2001
- Publisher: A.K. Peters, Natick, Massachusetts
- ISBN: 1568811330
Being quite fond of pottering with pencils, ink, paint — pity my monitor and keyboard keep my desk fully occupied leaving no room for artists’ materials — I decided to give that app a try. Well, trust me on this Corel Painter sucks. It doesn’t do what it promises: simulate real artists media on a computer with a graphics tablet.
Raph Levien explains why; and his little article piqued my interest enough that I started to cast around for a project to experiment with. I don’t even have the beginnings of mathematics, but I understood his paper, or so I thought.
After an attempt to code a prototype in Python, I decided to teach myself C++ (see forthcoming review of Koenig and Moo’s Accelerated C++), and I decided to join my lot with Krita, KDE’s long-languishing paint application.
And I needed to get the low-down on simulating paint, charcoal, the works. It is surprisingly hard to find good stuff on that. A few web-pages exist, a few SIGGRAPH papers can be downloaded, and one or two books look helpful. It seems that this is a field very much in its infancy. Fun, in other words.
Non-Photorealistic Rendering is the term most commonly employed in the field, even though I am not interested in rendering: I am interested in replicating the artist’s experience on the computer, pure and simple. I don’t want to confuse him or her with layers, brush masks, opacities or Porter-Duff composition strategies. I had high hopes (see the TOC of this book on the authors’ page) of this book, but only the first few chapters were interesting, and even so, they merely summarized papers I had already found. The pseudo-code they give for simulating ink is laughable and useless and their discussion seems geared towards providing a primer for students looking for a finals project.
Indeed, they often give an estimate of how much time it would take a decent programmer to replicate the results presented in a certain paper… I wish the authors of those papers would open their code, I consider keeping code secret the same as withholding facts, which is, as Dorothy L. Sayers famously said in ‘Gaudy Night’, the same as publishing a falsehood.
Anyway, this book contained four, maybe six pages of real interest to me… For other people, the balance might be better, of course. But if what you want is to create a painting app then you don’t want this book.
Java 2D Graphics
Jonathan Knudsen is, acknowledges the back blurb, an O’Reilly staff writer. That means he’s not a subject expert, but what is technically termed a ‘hack’ who writes about whatever subject O’Reilly needs a book about. That’s not to say that he doesn’t know his subject, but his book on Java Cryptography wasn’t all that good and at first I thought that the book on Java 2D graphics wasn’t up to scratch either.
- Author: Jonathan Knudsen
- Title: Java 2D Graphics
- Pages: 339
- Published: 1999
- Publisher: O’Reilly
- ISBN: 339 1-56592-484-3
When I read the book from front to back, only omitting the silly how-to-read-this-book-manual at the front, and the bits on fonts and text in the middle (I wasn’t interested in those; I was interested in a clear description of a paint and pixel-mess API), I discovered that
this is a pretty useful book.
Note that I had a Purpose in reading this book: I wanted a different, more object-oriented, perspective on a 2D API than Qt’s QPainter/QPaintDevice combo for Krita. I’ve investigated ImageMagick, Magic++, Libart — but this was the only description in book-form available to me. And it helped me a lot. A particular gem is the description of an image as a spatial function on page 215 (your page number may differ, I used the first edition). Good stuff, too, is
the PNG decoder.
However, I wouldn’t know how useful this book would be to someone who wanted to have a go at 2D Java programming, but my guess is: pretty useful.
Computer Graphics: Principles and Practice
By Foley, van Dam, Feiner, Hughes
Foley et al. is the current incumbent of Newman and Sproull: the absolute standard text for budding graphics programmers. The field has widened, deepened and generally ballooned; that’s clear just from the difference in page numbers: Foley is twice Newman.
- Author: Foley, van Dam. Feiner, Hughes
- Title: Computer Graphics: principles and practice
- Pages: 1175
- Published: 1996 (1990
- Publisher: Addison-Wesley Publishing Company
- ISBN: 0-201-84840-6
But is it twice as useful, too? Not for me; I’m really not interested in 3d rendering, and takes up the bulk of the book. The chapter on colour models is useful, but not comprehensive enough, and the chapter on compositing made me want to find the original Porter-Duff paper. Okay, so that’s good, maybe.
Another point is that I find the writing in general inferior to Newman & Sproull; not as clear, not as concise. Still one for the library, if only because it contains pointers to everything that’s useful. The kids rather liked the colour prints, though.
Principles of Interactive Computer Graphics
By William M. Newman and Robert F. Sproull
I’m trying to hack Krita into submission. I want a paint application that fakes natural media and the way they work, not just the way they look. So I’ve started studying C++ and computer graphics, a completely new field for me.
- Author: William M. Newman and Robert F. Sproull
- Title: Principles of Interactive Computer Graphics
- Pages: 541
- Published: 1983 (1979)
- Publisher: Mc Graw-Hill
- ISBN: 0-07-046338-7
Newman and Sproull is old, venerable even. But it still was an extremely useful introduction for me. Because it is so old, it spends time explaining the basics. Once you get beyond all the talk about vector displays, this is the book that most clearly tells you how to draw a line.
Useful, very useful — and written in a clear style that makes even the maths comprehensible to me.