Re: Rotated text



On Thu, 21 Nov 2002 13:16:52 EST, Mark Mielke said:
 
> To rotate text, do the following:
> 
>     1) Draw the text onto an offscreen image area.
> 
>     2) For each pixel:
> 
>         2a) Determine the offset and angle for the pixel from the 'center'.
> 
>         2b) Plot the pixel (with transparency taking into account that the
>             rectangular pixel is no longer up-right) the same offset
>             from the 'center' of the new image, but at a difference angle.
> 
>     3) Draw the offscreen image area onto the screen as many times as you
>        need to.

I'm told (but haven't tested) that you get better results and less aliasing
artifacts if you do it in reverse:

for each *destination* pixel
  determine the source pixel that is needed
  plot the source into the destination.

This avoids rounding-error artifacts where you get "wedges" where the source
pixels don't map quite right to destinations - if you work from source to
destination, it's possible that two adjacent pixels will map to 2 not-quite
adjacent destination pixels, leaving you a stray empty pixel in between. Working
the other way, you're sure to pick *some* pixel for every destination (even
if you just end up copying one of the two source pixels into the "in between"
dest pixel, that's still better than a black spot ;)

Proper handling of clipping of corners (and filling missing source pixels)
when you're rotating 51.8 degrees is left as an exersize for the student ;)
-- 
				Valdis Kletnieks
				Computer Systems Senior Engineer
				Virginia Tech

Attachment: pgpMvmk0ikaL6.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]