44 lines
1.5 KiB
Text
44 lines
1.5 KiB
Text
_window = 1
|
|
_curveSize = 7
|
|
_curveOrder = 3 * 3 * 3 * 3 // 3^4
|
|
|
|
void local fn BuildWindow
|
|
CGRect r = fn CGRectMake( 0, 0, 565, 570 )
|
|
window _window, @"Peano Curve In FutureBasic", r, NSWindowStyleMaskTitled
|
|
WindowSetBackgroundColor( _window, fn ColorBlack )
|
|
end fn
|
|
|
|
local fn Peano( x as long, y as long, lg as long, i1 as long, i2 as long )
|
|
ColorRef color = fn ColorRed
|
|
|
|
if ( lg == 1 ) then line to x * _curveSize, y * _curveSize : exit fn
|
|
lg /= 3
|
|
|
|
select ( rnd(8) )
|
|
case 1 : color = fn ColorBrown
|
|
case 2 : color = fn ColorRed
|
|
case 3 : color = fn ColorOrange
|
|
case 4 : color = fn ColorYellow
|
|
case 5 : color = fn ColorGreen
|
|
case 6 : color = fn ColorBlue
|
|
case 7 : color = fn ColorPurple
|
|
case 8 : color = fn ColorWhite
|
|
end select
|
|
|
|
pen 2, color
|
|
fn Peano( x + 2*i1* lg, y + 2*i1* lg, lg, i1, i2 )
|
|
fn Peano( x + (i1-i2+1)*lg, y + (i1+i2)* lg, lg, i1, 1-i2 )
|
|
fn Peano( x + lg, y + lg, lg, i1, 1-i2 )
|
|
fn Peano( x + (i1+i2)* lg, y + (i1-i2+1)*lg, lg, 1-i1, 1-i2 )
|
|
fn Peano( x + 2*i2* lg, y + 2*(1-i2)* lg, lg, i1, i2 )
|
|
fn Peano( x + (1+i2-i1)*lg, y + (2-i1-i2)*lg, lg, i1, i2 )
|
|
fn Peano( x + 2*(1-i1)* lg, y + 2*(1-i1)* lg, lg, i1, i2 )
|
|
fn Peano( x + (2-i1-i2)*lg, y + (1+i2-i1)*lg, lg, 1-i1, i2 )
|
|
fn Peano( x + 2*(1-i2)* lg, y + 2*i2* lg, lg, 1-i1, i2 )
|
|
end fn
|
|
|
|
randomize
|
|
fn BuildWindow
|
|
fn Peano( 0, 0, _curveOrder, 0, 0 )
|
|
|
|
HandleEvents
|