Difference between revisions of "BezierCurve:renderSegment"
(Created page) |
Albur godwin (talk | contribs) m (misprint) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
This function samples the Bézier curve using recursive subdivision. You can control the recursion depth using the depth parameter. | This function samples the Bézier curve using recursive subdivision. You can control the recursion depth using the depth parameter. | ||
− | If you | + | If you just need to know the position on the curve given a parameter, use [[BezierCurve:evaluate]]. |
== Function == | == Function == | ||
=== Synopsis === | === Synopsis === | ||
<source lang="lua"> | <source lang="lua"> | ||
− | coordinates = BezierCurve:renderSegment( | + | coordinates = BezierCurve:renderSegment( startpoint, endpoint, depth ) |
</source> | </source> | ||
=== Arguments === | === Arguments === | ||
− | {{param|number| | + | {{param|number|startpoint|The starting point along the curve. Must be between 0 and 1.}} |
− | {{param|number| | + | {{param|number|endpoint|The end of the segment to render. Must be between 0 and 1.}} |
{{param|number|depth (5)|Number of recursive subdivision steps.}} | {{param|number|depth (5)|Number of recursive subdivision steps.}} | ||
=== Returns === | === Returns === | ||
{{param|table|coordinates|List of x,y-coordinate pairs of points on the specified part of the curve.}} | {{param|table|coordinates|List of x,y-coordinate pairs of points on the specified part of the curve.}} | ||
+ | |||
+ | == Example == | ||
+ | === Draw a segment of a bezier curve === | ||
+ | <source lang="lua"> | ||
+ | curve = love.math.newBezierCurve({25,25,75,50,125,25}) | ||
+ | function love.draw() | ||
+ | love.graphics.line(curve:renderSegment(0, .75)) | ||
+ | end | ||
+ | </source> | ||
+ | |||
== See Also == | == See Also == | ||
* [[parent::BezierCurve]] | * [[parent::BezierCurve]] |
Latest revision as of 15:36, 21 August 2022
Available since LÖVE 0.10.0 |
This function is not supported in earlier versions. |
Get a list of coordinates on a specific part of the curve, to be used with love.graphics.line.
This function samples the Bézier curve using recursive subdivision. You can control the recursion depth using the depth parameter.
If you just need to know the position on the curve given a parameter, use BezierCurve:evaluate.
Contents
Function
Synopsis
coordinates = BezierCurve:renderSegment( startpoint, endpoint, depth )
Arguments
number startpoint
- The starting point along the curve. Must be between 0 and 1.
number endpoint
- The end of the segment to render. Must be between 0 and 1.
number depth (5)
- Number of recursive subdivision steps.
Returns
table coordinates
- List of x,y-coordinate pairs of points on the specified part of the curve.
Example
Draw a segment of a bezier curve
curve = love.math.newBezierCurve({25,25,75,50,125,25})
function love.draw()
love.graphics.line(curve:renderSegment(0, .75))
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