I can nearly get it to do what I am after, but I get a few pixles that do not turn black, run the code and you'll see what I doing.

type vector2
x as float
y as float
endtype
circ_center as vector2
circ_radius as float
circ_center.x=screen width()/2
circ_center.y=screen height()/2
circ_radius=200.0
`circle circ_center.x,circ_center.y,circ_radius
switch as boolean
switch=0
cur_mode as integer
cur_mode=1
linenum as integer
linenum=12
do
` lock pixels
select cur_mode
case 0
if mousemovex()<>0 and mousemovey()<>0
cls
for x=0 to linenum
point1 as vector2
point2 as vector2
point1.x=rnd(screen width())
point1.y=rnd(screen height())
point2.x=rnd(screen width())
point2.y=rnd(screen height())
circleclip_line(point1,point2,circ_center,circ_radius)
next x
endif
endcase
case 1
cls
for x=0 to linenum
ang#=x*360.0/linenum
point1 as vector2
point2 as vector2
point1.x=mousex()
point1.y=mousey()
point2.x=cos(ang#)*1000+mousex()
point2.y=sin(ang#)*1000+mousey()
circleclip_line(point1,point2,circ_center,circ_radius)
next x
endcase
case 2
cls
for x=0 to linenum
ang#=x*360.0/linenum
point1 as vector2
point2 as vector2
point2.x=mousex()
point2.y=mousey()
point1.x=cos(ang#)*1000+mousex()
point1.y=sin(ang#)*1000+mousey()
circleclip_line(point1,point2,circ_center,circ_radius)
next x
endcase
case 3
cls
perimeter as integer
pos as integer
pos2 as integer
perimeter=screen width()*2+screen height()*2
pos=0
for x=0 to linenum
point1 as vector2
point2 as vector2
point2.x=mousex()
point2.y=mousey()
pos=(x*perimeter)/linenum
if pos>screen width()
dec pos, screen width()
if pos>screen height()
dec pos, screen height()
if pos>screen width()
dec pos, screen width()
point1.x=0
point1.y=screen height()-pos
else
point1.x=screen width()-pos
point1.y=screen height()
endif
else
point1.x=screen width()
point1.y=pos
endif
else
point1.x=pos
point1.y=0
endif
circleclip_line(point1,point2,circ_center,circ_radius)
next x
endcase
case 4
cls
perimeter as integer
pos as integer
pos2 as integer
perimeter=screen width()*2+screen height()*2
pos=0
for x=0 to linenum
point1 as vector2
point2 as vector2
point1.x=mousex()
point1.y=mousey()
pos=(x*perimeter)/linenum
if pos>screen width()
dec pos, screen width()
if pos>screen height()
dec pos, screen height()
if pos>screen width()
dec pos, screen width()
point2.x=0
point2.y=screen height()-pos
else
point2.x=screen width()-pos
point2.y=screen height()
endif
else
point2.x=screen width()
point2.y=pos
endif
else
point2.x=pos
point2.y=0
endif
circleclip_line(point1,point2,circ_center,circ_radius)
next
endcase
endselect
` unlock pixels
if mouseclick()=1 and switch=0
switch=1
cur_mode=(cur_mode+1) mod 5
endif
if mouseclick()=0 then switch=0
sync
loop
end
function circleclip_line(p1 as vector2, p2 as vector2, C as vector2, radius as float)
x21 as float
y21 as float
y1c as float
x1c as float
quad_a as float
quad_b as float
quad_c as float
x21=p2.x-p1.x
x1c=p1.x-C.x
y21=p2.y-p1.y
y1c=p1.y-C.y
quad_a=x21*x21+y21*y21
quad_b=2*(x21*x1c+y21*y1c)
quad_c=y1c*y1c+x1c*x1c-radius*radius
quad_d=y1c*y1c+x1c*x1c-(radius-26)*(radius-26)
d#=sqrt(quad_b*quad_b-4*quad_a*quad_c)
d2#=sqrt(quad_b*quad_b-4*quad_a*quad_d)
t1#=(-quad_b+d#)/(2*quad_a)
t2#=(-quad_b-d#)/(2*quad_a)
t3#=(-quad_b+d2#)/(2*quad_a)
t4#=(-quad_b-d2#)/(2*quad_a)
t#=0
if t1#>=0 and t1#<=1.0
if t2#>=0 and t2#<=1.0
t#=minim(t1#,t2#)
else
t#=t1#
endif
else
if t2#>=0 and t2#<=1.0
t#=t2#
else
t#=1.0
endif
endif
if t3#>=0 and t3#<=1.0
if t4#>=0 and t4#<=1.0
ta#=minim(t3#,t4#)
else
ta#=t3#
endif
else
if t3#>=0 and t3#<=1.0
ta#=t4#
else
ta#=1.0
endif
endif
line p1.x, p1.y, (p2.x-p1.x)*t#+p1.x, (p2.y-p1.y)*t#+p1.y
ink rgb(0,0,0),0
` i =150
` circle t#, d#,i
line p1.x, p1.y, (p2.x-p1.x)*ta#+p1.x, (p2.y-p1.y)*ta#+p1.y
ink rgb(255,255,255),0
endfunction
function minim(x as float, y as float)
if x>y then exitfunction y
endfunction x

Dark Physics makes any hot drink go cold.