Constraints and Transforms #

The first I thing I worked on today was to constrain the line drawing when the shift key is held down. I had originally planned to simply restrict it to the x/y axis, but in the end I decided to do it at 45 degree intervals. This took a lot longer, since I had to use trig (I don't like trig), but in the end I got something that worked. I also reused this code to make the movement of the selection be constrained too (only when holding shift of course).

Then I started to work on adding the transformations. Flip vertical was the easiest, since I could operate on entire rows at the same time, and I didn't have to worry about the bit depths. Flip horizontal was trickier, because for each depth the pixel has a different size. For the 8 bit and 32 bit icons this was easy since the pixels were a char and long respectively. For the 1 and 4 bit depths however, it looked a lot more complicated. But then I decided that instead of having to worry about where in the char the pixel fell, I could use my SetPixel1/4 functions together with GetPixel1/4 functions, and then I could swap values easily.

After I did the flips the next step was to do rotations. I decided that rotations at arbitrary angles were unnecessary in an icon editor (besides, I didn't really know how to do them), so I just had to do a 90 degrees clockwise/counter-clockwise. I decided that swapping values in this case was a lot harder, since I had to keep track of which pixels were rotated already, and which weren't, so I used a second GWorld, which I copied back onto the first when I was done.

Post a Comment