@name Bezier2 Magic
@inputs 
@outputs 
@persist 
@trigger 

E=entity()

holoCreate(1*100,E:toWorld(vec(200,0,0)))
holoColor(100,vec(255,100,0)) #End
holoCreate(2*100,E:toWorld(vec(50,0,200)))
holoColor(200,vec(0,255,0)) #Mid 2
holoCreate(3*100,E:toWorld(vec(-50,0,200)))
holoColor(300,vec(255,255,0)) #Mid 1
holoCreate(4*100,E:toWorld(vec(-200,0,0)))
holoColor(400,vec(0,0,255)) #Beginning

for(I = 0, 20){
    V1 = mix(holoEntity(1*100):pos(), holoEntity(2*100):pos(), I/20)
    V2 = mix(holoEntity(2*100):pos(), holoEntity(3*100):pos(), I/20)
    V3 = mix(V1, V2, I/20) # This is the point that you have to draw
    
    V4 = mix(holoEntity(2*100):pos(), holoEntity(3*100):pos(), I/20)
    V5 = mix(holoEntity(3*100):pos(), holoEntity(4*100):pos(), I/20)
    V6 = mix(V4, V5, I/20) # This is the point that you have to draw
    
    V7 = mix(V3, V6, I/20) # This is the point that you have to draw
    holoCreate(I,V7)
    holoAlpha(I,255/2)
}

function vector bezier2(Src:vector,End:vector,CurvePoint1:vector,CurvePoint2:vector,Progress:number)
{
    local M1 = mix(mix(End,CurvePoint2,Progress),mix(CurvePoint2,CurvePoint1,Progress),Progress)
    local M2 = mix(mix(CurvePoint2,CurvePoint1,Progress),mix(CurvePoint1,Src,Progress),Progress)
    return mix(M1,M2,Progress)
}
