Well, I was bored, so I made this:
`press the num keys to change color
`1/white
`2/red
`3/yellow
`4/green
`5/blue
`6/black
`hold ctrl+color key to change backGround
`hold ctrl+click to erase
`press space to clear screen
`scroll mousewheel to change cursor size
sync on
sync rate 0
type col
r as byte
g as byte
b as byte
endtype
global blue as col
global red as col
global green as col
global white as col
global yellow as col
global black as col
blue.b=255
red.r=255
green.g=255
white.r=255 : white.g=255 : white.b=255
yellow.r=255 : yellow.g=255
global currCol as col
currCol=black
global backCol as col
backCol=white
global cursorScale as float
mMake(1,screen width(),screen height()) `background image - should be plain color
mMake(2,screen width(),screen height()) `foreground image - user draws on it, transparent parts are rgb(1,1,1)
mCls(1,cl(backCol))
mCls(2,rgbaa(1,1,1,0))
global temp_x as integer
global temp_y as integer
global lastx as integer
global lasty as integer
global pressedDown as integer
global pressedDown2 as integer
pressedDown=0
do
lock pixels
cls
make image from memblock 1,1
make image from memblock 2,2
paste image 1,0,0,0
sprite 1,0,0,2
box 0,0,10,10,cl(currCol),cl(currCol),cl(currCol),cl(currCol)
cursorScale=cursorScale+mousemovez()/500.0
cursorSize#=exp(cursorScale)
for n=2 to 7
if keystate(n)=1 then setCol(n-1)
next
if (mousex()<11 and mousey()<11) or keystate(17)=1 then drawToolTip("currCol=<"+str$(currCol.r)+"r,"+str$(currCol.g)+"g,"+str$(currCol.b)+"b>\nbackCol=<"+str$(backCol.r)+"r,"+str$(backCol.g)+"g,"+str$(backCol.b)+"b>\nScreen FPS="+str$(screen fps())+"\ntemp=<"+str$(temp_x)+","+str$(temp_y)+">",mousex(),mousey(),1)
if mouseclick()=1
if shiftkey()
if pressedDown=0
pressedDown=1
temp_x=mousex()
temp_y=mousey()
else
bline(temp_x,temp_y,mousex(),mousey(),cursorSize#,cl(currCol))
endif
else
if controlKey()
mCircle(2,mousex(),mousey(),cursorSize#,rgbaa(1,1,1,0))
else
if pressedDown2=0
pressedDown2=1
mCircle(2,mousex(),mousey(),cursorSize#,cl(currCol))
lastx=mousex()
lasty=mousey()
else
mbLine(2,lastx,lasty,mousex(),mousey(),cursorSize#,cl(currCol))
lastx=mousex()
lasty=mousey()
endif
endif
endif
endif
ink cl(currCol),0
if spacekey() then mCls(2,rgb(1,1,1))
if mouseclick()=0 then pressedDown2=0
if mouseclick()=0 and pressedDown=1
mbLine(2,temp_x,temp_y,mousex(),mousey(),cursorSize#,cl(currCol))
pressedDown=0
endif
unlock pixels
circle mousex(),mousey(),cursorSize#
sync
loop
function cl(clrl as col)
a as dword
a=rgb(clrl.r,clrl.g,clrl.b)
endfunction a
function setCol(num as integer)
if num=1 then _setCol(white)
if num=2 then _setCol(red)
if num=3 then _setCol(yellow)
if num=4 then _setCol(green)
if num=5 then _setCol(blue)
if num=6 then _setCol(black)
endfunction
function _setCol(colo as col)
if controlkey()=0
currCol=colo
else
setBackGround(colo)
endif
endfunction
function setBackGround(colo as col)
backCol=colo
mCls(1,cl(backCol))
endfunction
function mMake(mem as byte,width as integer height as integer)
make memblock mem,(width*height*4)+12
write memblock dword mem,0,width
write memblock dword mem,4,height
write memblock dword mem,8,32
endfunction
function mDot(mem as byte,x as integer, y as integer, color as dword)
if x>0 and y>0 and x<memblock dword(mem,0) and y<memblock dword(mem,4) then write memblock dword mem,((y*memblock dword(mem,0))+x)*4+12,color
endfunction
function mCls(mem as byte, color as dword)
for x=0 to memblock dword(mem,0)
for y=0 to memblock dword(mem,4)
mDot(mem,x,y,color)
next
next
endfunction
function mBox(mem as byte, x1 as integer,y1 as integer, x2 as integer,y2 as integer, color as dword)
for x=x1 to x2
for y=y1 to y2
mDot(mem,x,y,color)
next
next
endfunction
REM =========================
REM x1,y1 = starting point
REM x2,y2 = ending poing
REM thick = line thickness
function bline(x1,y1,x2,y2,thick,color as dword)
t# = thick/2.0
dx = x2-x1
dy = y2-y1
`dot x1,y1
box x1-t#,y1-t#,x1+t#,y1+t#
if abs(dx) > abs(dy)
m# = (0.0 + dy)/dx
b# = y1 - m#*x1
if dx < 0
dx = -1
else
dx = 1
endif
while x1 <> x2
x1 = x1 + dx
`dot x1,m#*x1+b#
box x1-t#,(m#*x1+b#)-t#,x1+t#,(m#*x1+b#)+t#
endwhile
else
if dy <> 0
m# = (0.0 + dx)/dy
b# = x1 - m#*y1
if dy < 0
dy = -1
else
dy = 1
endif
while y1 <> y2
y1 = y1 + dy
`dot m#*y1+b#,y1
box (m#*y1+b#)-t#,y1-t#,(m#*y1+b#)+t#,y1+t#
endwhile
endif
endif
endfunction
REM =========================
REM x1,y1 = starting point
REM x2,y2 = ending poing
REM thick = line thickness
function mbline(mem as byte,x1,y1,x2,y2,thick,color as dword)
t# = thick/2.0
dx = x2-x1
dy = y2-y1
`dot x1,y1
mbox(mem,x1-t#,y1-t#,x1+t#,y1+t#,color)
if abs(dx) > abs(dy)
m# = (0.0 + dy)/dx
b# = y1 - m#*x1
if dx < 0
dx = -1
else
dx = 1
endif
while x1 <> x2
x1 = x1 + dx
`dot x1,m#*x1+b#
mbox(mem,x1-t#,(m#*x1+b#)-t#,x1+t#,(m#*x1+b#)+t#,color)
endwhile
else
if dy <> 0
m# = (0.0 + dx)/dy
b# = x1 - m#*y1
if dy < 0
dy = -1
else
dy = 1
endif
while y1 <> y2
y1 = y1 + dy
`dot m#*y1+b#,y1
mbox(mem,(m#*y1+b#)-t#,y1-t#,(m#*y1+b#)+t#,y1+t#,color)
endwhile
endif
endif
endfunction
function mCircle(mem as byte,x as integer,y as integer,r as integer,color as dword)
for yy = y-r to y
for xx = x-r to x
d# = (xx-x)^2 + (yy-y)^2
if d# <= r*r
mbox(mem,xx,yy,x+(x-xx)+1,yy+1,color)
if yy <> y then mBox(mem,xx,y+(y-yy),x+(x-xx)+1,y+(y-yy)+1,color)
exit
endif
next xx
next yy
endfunction
REM ============================================
REM Draws a tool tip box. The string may contain
REM any number of '\n' (newline) switches.
REM The 'corner' parameter states where the tool
REM tip should be draw in relation to the given
REM [X, Y] coordinates.
REM Corner 1 = top right
REM Corner 2 = top left
REM Corner 3 = bottom right
REM Corner 4 = bottom left
REM ============================================
function drawToolTip(s$, x, y, corner)
maxWidth = 0
lines = 0
b = 0
for i = 2 to len(s$)
if mid$(s$,i-1)+mid$(s$,i) = "\n" or i = len(s$)
t$ = left$(s$, i-((i<len(s$))*2))
t$ = right$(t$, len(t$)-b)
b = i
inc i
inc lines
w = text width(t$)
if w > maxWidth then maxWidth = w
endif
next i
if corner = 2 || corner = 4 then ox = -(maxWidth+6)
if corner = 3 || corner = 4 then oy = lines*-16
rem tooltip background
ink rgb(228,219,195),0
box x+ox, y+oy, x+maxWidth+6+ox, y+lines*16+oy
ink 0,0
b = 0
row = 0
for i = 2 to len(s$)
if mid$(s$,i-1)+mid$(s$,i) = "\n" or i = len(s$)
t$ = left$(s$, i-((i<len(s$))*2))
text x+3+ox, y+row*16+oy, right$(t$, len(t$)-b)
b = i
inc i
inc row
endif
next i
rem tooltip outline
box x+ox, y+oy, x+ox+1, y+lines*16+oy
box x+maxWidth+5+ox, y+oy, x+maxWidth+6+ox, y+lines*16+oy
box x+ox, y+oy, x+maxWidth+6+ox, y+oy+1
box x+ox, y+lines*16+oy-1, x+maxWidth+6+ox, y+lines*16+oy
endfunction
`RGBA function by Aaron Miller
function rgbaa(r,g,b,a)
c = (a and 0xff) << 24 or ((r and 0xff) << 16) or ((g and 0xff) << 8) or (b and 0xff)
endfunction c
it uses a lot of code from the codebase. Namely:
phalaex's multi-line tooltips (mouseover the box in the upper left hand corner for random info used during debugging... though the info isn't too useful), phalaex's line with thickness, phalaex's circle function, some heavily modded code from syncaidus's image manipulation functions, and aaron millers rgba function (renamed).
After I made that, I made this. enjoy.
[edit]
oh, I should also explain the controls o.O
numbers 1 through 6 to change the drawing color, ctrl+num to change the background color, shift+drag to draw a line of color, and ctrl+click to erase.
Is't life, I ask, is't even prudence, to bore thyself and bore thy students?