I MA3d a function to draw arrows.
Rem Project: Dark Basic Pro Project
Rem Created: Saturday, August 07, 2010
Rem ***** Main Source File *****
for n=0 to 10
drawArrow(rnd(screen width()),rnd(screen height()),rnd(screen width()),rnd(screen height()),10)
next
sync
wait key
end
function drawArrow(fromx,fromy,tox,toy,size)
line fromx,fromy,tox,toy
//type 1, box
`box tox-size/2,toy-size/2,tox+size/2,toy+size/2
//type 2, arrow
x=fromx-tox
y=fromy-toy
d#=sqrt(x*x+y*y)
x2#=x/d#
y2#=y/d# `<x1#,x2#> is just the direction from <tox,toy> to <fromx,fromy>
line tox,toy,tox+size*0.707106781*(x2#-y2#),toy+size*0.707106781*(x2#+y2#) `trig? I don't need no stinkin trig!
line tox,toy,tox+size*0.707106781*(y2#+x2#),toy+size*0.707106781*(y2#-x2#)
//type 3, circle
`circle tox,toy,size/2
endfunction
if you're wondering what that weird code is for the arrow drawing... well... I didn't want to use trig (bored n' I like math). It actually isn't as complicated as it looks. These two vectors
are unit vectors at 45 degree angles to vector B, so we define vector B to be <fromx-tox,fromy-toy>, and then normalize it. Thats all that that gibberish is doing.
Is't life, I ask, is't even prudence, to bore thyself and bore thy students?