just watched this video and created the simple version of the Quadratic besier Curve.
She also has good shader/render pipe Videos:
AGK Code:
// Project: Bezier Curves
// Created: 22-04-12
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Bezier Curves" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 100, 100 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 )
StartPoint as Core_Vec2Data
MidPoint as Core_Vec2Data
EndPoint as Core_Vec2Data
StartPoint.X#=25
StartPoint.Y#=75
MidPoint.X#=50
MidPoint.Y#=25
EndPoint.X#=75
EndPoint.Y#=75
StartMidPoint as Core_Vec2Data
MidEndPoint as Core_Vec2Data
Result as Core_Vec2Data
ResultStart as Core_Vec2Data
BlueColor=MakeColor(128,128,255)
GreenColor=MakeColor(128,255,128)
do
Time#=Timer()
SinTime#=abs(sin(Time#*10))
//Start, Mid and End Points
DrawLine(StartPoint.X#,StartPoint.Y#,MidPoint.X#,MidPoint.Y#,255,255,255)
DrawLine(MidPoint.X#,MidPoint.Y#,EndPoint.X#,EndPoint.Y#,255,255,255)
//Interpolate between Start and Mid Point
StartMidPoint.X#=Core_Lerp(StartPoint.X#,MidPoint.X#,SinTime#)
StartMidPoint.Y#=Core_Lerp(StartPoint.Y#,MidPoint.Y#,SinTime#)
DrawEllipse(StartMidPoint.X#,StartMidPoint.Y#,1,1,BlueColor,BlueColor,0)
//Interpolate between The Resulting StartMid and MidEnd Point
MidEndPoint.X#=Core_Lerp(MidPoint.X#,EndPoint.X#,SinTime#)
MidEndPoint.Y#=Core_Lerp(MidPoint.Y#,EndPoint.Y#,SinTime#)
DrawEllipse(MidEndPoint.X#,MidEndPoint.Y#,1,1,BlueColor,BlueColor,0)
DrawLine(StartMidPoint.X#,StartMidPoint.Y#,MidEndPoint.X#,MidEndPoint.Y#,128,128,255)
//The Actual Bezier Functionto use with less parameter
Result.X#=Core_QuadraticBezier(StartPoint.X#,MidPoint.X#,EndPoint.X#,SinTime#)
Result.Y#=Core_QuadraticBezier(StartPoint.Y#,MidPoint.Y#,EndPoint.Y#,SinTime#)
DrawEllipse(Result.X#,Result.Y#,1,1,GreenColor,GreenColor,0)
//Example code for drawing a whole Bezier Line
MaxSegments#=15
for i=1 to MaxSegments#
Segment#=i/MaxSegments#
ResultStart.X#=Core_QuadraticBezier(StartPoint.X#,MidPoint.X#,EndPoint.X#,Segment#-(1/MaxSegments#))
ResultStart.Y#=Core_QuadraticBezier(StartPoint.Y#,MidPoint.Y#,EndPoint.Y#,Segment#-(1/MaxSegments#))
Result.X#=Core_QuadraticBezier(StartPoint.X#,MidPoint.X#,EndPoint.X#,Segment#)
Result.Y#=Core_QuadraticBezier(StartPoint.Y#,MidPoint.Y#,EndPoint.Y#,Segment#)
DrawLine(ResultStart.X#,ResultStart.Y#,Result.X#,Result.Y#,128,128,255)
next i
Print(ScreenFPS())
Print(str(SinTime#,2))
Sync()
loop
function Core_QuadraticBezier(Start#,Mid#,End#,Time#)
StartMid#=Core_Lerp(Start#,Mid#,Time#)
MidEnd#=Core_Lerp(Mid#,End#,Time#)
StartEnd#=Core_Lerp(StartMid#,MidEnd#,Time#)
endfunction StartEnd#
function Core_Lerp(Start#,End#,Time#)
endfunction Start#+Time#*(End#-Start#)
do you guys know of a AppGameKit library with all the derivatives and Attributes like velocity and curvature of a curve ?