Wednesday, June 12, 2013

AnchorSprite: Setting an anchor point on any Sprite

Having done a lot of work with matrices in Gideros recently, during a discussion at the Gideros forums it occurred to me that with the Matrix class that I recently covered, I could possibly address an oft-requested feature of Gideros. The problem is that in Gideros, all Sprite objects have an anchor point of [0,0] that you can't change. So all transformations such as rotation and scaling are relative to the top left point of the Sprite. The one exception to this is with Bitmap objects, where there is a setAnchorPoint() method. But this doesn't help for other Sprite based objects, such as TextFields or Shapes.

So I whipped together a class called AnchorSprite, which when added to your project, adds a setAnchorPoint() and getAnchorPoint() method to every Sprite object and all objects that inherit from Sprite. Further, bowerandy had the great idea to make this support completely inactive until you set an anchor, that way you could avoid any overhead on sprites that still had the default anchor point.

So I'm going to explain a little bit about how this class works. I'm going to skip over most of the matrix stuff since I already covered that in detail.

Friday, May 17, 2013

The beauty of using matricies to apply transformations to objects

I have recently done a lot of work with matrix transformations, and I found the information on them either sparse, or over-complicated for what I needed. I had to pull together information from many places, split between mathematics focused information, programming reference, and forum posts. So I decided to hopefully write a simple but complete guide on how to understand matrix transformations for the purposes of applying them to computer graphics.

Friday, May 3, 2013

Implementing a better Bezier class in Gideros

Bezier curves are nothing new, and there is a lot of good code out there that implements them well. I started with Paul Burke's algorithm, mainly because someone had already ported it to Gideros. This algorithm works quite well, is fast, and is simple enough to understand. However, I thought I could figure out how to improve on my implementation at least a little, without switching to a much more complicated algorithm. My goals were to produce curves with points in all the optimal places resulting in it being smooth, but with as few points as possible. So this is what I've come up with.

Wednesday, April 10, 2013

Fixing LUA indenting in Sublime Text

I recently started using Sublime Text 2 to edit the Lua project I'm working on, however, it did a couple strange things with indenting. Here is how I fixed them.