Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Util/Spline Test
This example is the version from Sat, 23th Oct 2015.
Project "Spline Test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
EventHandler Sub Open()
x.Append 0.0
y.Append 0.0
x.Append 30.0
y.Append 0.5
x.Append 60.0
y.Append 0.866
x.Append 90.0
y.Append 1.0
s = new SplineMBS(x,y)
'for i as double = 10 to 100 step 10
'dim v as Double = s.calc(i)
'
'System.DebugLog str(i)+": "+str(v)
'
'next
'break
End EventHandler
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect)
dim fw as Double = (Width-100) / 100.0
dim fh as Double = g.Height-100
dim x1,y1 as Double
dim dx as integer = 50
dim dy as integer = g.Height - 50
g.ForeColor = &c777777
g.DrawLine 0, dy, g.Width, dy
g.DrawLine dx, 00, dx, g.Height
g.ForeColor = &c000000
x1 = 0
y1 = s.calc(0)
for i as integer = -10 to 110 step 2
dim x2 as Double = i
dim y2 as Double = s.calc(x2)
g.DrawLine dx + (fw * x1), dy - (y1 * fh), dx + (fw * x2), dy - (y2 * fh)
x1 = x2
y1 = y2
next
g.ForeColor = &cFF0000
dim u as integer = UBound(x)
for i as integer = 0 to u
dim px as integer = dx + (fw * x(i))
dim py as integer = dy - (fh * y(i))
g.DrawLine px-5, py-5, px+5, py+5
g.DrawLine px+5, py-5, px-5, py+5
next
End EventHandler
Property s As SplineMBS
Property x() As Double
Property y() As Double
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
End Project
The items on this page are in the following plugins: MBS Util Plugin.