I know, I know. I was supposed to write something about the horizontal layout. But this will have to wait, since I have a sexier thing to talk about. After some hiatus from Logeox, my turtle is finally visible! And here’s the proof:
I’m so excited that it works!
Not so much about how it worked, though. Turns out that I really, deeply suck at geometry. Like, I’d probably fail any reasonable test in analytical geometry. (School tests aren’t reasonable – after all, I passed most of them in my life, though not as well as I’d wish. I mean a real test, like writing a simple turtle graphic program in whatever language on whatever platform…)
Here’s the synopsis of what I did.
res/drawable
.Bitmap
variable, and a BitmapFactory
which took the png from resources and made it into a bitmap object. (Just like in a Java joke – good!)canvas.drawBitmap
. The tricky part (and the one I messed up a few times) is putting it in the right place.Matrix
. You want to know what it is? Morpheus cannot tell you, but any decent book on linear algebra can. A matrix is a special kind of geometrical transformation. Nothing less, nothing more.drawingView.invalidate()
not only after moving the turtle, but also after turning it.OK, so what’s next? If you look at the current state of the code, you’ll notice that I’ll need to move paint
to the turtle object (probably). Then I’ll probably think a bit about that horizontal layout, and add some controls (e.g. for the penup/pendown operations). And then we’ll see.