@name Bezier Curve
@persist [Start Mid End]:vector
if(first()) {
    #include "mantle/vector"
    #include "mantle/angle"
    Start=entity():pos()
    Mid=entity():toWorld(vec(0,500,100))
    End=entity():toWorld(vec(300,0,0))
    
    holoCreate(1)
    holoCreate(2)
    holoCreate(3)
    holoMaterial(1,"debug/debugdrawflat")
    holoMaterial(2,"debug/debugdrawflat")
    holoMaterial(3,"debug/debugdrawflat")
    holoColor(1,vec(255,0,0))
    holoColor(2,vec(255,255,0))
    holoColor(3,vec(0,255,0))
    holoPos(1,Start)
    holoPos(2,Mid)
    holoPos(3,End)
    #holoScale(1,vec(0.2))
    #holoScale(2,vec(0.2))
    #holoScale(3,vec(0.2))
    holoAlpha(1,128)
    holoAlpha(2,128)
    holoAlpha(3,128)
    
    local Array=bezier(20,Start,Mid,End)
    foreach(I,V:vector=Array) {
        local I=3+I
        holoCreate(I)
        holoPos(I,V)
        holoScale(I,vec(0.1))
        holoColor(I,hsv2rgb((360/20)*(I-3),1,1))
        holoDisableShading(I,1)
        if(I-3!=Array:count()) {
            holoAng(I,ang(Array[I-3,vector],Array[I-2,vector]))
            holoPos(I,(Array[I-3,vector]+Array[I-2,vector])/2)
            holoScale(I,vec(Array[I-3,vector]:distance(Array[I-2,vector])/12,0.1,0.1))
        }
    }
}

Start=entity():pos()
Mid=entity():toWorld(randvec(0,1000))
End=entity():toWorld(randvec(0,1000))

holoPos(1,Start)
holoPos(2,Mid)
holoPos(3,End)
    
local Array=bezier(20,Start,Mid,End)
foreach(I,V:vector=Array) {
    local I=3+I
    #holoCreate(I)
    holoPos(I,V)
    holoScale(I,vec(0.1))
    #holoColor(I,hsv2rgb((360/20)*(I-3),1,1))
    if(I-3!=Array:count()) {
        holoAng(I,ang(Array[I-3,vector],Array[I-2,vector]))
        holoPos(I,(Array[I-3,vector]+Array[I-2,vector])/2)
        holoScale(I,vec(Array[I-3,vector]:distance(Array[I-2,vector])/12,0.1,0.1))
    }
}

interval(1000)
