Jump to content

Integrating LW flowgraph in my app


Vida Marcell
 Share

Recommended Posts

The flowgraph code is part of the editor, not part of the engine API, but it's using bezier curves and the regular line-drawing routines.

	Method InterpolateCurve(f:Float,x0:Int,y0:Int,x1:Int,y1:Int, px:Float Var,py:Float Var)
		Local curve:Float
		Local m:Float
		Local dx:Float = x1-x0
		Local dy:Float = y1-y0
		m=Sqr(dx*dx+dy*dy)
		curve = m*0.5
		calcbezier f,x0,y0,x0+curve,y0,x1,y1,x1-curve,y1,px,py
	EndMethod
	
	Function CalcBezier(f#,x1:Float,y1:Float,vx1:Float,vy1:Float,x2:Float,y2:Float,vx2:Float,vy2:Float,px# Var ,py# Var)
		Local t:Float,lx:Float,ly:Float
		Local pointx:Float,pointy:Float
		Local steps:Float=20
		'For Local i:Int=0 To steps+1't#=0 To 1 Step 0.25'0.05
			't=1.0/(steps+1)*Float(i)
			t=f
			pointx# = x1*(1.0-t)^3.0 + 3.0*vx1*(1.0-t)^2.0*t + 3.0*vx2*(1.0-t)*t^2.0 + x2*t^3.0
			pointy# = y1*(1.0-t)^3.0 + 3.0*vy1*(1.0-t)^2.0*t + 3.0*vy2*(1.0-t)*t^2.0 + y2*t^3.0
			px=pointx
			py=pointy
		'Next
	EndFunction		
		
	Method DrawCurve(x0:Int,y0:Int,x1:Int,y1:Int)
		Local curve:Float
		Local m:Float
		Local dx:Float = x1-x0
		Local dy:Float = y1-y0
		m=Sqr(dx*dx+dy*dy)
		curve = m*0.5
		drawbezier x0,y0,x0+curve,y0,x1,y1,x1-curve,y1
	EndMethod

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

7 hours ago, Josh said:

The flowgraph code is part of the editor, not part of the engine API, but it's using bezier curves and the regular line-drawing routines.


	Method InterpolateCurve(f:Float,x0:Int,y0:Int,x1:Int,y1:Int, px:Float Var,py:Float Var)
		Local curve:Float
		Local m:Float
		Local dx:Float = x1-x0
		Local dy:Float = y1-y0
		m=Sqr(dx*dx+dy*dy)
		curve = m*0.5
		calcbezier f,x0,y0,x0+curve,y0,x1,y1,x1-curve,y1,px,py
	EndMethod
	
	Function CalcBezier(f#,x1:Float,y1:Float,vx1:Float,vy1:Float,x2:Float,y2:Float,vx2:Float,vy2:Float,px# Var ,py# Var)
		Local t:Float,lx:Float,ly:Float
		Local pointx:Float,pointy:Float
		Local steps:Float=20
		'For Local i:Int=0 To steps+1't#=0 To 1 Step 0.25'0.05
			't=1.0/(steps+1)*Float(i)
			t=f
			pointx# = x1*(1.0-t)^3.0 + 3.0*vx1*(1.0-t)^2.0*t + 3.0*vx2*(1.0-t)*t^2.0 + x2*t^3.0
			pointy# = y1*(1.0-t)^3.0 + 3.0*vy1*(1.0-t)^2.0*t + 3.0*vy2*(1.0-t)*t^2.0 + y2*t^3.0
			px=pointx
			py=pointy
		'Next
	EndFunction		
		
	Method DrawCurve(x0:Int,y0:Int,x1:Int,y1:Int)
		Local curve:Float
		Local m:Float
		Local dx:Float = x1-x0
		Local dy:Float = y1-y0
		m=Sqr(dx*dx+dy*dy)
		curve = m*0.5
		drawbezier x0,y0,x0+curve,y0,x1,y1,x1-curve,y1
	EndMethod

 

I know that, that is why i was asking, so thanks Josh

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...