Difference between revisions of "love.graphics.point"
(Add an (admittedly overcomplicated) example) |
m |
||
(8 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{newinoldin|[[0.3.0]]|030|[[0.10.0]]|100|type=function|text=It has been replaced by [[love.graphics.points]]}} | ||
+ | |||
Draws a point. | Draws a point. | ||
== Function == | == Function == | ||
Line 12: | Line 14: | ||
== Notes == | == Notes == | ||
The pixel grid is actually offset to the center of each pixel. So to get clean pixels drawn use 0.5 + integer increments. | The pixel grid is actually offset to the center of each pixel. So to get clean pixels drawn use 0.5 + integer increments. | ||
+ | |||
+ | Points are not affected by [[love.graphics.scale]] - their [[love.graphics.setPointSize|size]] is always in pixels. | ||
== Examples == | == Examples == | ||
Render a starfield | Render a starfield | ||
<source lang="lua"> | <source lang="lua"> | ||
function love.load() | function love.load() | ||
+ | local screen_width, screen_height = love.graphics.getDimensions() | ||
+ | local max_stars = 100 -- how many stars we want | ||
+ | |||
stars = {} -- table which will hold our stars | stars = {} -- table which will hold our stars | ||
− | + | ||
for i=1, max_stars do -- generate the coords of our stars | for i=1, max_stars do -- generate the coords of our stars | ||
− | local x = math.random(5, | + | local x = love.math.random(5, screen_width-5) -- generate a "random" number for the x coord of this star |
− | local y = math.random(5, | + | local y = love.math.random(5, screen_height-5) -- both coords are limited to the screen size, minus 5 pixels of padding |
− | stars[ | + | stars[i] = {x, y} -- stick the values into the table |
end | end | ||
end | end | ||
+ | |||
function love.draw() | function love.draw() | ||
− | for i | + | for i, star in ipairs(stars) do -- loop through all of our stars |
− | love.graphics.point( | + | love.graphics.point(star[1], star[2]) -- draw each point |
end | end | ||
end | end | ||
Line 32: | Line 40: | ||
== See Also == | == See Also == | ||
* [[parent::love.graphics]] | * [[parent::love.graphics]] | ||
+ | * [[love.graphics.setPointSize]] | ||
+ | * [[love.graphics.setPointStyle]] | ||
[[Category:Functions]] | [[Category:Functions]] | ||
+ | [[Sub-Category::Drawing| ]] | ||
{{#set:Description=Draws a point.}} | {{#set:Description=Draws a point.}} | ||
{{#set:Since=000}} | {{#set:Since=000}} | ||
== Other Languages == | == Other Languages == | ||
{{i18n|love.graphics.point}} | {{i18n|love.graphics.point}} |
Latest revision as of 02:43, 21 October 2022
Available since LÖVE 0.3.0 and removed in LÖVE 0.10.0 |
It has been replaced by love.graphics.points. |
Draws a point.
Contents
Function
Synopsis
love.graphics.point( x, y )
Arguments
Returns
Nothing.
Notes
The pixel grid is actually offset to the center of each pixel. So to get clean pixels drawn use 0.5 + integer increments.
Points are not affected by love.graphics.scale - their size is always in pixels.
Examples
Render a starfield
function love.load()
local screen_width, screen_height = love.graphics.getDimensions()
local max_stars = 100 -- how many stars we want
stars = {} -- table which will hold our stars
for i=1, max_stars do -- generate the coords of our stars
local x = love.math.random(5, screen_width-5) -- generate a "random" number for the x coord of this star
local y = love.math.random(5, screen_height-5) -- both coords are limited to the screen size, minus 5 pixels of padding
stars[i] = {x, y} -- stick the values into the table
end
end
function love.draw()
for i, star in ipairs(stars) do -- loop through all of our stars
love.graphics.point(star[1], star[2]) -- draw each point
end
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