View.Set ("graphics:640;640,nobuttonbar")
var ptx, pty : array 1 .. 120 of int
var n : int := 4
var r : real := (6 / 10)
function distance (x1, y1, x2, y2 : real) : real
result ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
end distance
proc drawRegPolygon (n0, a, x02, y02, C : int)
var x, y, x12, y12 : int
x12 := round (a * cosd ((360 / n0) * 0) + x02)
y12 := round (a * sind ((360 / n0) * 0) + y02)
for i : 1 .. n0
x := round (a * cosd ((360 / n0) * i) + x02)
y := round (a * sind ((360 / n0) * i) + y02)
ptx (i) := round (x)
pty (i) := round (y)
drawline (round (x), round (y), x12, y12, C)
x12 := round (x)
y12 := round (y)
end for
drawfillpolygon (ptx, pty, n0, C)
end drawRegPolygon
drawRegPolygon (n, maxx div 3, maxx div 2, maxy div 2, 7)
var screen : array 1 .. maxx, 1 .. maxy of boolean
for x : 1 .. maxx
for y : 1 .. maxy
if whatdotcolor (x, y) not= 0 then
screen (x, y) := true
else
screen (x, y) := false
end if
end for
end for
cls
var x, y, dx, dy : real
loop
x := Rand.Int (0, maxx)
y := Rand.Int (0, maxy)
exit when screen (round (x), round (y)) = true
end loop
drawfillbox (0, 0, maxx, maxy, 7)
for i : 1 .. 100000
if screen (round (x), round (y)) = true then
drawdot (round (x), round (y), 0)
dx := (ptx (Rand.Int (1, n)) - x) * r
dy := (pty (Rand.Int (1, n)) - y) * r
if (x + dx) > 1 and (x + dx) < maxx and (y + dy) > 1 and (y + dy) < maxy then
if screen (round (x + dx), round (y + dy)) then
x := x + dx
y := y + dy
end if
end if
end if
end for
|