Difference between revisions of "love.graphics.points"

(Created page)
 
m
 
(8 intermediate revisions by 4 users not shown)
Line 5: Line 5:
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
love.graphics.points( x1, y1, x2, y2, ... )
+
love.graphics.points( x, y, ... )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|number|x1|The position on the x-axis of the first point.}}
+
{{param|number|x|The position of the first point on the x-axis.}}
{{param|number|y1|The position on the y-axis of the first point.}}
+
{{param|number|y|The position of the first point on the y-axis.}}
{{param|number|x2|The position on the x-axis of the second point.}}
+
{{param|number|...|The x and y coordinates of additional points.}}
{{param|number|y2|The position on the y-axis of the second point.}}
 
{{param|number|...|x and y coordinates of additional points.}}
 
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
Line 22: Line 20:
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|table|points|A table containing multiple point positions, in the form of <code>{x1, y1, x2, y2, ...}</code>.}}
+
{{param|table|points|A table containing multiple point positions, in the form of <code>{x, y, ...}</code>.}}
 +
{{subparam|number|x|The position of the first point on the x-axis.}}
 +
{{subparam|number|y|The position of the first point on the y-axis.}}
 +
{{subparam|number|...|The x and y coordinates of additional points.}}
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
  
 
== Function ==
 
== Function ==
 +
Draws one or more individually colored points.
 +
 +
In versions prior to [[11.0]], color component values were within the range of 0 to 255 instead of 0 to 1.
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
Line 32: Line 36:
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|table|points|A table containing multiple individually colored points, in the form of <code>{point1, point2, ...}</code>.}}
+
{{param|table|points|A table containing multiple individually colored points, in the form of <code>{point, ...}</code>.}}
{{subparam|table|point1|A table containing the position and color of the first point, in the form of <code>{x, y, r, g, b, a}</code>. The color components are optional.}}
+
{{subparam|table|point|A table containing the position and color of the first point, in the form of <code>{x, y, r, g, b, a}</code>. The color components are optional.}}
{{subparam|table|point2|A table containing the position and color of the second point, in the form of <code>{x, y, r, g, b, a}</code>. The color components are optional.}}
+
{{subparam|table|...|Additional tables containing the position and color of more points, in the form of <code>{x, y, r, g, b, a}</code>. The color components are optional.}}
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
 
=== Notes ===
 
=== Notes ===
The global color set by [[love.graphics.setColor]] is modulated (multiplied) with the per-point color.
+
The global color set by [[love.graphics.setColor]] is modulated (multiplied) with the per-point colors.
  
 
== Notes ==
 
== Notes ==
Line 71: Line 75:
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Sub-Category::Drawing| ]]
 
[[Sub-Category::Drawing| ]]
{{#set:Description=Draws one or more points..}}
+
{{#set:Description=Draws one or more points.}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.graphics.points}}
 
{{i18n|love.graphics.points}}

Latest revision as of 01:01, 16 July 2021

Available since LÖVE 0.10.0
It has replaced love.graphics.point.

Draws one or more points.

Function

Synopsis

love.graphics.points( x, y, ... )

Arguments

number x
The position of the first point on the x-axis.
number y
The position of the first point on the y-axis.
number ...
The x and y coordinates of additional points.

Returns

Nothing.

Function

Synopsis

love.graphics.points( points )

Arguments

table points
A table containing multiple point positions, in the form of {x, y, ...}.
number x
The position of the first point on the x-axis.
number y
The position of the first point on the y-axis.
number ...
The x and y coordinates of additional points.

Returns

Nothing.

Function

Draws one or more individually colored points.

In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1.

Synopsis

love.graphics.points( points )

Arguments

table points
A table containing multiple individually colored points, in the form of {point, ...}.
table point
A table containing the position and color of the first point, in the form of {x, y, r, g, b, a}. The color components are optional.
table ...
Additional tables containing the position and color of more points, in the form of {x, y, r, g, b, a}. The color components are optional.

Returns

Nothing.

Notes

The global color set by love.graphics.setColor is modulated (multiplied) with the per-point colors.

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()
   love.graphics.points(stars)  -- draw all stars as points
end

See Also


Other Languages