76 lines
1.7 KiB
Text
76 lines
1.7 KiB
Text
//
|
|
// SIERPINSKY ARROWHEAD CURVES
|
|
//
|
|
// FutureBasic 7.0.34, August 2025 R.W.
|
|
//
|
|
|
|
double direction, myorder, mysixty
|
|
CGFloat red, green, blue
|
|
colorref Colr
|
|
double xpos, ypos
|
|
|
|
// Create main window
|
|
|
|
void local fn BuildMainWindow(wTag as NSInteger)
|
|
colorref wco
|
|
CGRect r
|
|
SInt32 wndStyleMask
|
|
wco = fn ColorBlack
|
|
wndStyleMask = NSWindowStyleMaskTitled
|
|
wndStyleMask += NSWindowStyleMaskClosable
|
|
r = fn CGRectMake( 0, 0, 560, 540 )
|
|
window wTag, @" Sierpinsky Arrowhead Curves ", r, wndStyleMask
|
|
WindowSetBackgroundColor(wTag, wco)
|
|
ViewSetFlipped( _WindowContentViewTag, YES )
|
|
windowcenter (wTag)
|
|
AppSetAppearance(fn AppearanceNamed(NSAppearanceNameDarkAqua))
|
|
end fn
|
|
|
|
// Draw the arrowhead recursively
|
|
|
|
local fn ArrowHead ( order as int, length as double, myangle as Int)
|
|
|
|
red = 0.55
|
|
green = 0.75
|
|
blue = 0.00
|
|
|
|
Colr = fn ColorWithRGB(red,green,blue,1.0)
|
|
pen 2, Colr
|
|
|
|
if order == 0
|
|
xpos = xpos + length * cos(Direction)
|
|
ypos = ypos + length * sin(Direction)
|
|
line xpos, ypos
|
|
Oval fill (xpos, ypos, 1, 1),Colr
|
|
else
|
|
fn ArrowHead (order - 1, length / 2.0, -myangle)
|
|
Direction = Direction + myangle
|
|
fn ArrowHead(order - 1, length / 2.0, +myangle)
|
|
Direction = Direction + myangle
|
|
fn ArrowHead(order - 1, length / 2.0, -myangle)
|
|
end if
|
|
end fn
|
|
//
|
|
// Main
|
|
|
|
fn BuildMainWindow(1)
|
|
|
|
myorder = 5
|
|
Direction = -PI/3 // base flat on the bottom, tip on the top
|
|
xpos = 560 / 3 - 90
|
|
ypos = 540 / 2 +160
|
|
mysixty = PI / 3
|
|
line xpos, ypos
|
|
|
|
// 5 recursion depth, 200 starting length,
|
|
// rotated 180/3 = 60 degrees
|
|
|
|
if (myorder AND 1) == 0
|
|
fn ArrowHead (5, 320, + mysixty)
|
|
else
|
|
Direction = Direction + mysixty
|
|
fn ArrowHead (5, 320, - mysixty)
|
|
end if
|
|
|
|
|
|
handleEvents
|