Re: Rotated text



On Thu, Nov 21, 2002 at 09:56:10AM -0800, Ian King [ES] wrote:
> What makes you think this is so easy?  For 90, 180 and 270 degrees it's
> fairly simple but what about 45?  I have played about with the gimp and they
> only support limited (90, 180, 270) rotation.  Am I missing something here,
> gdk allows me to render text, can I render that text (or even anything)
> rotated or is that beyond the scope of the `drawing' kit.

The real issues are efficiency and accuracy. Text can be efficiently
rotating 90/180/270 without any significant calculations at all. The
axis are flipped and/or inversed.

I am pretty sure that the gimp supports rotation by a specified
amount.  It is just under a different menu, and it is one of the
interactive tools.

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.

The process can be accelerated by doing 4 pixels at a time, one from each
quadrant. After rotation the transparency of pixels not on the outside rim
should have the same transparency as they did before you started. If the
algorithm is good, you should be able to figure the height:width ratio of
the pixel into the equation to ensure that the image does not appear wrong
to the human eye.

Basic trigonometry... :-)

mark

-- 
mark mielke cc/markm ncf ca/markm nortelnetworks com __________________________
.  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada

  One ring to rule them all, one ring to find them, one ring to bring them all
                       and in the darkness bind them...

                           http://mark.mielke.cc/




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