love.graphics.scale
将二维坐标体系进行放大或缩小,请注意LÖVE的坐标体系是以左上角为(0, 0),向右为坐标轴的x正方向,向下为坐标轴的y正方向(而非向上)。
By default the coordinate system in LÖVE corresponds to the display pixels in horizontal and vertical directions one-to-one, and the x-axis increases towards the right while the y-axis increases downwards. Scaling the coordinate system changes this relation.
After scaling by sx and sy, all coordinates are treated as if they were multiplied by sx and sy. Every result of a drawing operation is also correspondingly scaled, so scaling by (2, 2) for example would mean making everything twice as large in both x- and y-directions. Scaling by a negative value flips the coordinate system in the corresponding direction, which also means everything will be drawn flipped or upside down, or both. Scaling by zero is not a useful operation.
Scale and translate are not commutative operations, therefore, calling them in different orders will change the outcome.
Scaling lasts until love.draw() exits.
Function
Synopsis
love.graphics.scale( sx, sy )
Arguments
number sx
- The scaling in the direction of the x-axis.
number sy (sx)
- The scaling in the direction of the y-axis. If omitted, it defaults to same as parameter sx.
Returns
Nothing.
Examples
Draw two lines of text, one scaled and one normal. Uses love.graphics.push and love.graphics.pop to return to normal render scale.
function love.draw()
love.graphics.push()
love.graphics.scale(0.5, 0.5) -- reduce everything by 50% in both X and Y coordinates
love.graphics.print("Scaled text", 50, 50)
love.graphics.pop()
love.graphics.print("Normal text", 50, 50)
end
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info