This is a bezier function where you can get a bezier of any order
https://github.com/qwwshs/lua_bezier
example:
bez = require "bezier"
print(bez:GetBezier(0,1,0,1,0.5,{0,0,1,1,1,1}))
function love.load()
end
function love.draw()
for i=0,1,0.001 do
local int = bez:GetBezier(0,1,0,1,i,{0,0,1,1})
love.graphics.rectangle("fill",i*300,int*300,1,1)
end
end
Bezier
Re: Bezier
Must be:qwws wrote: ↑Tue Aug 27, 2024 10:55 am This is a bezier function where you can get a bezier of any order
https://github.com/qwwshs/lua_bezier
example:
Code: Select all
bez = require "bezier" print(bez:GetBezier(0,1,0,1,0.5,{0,0,1,1,1,1})) function love.draw() for i=0,1,0.001 do local int = bez:GetBezier(0,1,0,1,i,{0,0,1,1,1,1,1,1,0.5,0.5}) love.graphics.rectangle("fill",i*300,int*300,1,1) end end
Code: Select all
local m = 1000
for n = 0, m do -- range n = [0, 1000]
local k = n/m -- range k = [0, 1]
end
Why your code is better than https://love2d.org/wiki/BezierCurve:render or https://love2d.org/wiki/BezierCurve:evaluate?
Re: Bezier
Fixeddarkfrei wrote: ↑Tue Aug 27, 2024 3:27 pmMust be:qwws wrote: ↑Tue Aug 27, 2024 10:55 am This is a bezier function where you can get a bezier of any order
https://github.com/qwwshs/lua_bezier
example:
Code: Select all
bez = require "bezier" print(bez:GetBezier(0,1,0,1,0.5,{0,0,1,1,1,1})) function love.draw() for i=0,1,0.001 do local int = bez:GetBezier(0,1,0,1,i,{0,0,1,1,1,1,1,1,0.5,0.5}) love.graphics.rectangle("fill",i*300,int*300,1,1) end end
Your code makes range [0, 1): the last number is 0.999, not 1.0.Code: Select all
local m = 1000 for n = 0, m do -- range n = [0, 1000] local k = n/m -- range k = [0, 1] end
Why your code is better than https://love2d.org/wiki/BezierCurve:render or https://love2d.org/wiki/BezierCurve:evaluate?
- Attachments
-
- bezier-0.1-2.lua
- (2.51 KiB) Downloaded 1763 times
Last edited by qwws on Thu Aug 29, 2024 2:36 pm, edited 1 time in total.
::Hello::
Re: Bezier
I don't know much about the code for love2d...darkfrei wrote: ↑Tue Aug 27, 2024 3:27 pmMust be:qwws wrote: ↑Tue Aug 27, 2024 10:55 am This is a bezier function where you can get a bezier of any order
https://github.com/qwwshs/lua_bezier
example:
Code: Select all
bez = require "bezier" print(bez:GetBezier(0,1,0,1,0.5,{0,0,1,1,1,1})) function love.draw() for i=0,1,0.001 do local int = bez:GetBezier(0,1,0,1,i,{0,0,1,1,1,1,1,1,0.5,0.5}) love.graphics.rectangle("fill",i*300,int*300,1,1) end end
Your code makes range [0, 1): the last number is 0.999, not 1.0.Code: Select all
local m = 1000 for n = 0, m do -- range n = [0, 1000] local k = n/m -- range k = [0, 1] end
Why your code is better than https://love2d.org/wiki/BezierCurve:render or https://love2d.org/wiki/BezierCurve:evaluate?
but maybe it's the dichotomy that is used
::Hello::
Who is online
Users browsing this forum: Bing [Bot], Semrush [Bot] and 5 guests