| Not a conventional Bezier spline method, but can be useful for some applications. 
 
 
 
;
; ALTERNATIVE CURVING CONSTRUCTION METHOD
;
; "how to get a curve using two lines segments"
;
; ralph.le.gall@...
Graphics 800,600,GraphicsDepth(),6
stp=20 ;<--you can change this "step" value
	x1#=150 : y1#=150 ;A starting place coords
	x2#=650 : y2#=450 ;B starting place coords
	Dim xyA#(stp,1) ;"segments line  steps"
	Dim xyB#(stp,1) ;"segments line  steps"
	Dim xyZ#(stp,1) ;"segments curve steps"
	;set green and yellow 3x3 dots..
	dotAB=CreateImage(3,3) : SetBuffer ImageBuffer(dotAB) : ClsColor   0,120,0 : Cls : MidHandle dotAB
	dotZ=CreateImage(3,3)  : SetBuffer ImageBuffer(dotZ)  : ClsColor 255,255,0 : Cls : MidHandle dotZ
	SetBuffer BackBuffer()
ClsColor 0,0,0
MoveMouse x2#,y1# ;move mouse to "orthogonal" place
;__________________________________________________________________________________________________________________
While KeyDown(1)=False
	xm#=MouseX() : ym#=MouseY()
	Cls
	;-------------------------------------------------------------------------------------------------
	;INFOS
	;-------------------------------------------------------------------------------------------------
	Color 120,120,120
	Text 10,10,"Left  click = place A"
	Text 10,25,"Right click = place B"
	Text xyA#(  0,0),xyA#(  0,1),"A"
	Text xyB#(stp,0),xyB#(stp,1),"B"
	;-------------------------------------------------------------------------------------------------
	;-------------------------------------------------------------------------------------------------
	;SET SEGMENTED LINES AND CURVE
	;-------------------------------------------------------------------------------------------------
	;construction lines coords..
	tmp_float#=(xm#-x1#)/stp : For i=0 To stp : xyA#(i,0)=x1#+((tmp_float#)*i) : Next
	tmp_float#=(ym#-y1#)/stp : For i=0 To stp : xyA#(i,1)=y1#+((tmp_float#)*i) : Next
	tmp_float#=(x2#-xm#)/stp : For i=0 To stp : xyB#(i,0)=xm#+((tmp_float#)*i) : Next
	tmp_float#=(y2#-ym#)/stp : For i=0 To stp : xyB#(i,1)=ym#+((tmp_float#)*i) : Next
	;curve coords (based on previous construction lines)..
	For i=0 To stp
	tmp_float#=(xyB#(i,0)-xyA#(i,0))/stp : xyZ#(i,0)=xyA#(i,0)+((tmp_float#)*i) ;X curve values
	tmp_float#=(xyB#(i,1)-xyA#(i,1))/stp : xyZ#(i,1)=xyA#(i,1)+((tmp_float#)*i) ;Y curve values
	Next
	;-------------------------------------------------------------------------------------------------
	;-------------------------------------------------------------------------------------------------
	;VISUAL ELEMENTS
	;-------------------------------------------------------------------------------------------------
	;green segments lines..
	Color 0,60,0 : For i=0 To stp : Line xyA#(i,0),xyA#(i,1),xyB#(i,0),xyB#(i,1) : Next
	;green and yellow 3x3 dots..
	For i=0 To stp
	DrawImage dotAB,xyA#(i,0),xyA#(i,1)		;green  dots (from A to mouse_XY)
	DrawImage dotAB,xyB#(i,0),xyB#(i,1)		;green  dots (from mouse_XY to B)
	DrawImage dotZ, xyZ#(i,0),xyZ#(i,1)		;yellow dots
	Next
	;yellow segments curve..
	Color 160,160,0 : For i=0 To stp-1 : Line xyZ#(i,0),xyZ#(i,1),xyZ#(i+1,0),xyZ#(i+1,1) : Next
	;-------------------------------------------------------------------------------------------------
	;-------------------------------------------------------------------------------------------------
	;PLACING DOTS A B
	;-------------------------------------------------------------------------------------------------
	If MouseDown(1) Then x1#=xm# : y1#=ym#
	If MouseDown(2) Then x2#=xm# : y2#=ym#
	;-------------------------------------------------------------------------------------------------
Flip False
Wend
;__________________________________________________________________________________________________________________
End
 
 
 |