Hilbert Curve
Posted: Sun Aug 31, 2014 9:44 am
a space filling curve
using the algorithm from
http://www.vb-helper.com/howto_fractal_ ... curve.html
i have replaced the vb6 line:
picCanvas.Line -Step(dx, dy)
with these PB lines:
LineXY(x0,y0 , x0+dx, y0+dy)
x0 + dx: y0 + dy
ref:
1- http://www.datagenetics.com/blog/march22013/
2- http://www.jasondavies.com/hilbert-curve/
3- http://www.latenightpc.com/blog/archive ... -lua-and-c
4- http://www.ebi.ac.uk/huber-srv/hilbert/
using the algorithm from
http://www.vb-helper.com/howto_fractal_ ... curve.html
i have replaced the vb6 line:
picCanvas.Line -Step(dx, dy)
with these PB lines:
LineXY(x0,y0 , x0+dx, y0+dy)
x0 + dx: y0 + dy
Code: Select all
#SizeH = 800: #SizeV = 600
Global imageNum
Global.l x0, y0
x0 = 20: y0 = 20
Procedure Hilbert(depth.i, dx.f, dy.f)
If depth > 1
Hilbert(depth - 1, dy, dx)
LineXY(x0,y0 , x0+dx, y0+dy)
x0 + dx: y0 + dy
EndIf
If depth > 1
Hilbert(depth - 1, dx, dy)
LineXY(x0,y0 , x0+dy, y0+dx)
x0 + dy: y0 + dx
EndIf
If depth > 1
Hilbert(depth - 1, dx, dy)
LineXY(x0,y0 , x0-dx, y0-dy)
x0 - dx: y0 - dy
EndIf
If depth > 1
Hilbert(depth - 1, -dy, -dx)
EndIf
EndProcedure
CreateImage(2,700,570)
;**************************************************************
OpenWindow(0, 0, 0, #SizeH, #SizeV, "Hilbert Curve", #PB_Window_SystemMenu)
imageNum = CreateImage(#PB_Any, #SizeH, #SizeV, 32)
ImageGadget(0, 10, 10, 0, 0, ImageID(imageNum))
depth.i = 7
If StartDrawing(ImageOutput(imageNum))
Hilbert(depth, 10, 0)
StopDrawing()
SetGadgetState(0, ImageID(imageNum))
EndIf
Repeat: Until WaitWindowEvent(10) = #PB_Event_CloseWindow
1- http://www.datagenetics.com/blog/march22013/
2- http://www.jasondavies.com/hilbert-curve/
3- http://www.latenightpc.com/blog/archive ... -lua-and-c
4- http://www.ebi.ac.uk/huber-srv/hilbert/