Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
25
Task/Sierpinski-carpet/FutureBasic/sierpinski-carpet.basic
Normal file
25
Task/Sierpinski-carpet/FutureBasic/sierpinski-carpet.basic
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
local fn IsInCarpet( x as NSUInteger, y as NSUInteger ) as BOOL
|
||||
while ( x != 0 && y != 0 )
|
||||
if ( x % 3 == 1 && y % 3 == 1 ) then return NO
|
||||
y /= 3 : x /= 3
|
||||
wend
|
||||
end fn = YES
|
||||
|
||||
void local fn SierpinskiCarpet( n as NSUInteger )
|
||||
NSUInteger i, j, k = fn pow(3,n) - 1
|
||||
pen -1
|
||||
for i = 0 to k
|
||||
for j = 0 to k
|
||||
ColorRef col = fn ColorOrange
|
||||
if ( fn IsInCarpet(i,j) )
|
||||
col = fn ColorRed
|
||||
end if
|
||||
rect fill (i * 10, j * 10, 10, 10 ), col
|
||||
next
|
||||
next
|
||||
end fn
|
||||
|
||||
window 1, @"Sierpinski Carpet", (0,0,270,270), NSWindowStyleMaskTitled
|
||||
fn SierpinskiCarpet(3)
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue