Draw Text Rotated?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
peaches
Prole
Posts: 9
Joined: Tue Jul 28, 2009 7:47 pm

Draw Text Rotated?

Post by peaches »

I'm playing with kinetic type, but none of the text-drawing algorithms allow rotated text. Is there a way around this than other making images of A-Z, or doing procedural vectors?
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Draw Text Rotated?

Post by Jasoco »

Code: Select all

love.graphics.draw(text, x, y, rotation, scale)
Works with fonts based on images. Not sure if it'll work with fonts based on actual font calls.

For a starter image font, I just steal the one from one of the many examples (Like sinescroller) and shrink it to 50% (Using Photoshop's nearest neighbor method) and color it to black instead of blue. (I use it for my debug messages in my game since it looks good on any background and sticks out enough to know it's for debugging, not for release.)
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Draw Text Rotated?

Post by TechnoCat »

I love kinetic type. I'm really interested in seeing what you come up with.
YouTube - HARUHI intro - KineticTypography I love this stuff.
peaches
Prole
Posts: 9
Joined: Tue Jul 28, 2009 7:47 pm

Re: Draw Text Rotated?

Post by peaches »

So i was dumb; I mean is there a formatted draw (love.graphics.drawf) that can be rotated?

love.graphics.draw() is annoying because it doesn't offer good options for rotating around the center, other than computing it yourself.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Draw Text Rotated?

Post by Jasoco »

I think LÖVE's drawing commands should have been designed a little differently keeping the text drawing separate from the shape drawing. Like love.graphics.drawText("Hello!", x, y, rotation, angle) and love.graphics.drawImage(image, x, y, ...) to keep them separate from each other. Because it seems to be you can use both draw and drawf for text depending on if you want it rotated and scaled or not. I stumbled onto this accidentally when I gave my text wrong parameters and the wrong draw command, instead of drawing a text box with a fixed width, it drew a rotated, scaled text string. There should have been completely different commands for drawing different things. Because drawf may do text, but draw can also do text which gets confusing.

From the documentation:

Code: Select all

draw( string, x, y )   	 Draws text on screen.
draw( string, x, y, angle ) 	Draws rotated text on screen.
draw( string, x, y, angle, s ) 	Draws rotated/scaled text on screen.
draw( string, x, y, angle, sx, sy ) 	Draws rotated/scaled text on screen.
draw( sprite, x, y ) 	Draws an Image or Animation on screen.
draw( sprite, x, y, angle ) 	Draws a rotated Image or Animation on screen.
draw( sprite, x, y, angle, s ) 	Draws a rotated/scaled Image or Animation on screen.
draw( sprite, x, y, angle, sx, sy ) 	Draws a rotated/scaled Image or Animation on screen.
draw( particlesystem, x, y ) 	Draws a particle system on screen.

drawf( string, x, y, limit )   	 Draws formatted text on screen, with word wrap.
drawf( string, x, y, limit, align ) 	Draws formatted text on screen, with word wrap.
	
draws( image, x, y, cx, cy, w, h ) 	Draws a subsprite of an Image.
draws( image, x, y, cx, cy, w, h, angle ) 	Draws a rotated subsprite of an Image.
draws( image, x, y, cx, cy, w, h, angle, s ) 	Draws a rotated/scaled subsprite of an Image.
draws( image, x, y, cx, cy, w, h, angle, sx, sy ) 	Draws a rotated/scaled subsprite of an Image.
draws( image, x, y, cx, cy, w, h, angle, sx, sy, ox, oy )
Note draw is used for both text strings AND images. Depending on what you pass to it. And then it can also be used for particles! But you can also use draws for sprites of a different kind, or drawf for text. Now that's just confusing.

*sigh* I remember the good old simple days of
LOCATE 10,10
PRINT "HELLO!"
LINE (0,9)-(50,9), 15
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Draw Text Rotated?

Post by Robin »

Wasn't that changed in 0.6.0?
Help us help you: attach a .love.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Draw Text Rotated?

Post by Jasoco »

I don't know. Is 0.6.0 even out? I haven't seen it yet.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Draw Text Rotated?

Post by Robin »

No, but if you feel reckless, I suppose you could use the development SVN/Mercurial or whatever they are using at the moment.
Help us help you: attach a .love.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Draw Text Rotated?

Post by Jasoco »

Not sure I'm feeling wreckless at the moment, but I will look at the changes coming so far. :ultraglee:
Mr. Strange
Party member
Posts: 101
Joined: Mon Aug 11, 2008 5:19 am

Re: Draw Text Rotated?

Post by Mr. Strange »

I've been waiting for rotated + line-wrapped text for quite a while now. I don't see it listed specifically in the 0.6.0 list linked above...

Perhaps you simply mean that draw functions for images and text are disambiguated? That's cool, but the OP and I still want to rotate our formatted text.

Can we get confirmation on the presence / absence of that feature in the next release?

--Mr. Strange
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 30 guests