Difference between revisions of "love.graphics.print"

(made it look pretty)
(Made it simpler)
Line 6: Line 6:
  
 
== Function ==
 
== Function ==
{{newin|[[0.8.0]]|080|type=variant}}
 
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
Line 20: Line 19:
 
{{param|number|ox (0)|Origin offset (x-axis).}}
 
{{param|number|ox (0)|Origin offset (x-axis).}}
 
{{param|number|oy (0)|Origin offset (y-axis).}}
 
{{param|number|oy (0)|Origin offset (y-axis).}}
{{param|number|kx (0)|Shear factor (x-axis).}}
+
{{New feature|0.8.0|
{{param|number|ky (0)|Shear factor (y-axis).}}
+
{{param|number|kx (0)|Shearing factor (x-axis).}}
=== Returns ===
+
{{param|number|ky (0)|Shearing factor (y-axis).}}
Nothing.
+
|080}}
== Function ==
 
{{oldin|[[0.8.0]]|080|type=variant}}
 
=== Synopsis ===
 
<source lang="lua">
 
love.graphics.print( text, x, y, r, sx, sy )
 
</source>
 
=== Arguments ===
 
{{param|string|text|The text to draw.}}
 
{{param|number|x|The position to draw the object (x-axis).}}
 
{{param|number|y|The position to draw the object (y-axis).}}
 
{{param|number|r (0)|Orientation (radians).}}
 
{{param|number|sx (1)|Scale factor (x-axis).}}
 
{{param|number|sy (sx)|Scale factor (y-axis).}}
 
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.

Revision as of 23:38, 10 November 2012

Draws text on screen. If no Font is set, one will be created and set (once) if needed.

As of LOVE 0.7.1, when using translation and scaling functions while drawing text, this function assumes the scale occurs first. If you don't script with this in mind, the text won't be in the right position, or possibly even on screen.

Drawing uses the current color, but only if the ColorMode is "modulate" (which is the default). If your text is displayed as white, it is probably because the color mode is "replace" (which is useful when drawing sprites). Change the color model to "modulate" before drawing.

Function

Synopsis

love.graphics.print( text, x, y, r, sx, sy, ox, oy, kx, ky )

Arguments

string text
The text to draw.
number x
The position to draw the object (x-axis).
number y
The position to draw the object (y-axis).
number r (0)
Orientation (radians).
number sx (1)
Scale factor (x-axis).
number sy (sx)
Scale factor (y-axis).
number ox (0)
Origin offset (x-axis).
number oy (0)
Origin offset (y-axis).
Available since LÖVE 0.8.0
number kx (0)
Shearing factor (x-axis).
number ky (0)
Shearing factor (y-axis).

Returns

Nothing.

Examples

A lame example

function love.draw()
    love.graphics.setColor(0, 255, 0, 255)
    love.graphics.print("This is a pretty lame example.", 10, 200)
    love.graphics.setColor(255, 0, 0, 255)
    love.graphics.print("This lame example is twice as big.", 10, 250, 0, 2, 2)
    love.graphics.setColor(0, 0, 255, 255)
    love.graphics.print("This example is lamely vertical.", 300, 30, math.pi/2)
end

Notes

love.graphics.print stops at the first '\0' (null) character. This can bite you if you are appending keystrokes to form your string, as some of those are multi-byte unicode characters which will likely contain null bytes.

See Also


Other Languages