I managed to delete MS Paint
So I amde this. It's not done, and I don't know if I could be bothered to finish it. But here it is anyway, you may not want the paint program, but it has some really good 2D GUI used in it that you could use, including buttons, menu, labels, tabs, sliders (vertical and horizontal), and umm.. well that's it...
Here you go,
`**Paint Program**
sync on : sync rate 60
set display mode 1024,768,16
set window on : maximize window
`==============
`Setup Types
`==============
`setup program
dim imgtaken(65535) as boolean
`setup floodfill
type __FloodFillType
Initialised as integer
CoverColour as integer
BitmapWidth as integer
BitmapHeight as integer
endtype
global __FloodFillGlobal as __FloodFillType
#constant __SpanListSize 15
type __FillSpan
Left as integer
Right as integer
endtype
global dim __FilledSpans() as __FillSpan
global dim __FilledSpansCount() as integer
`setup draw-board
type _DrawBoardType
x1 as integer
x2 as integer
y1 as integer
y2 as integer
col
endtype
Global _DrawBoard as _DrawBoardType
`setup buttons
type _ButtonType
x as integer
y as integer
sx as integer
sy as integer
capt as string
col1 as integer
col2 as integer
img1 as integer
img2 as integer
img3 as integer
state as integer
tab as integer
tabpage as integer
tabassigned as boolean
show as boolean
visible as boolean
endtype
dim _Button(0) as _ButtonType
`setup labels
type _labelType
x as integer
y as integer
w as integer
h as integer
l as integer
s as string
i as integer
show as boolean
tab as integer
tabpage as integer
tabassigned as boolean
endtype
dim _label(0) as _labelType
`setup menustrip
type _MenuType
x as integer
name as string
active as boolean
width as integer
height as integer
count as integer
endtype
type _MenuItemType
parent as integer
item as string
endtype
type _menuselectType
m as integer
i as integer
endtype : global _menuselect as _menuselectType
dim _menu(0) as _menuType
dim _menuitem(100,100) as string
`setup sliders
type _vslidertype
x as integer
y as integer
height as integer
slide as integer
show as boolean
visible as boolean
tab as integer
tabpage as integer
tabassigned as boolean
endtype
dim _vslider(0) as _vslidertype
type _hslidertype
x as integer
y as integer
length as integer
slide as integer
show as boolean
visible as boolean
tab as integer
tabpage as integer
tabassigned as boolean
endtype
dim _hslider(0) as _hslidertype
`setup tabs
type _tabtype
x as integer
y as integer
sx as integer
sy as integer
pages as integer
show as boolean
endtype
type _tabpagetype
x as integer
width as integer
tab as string
selected as boolean
endtype
dim _tab(0) as _tabtype
dim _tabpage(100,100) as _tabpagetype
`setup colours
type _colortype
r as integer
g as integer
b as integer
col as integer
endtype
global _color as _colortype
`===========================================================================================
`===================
`Create Draw Area
`===================
set text font "tahoma" : set text size 16 : set text to normal
`make drawBoard
setDrawBoard(100,170,screen width()-4,screen height()-4,rgb(200,200,200))
`make tools
global _tool=1
addLabel(10,30,"Tools:",80)
addButton(10,50,80,20,"Pencil",rgb(255,255,255),rgb(192,192,192))
addButton(100,50,80,20,"Brush",rgb(255,255,255),rgb(192,192,192))
addButton(190,50,80,20,"Fill",rgb(255,255,255),rgb(192,192,192))
addButton(280,50,80,20,"Line",rgb(255,255,255),rgb(192,192,192))
addButton(370,50,80,20,"Spray",rgb(255,255,255),rgb(192,192,192))
addButton(460,50,80,20,"Extract",rgb(255,255,255),rgb(192,192,192))
`tool options--
addLabel(10,90,"Tool Options:",200)
`brush
tab_brush=addTab(10,130,screen width()-20,30) : addTabPage(1,"Size") : addTabPage(1,"Style")
tls_brsize=addLabel(15,138,"Brushsize:",200) : hsldbrsize=addHSlider(100,145,100) : setHSliderValue(hsldbrsize,20)
setLabelTab(tls_brsize,1,1) : setHSliderTab(hsldbrsize,1,1)
brsh_sq=addButton(15,135,80,20,"Square",rgb(255,255,255),rgb(192,192,192)) : setButtonTab(brsh_sq,1,2)
brsh_cr=addButton(100,135,80,20,"Circle",rgb(255,255,255),rgb(192,192,192)) : setButtonTab(brsh_cr,1,2)
_brushstyle=1
`line
tab_line=addTab(10,130,screen width()-20,30) : addtabPage(2,"Thickness")
tls_lnthk=addLabel(15,138,"Thickness:",200) : hsldlnthk=addHSlider(100,145,50) : setHSliderValue(hsldlnthk,10)
setLabelTab(tls_lnthk,2,1) : setHSliderTab(hsldlnthk,2,1)
`spray
tab_spray=addTab(10,130,screen width()-20,30) : addTabPage(3,"Radius") : addTabPage(3,"Intensity")
tls_sprr=addLabel(15,138,"Radius:",200) : hsldsprd=addHSlider(100,145,500) : setHSliderValue(hsldsprd,250)
tls_spri=addLabel(15,138,"Intensity:",200) : hsldspin=addHSlider(100,145,50) : setHSliderValue(hsldspin,30)
setlabelTab(tls_sprr,3,1) : setHSliderTab(hsldsprd,3,1)
setlabelTab(tls_spri,3,2) : setHSliderTab(hsldspin,3,2)
`menustrip
addMenu("File")
addMenu("Edit")
addMenu("View")
addMenuItem(1,"New")
addMenuItem(1,"Open")
addMenuItem(1,"Save")
addMenuItem(1,"Save As")
addMenuItem(1,"Exit")
addMenuItem(2,"Undo")
addMenuItem(2,"Redo")
addMenuItem(2,"Cut")
addMenuItem(2,"Copy")
addMenuItem(2,"Paste")
addMenuItem(3,"Flip/Rotate")
addMenuItem(3,"Options")
`colors
addLabel(10,295,"Colour: ",80)
addLabel(5,315,"R",50) : addVSlider(10,345,255) : setVSliderValue(1,255)
addLabel(35,315,"G",50) : addVSlider(40,345,255) : setVSliderValue(2,255)
addLabel(65,315,"B",50) : addVSlider(70,345,255) : setVSliderValue(3,255)
`draw
createButtons() : createLabels()
`main loop
do
`mouse data
if mouseclick() then _mouseclicked=1
if _mouseclicked
_oldmx=_mx : _oldmy=_my
else
_oldmx=mousex() : _oldmy=mousey()
endif
if mousex()>_drawBoard.x1 and mousex()<_drawBoard.x2 and mousey()>_drawBoard.y1 and mousey()<_drawBoard.y2
_indrawarea=1
else
_indrawarea=0
endif
`Draw Board
handleDrawBoard()
`colour selection
_color.r=getVSliderValue(1) : _color.g=getVSliderValue(2) : _color.b=getVSliderValue(3)
_color.col=rgb(_color.r,_color.g,_color.b)
ink _color.col,0 : box 5,620,75,670
ink 0,0
line 5,620,75,620 : line 5,620,5,670
line 5,670,75,670 : line 75,620,75,670
center text 10,600,str$(_color.r)
center text 40,600,str$(_color.g)
center text 70,600,str$(_color.b)
`handle GUI
handleTabs()
handleButtons()
handleLabels()
handleMenus()
handleVSliders()
handleHSliders()
`tools
if buttonClicked(1) then _tool=1
if buttonClicked(2) then _tool=2
if buttonClicked(3) then _tool=3
if buttonClicked(4) then _tool=4
if buttonClicked(5) then _tool=5
if buttonClicked(6) then _tool=6
`tool options
if _tool=2
_brushsize=int(getHSliderValue(hsldbrsize)/10)
if tabPageSelected(1,1) then ink 0,0 : text 210,140,str$(_brushsize)
showTab(tab_brush)
else
hideTab(tab_brush)
endif
if buttonClicked(brsh_sq) then _brushstyle=1
if buttonClicked(brsh_cr) then _brushstyle=2
if _tool=4
_linethick=int(getHSliderValue(hsldlnthk)/10)
if tabPageSelected(2,1) then ink 0,0 : text 210,140,str$(_linethick)
showTab(tab_line)
else
hideTab(tab_line)
endif
if _tool=5
_sprayrad=int(getHSliderValue(hsldsprd)/10)
_sprayint=int(getHSliderValue(hsldspin)/10)
if tabPageSelected(3,1) then ink 0,0 : text 660,140,str$(_sprayrad)
if tabPageSelected(3,2) then ink 0,0 : text 160,140,str$(_sprayint)
showTab(tab_spray)
else
hideTab(tab_spray)
endif
`pencil
if _indrawarea
if _tool=1
ink _color.col,0
if mouseclick()=1
_mx=mousex() : _my=mousey()
ink _color.col,0 : line _oldmx,_oldmy,_mx,_my
endif
endif
endif
`brush
if _indrawarea
if _tool=2
ink _color.col,0
if mouseclick()=1
if _brushstyle=1 then box mousex()-_brushsize,mousey()-_brushsize,mousex()+_brushsize,mousey()+_brushsize
if _brushstyle=2 then circ(mouseX(),mousey(),_brushsize*2,_brushsize*2)
endif
endif
endif
`fill
if _indrawarea
if _tool=3
if mouseclick()=1
FloodFill(mousex(),mousey(),_color.col)
endif
endif
endif
`line
if _indrawarea
if _tool=4
if mouseclick()=1
linex1=mousex() : liney1=mousey()
inc _lntime
linex2=-mousemovex()+mousex() : liney2=-mousemovey()+mousey()
ink _color.col,0 : line linex1,liney1,linex2,liney2
endif
endif
endif
`spray
if _indrawarea
if _tool=5
if mouseclick()
_sprayx=mousex()+(rnd(_sprayrad)-(_sprayrad/2)) : _sprayy=mousey()+(rnd(_sprayrad)-(_sprayrad/2))
ink _color.col,0
for i=1 to _sprayint
cdot(_sprayx,_sprayy)
next i
endif
endif
endif
`extract
if _indrawarea
if _tool=6
if mouseclick()=1
setVSliderValue(1,rgbr(point(mousex(),mousey())))
setVSliderValue(2,rgbg(point(mousex(),mousey())))
setVSliderValue(3,rgbb(point(mousex(),mousey())))
endif
endif
endif
`handle menu
if checkMenuItem(1,1) and mouseclick() then ink 0,0 : box _drawBoard.x1,_drawBoard.y1,_drawBoard.x2,_drawBoard.y2
if checkMenuItem(1,5) then end
sync
loop
`============
`Functions
`============
`drawboard
function setDrawBoard(x1,y1,x2,y2,col)
_DrawBoard.x1=x1 : _DrawBoard.y1=y1
_DrawBoard.x2=x2 : _DrawBoard.y2=y2
_DrawBoard.col=col
endfunction
function handleDrawBoard()
ink _drawBoard.col,rgb(255,255,255)
box 0,0,_drawBoard.x1,screen height()
box 0,0,screen width(),_drawBoard.y1
box 0,_drawBoard.y2,screen width(),screen height()
box _drawBoard.x2,0,screen width(),screen height()
endfunction
`gui--
function addTab(x,y,sx,sy)
local num as integer
array insert at bottom _tab()
num=array count(_tab())
_tab(num).x=x : _tab(num).y=y
_tab(num).sx=sx : _tab(num).sy=sy
endfunction num
function addTabPage(prnt,tab as string)
local i as integer
_tab(prnt).pages=_tab(prnt).pages+1
i=_tab(prnt).pages
_tabpage(prnt,1).selected=1
_tabpage(prnt,i).tab=tab
_tabpage(prnt,i).width=text width(tab)+10
_tabpage(prnt,i).x=_tab(prnt).x+((_tabpage(prnt,i).width*i)-_tabpage(prnt,i).width)
endfunction
function handleTabs()
local num as integer : num=array count(_tab())
for t=1 to num
ink rgb(255,255,255),0
if _tab(t).show then box _tab(t).x,_tab(t).y,_tab(t).x+_tab(t).sx,_tab(t).y+_tab(t).sy
for i=1 to _tab(t).pages
if _tab(t).show
ink rgb(255,255,255),0
box _tabpage(t,i).x,_tab(t).y-20,_tabpage(t,i).x+(_tabpage(t,i).width),_tab(t).y
ink 0,0
text _tabpage(t,i).x+3,_tab(t).y-17,_tabpage(t,i).tab
endif
if mousex()>_tabpage(t,i).x and mousex()<_tabpage(t,i).x+(_tabpage(t,i).width) and mousey()>_tab(t).y-20 and mousey()<_tab(t).y and mouseclick()
for it=1 to _tab(t).pages
_tabpage(t,it).selected=0
next it
_tabpage(t,i).selected=1
endif
if _tabpage(t,i).selected and _tab(t).show
ink rgb(252,171,3),0
box _tabpage(t,i).x,_tab(t).y-20,_tabpage(t,i).x+_tabpage(t,i).width,_tab(t).y-17
endif
next i
next t
endfunction
function tabPageSelected(t,i)
if _tabpage(t,i).selected then exitfunction 1
endfunction 0
function showTab(t)
_tab(t).show=1
endfunction
function hideTab(t)
_tab(t).show=0
endfunction
function addVSlider(x,y,h)
local num as integer
array insert at bottom _vslider()
num=array count(_vslider())
_vslider(num).x=x : _vslider(num).y=y
_vslider(num).height=h+2
endfunction num
function handleVSliders()
local num as integer : num=array count(_vslider())
for s=1 to num
if _vslider(s).visible
if mousex()>_vslider(s).x-5 and mousex()<_vslider(s).x+5 and mousey()>_vslider(s).y and mousey()<_vslider(s).y+_vslider(s).height
if mouseclick() then _vslider(s).slide=mousey()-_vslider(s).y-1
endif
endif
if _vslider(s).show
if _vslider(s).tabassigned
if tabPageSelected(_vslider(s).tab,_vslider(s).tabpage) and _tab(_vslider(s).tab).show
ink rgb(150,150,150),0 : box _vslider(s).x-1,_vslider(s).y,_vslider(s).x+1,_vslider(s).y+_vslider(s).height
ink rgb(100,100,100),0 : box _vslider(s).x-5,(_vslider(s).y+_vslider(s).slide)-2,_vslider(s).x+5,(_vslider(s).y+_vslider(s).slide)+2
_vslider(s).visible=1
else
_vslider(s).visible=0
endif
else
ink rgb(150,150,150),0 : box _vslider(s).x-1,_vslider(s).y,_vslider(s).x+1,_vslider(s).y+_vslider(s).height
ink rgb(100,100,100),0 : box _vslider(s).x-5,(_vslider(s).y+_vslider(s).slide)-2,_vslider(s).x+5,(_vslider(s).y+_vslider(s).slide)+2
_vslider(s).visible=1
endif
endif
if _vslider(s).show=0 then _vslider(s).visible=0
showVSlider(s)
next s
endfunction
function getVSliderValue(num)
local value as integer
value=_vslider(num).slide
endfunction value
function setVSliderValue(num,value)
_vslider(num).slide=value
endfunction
function showVSlider(num)
_vslider(num).show=1
endfunction
function hideVSlider(num)
_vslider(num).show=0
endfunction
function setVSliderTab(s,t,p)
_vslider(s).tabassigned=1
_vslider(s).tab=t : _vslider(s).tabpage=p
endfunction
function addHSlider(x,y,l)
local num as integer
array insert at bottom _hslider()
num=array count(_hslider())
_hslider(num).x=x : _hslider(num).y=y
_hslider(num).length=l+2
endfunction num
function handleHSliders()
local num as integer : num=array count(_hslider())
for s=1 to num
if _hslider(s).visible=1
if mousey()>_hslider(s).y-5 and mousey()<_hslider(s).y+5 and mousex()>_hslider(s).x and mousex()<_hslider(s).x+_hslider(s).length
if mouseclick() then _hslider(s).slide=mousex()-_hslider(s).x-1
endif
endif
if _hslider(s).show
if _hslider(s).tabassigned
if tabPageSelected(_hslider(s).tab,_hslider(s).tabpage) and _tab(_hslider(s).tab).show
ink rgb(150,150,150),0 : box _hslider(s).x,_hslider(s).y-1,_hslider(s).x+_hslider(s).length,_hslider(s).y+1
ink rgb(100,100,100),0 : box (_hslider(s).x+_hslider(s).slide)-2,_hslider(s).y-5,(_hslider(s).x+_hslider(s).slide)+2,_hslider(s).y+5
_hslider(s).visible=1
else
_hslider(s).visible=0
endif
else
ink rgb(150,150,150),0 : box _hslider(s).x,_hslider(s).y-1,_hslider(s).x+_hslider(s).length,_hslider(s).y+1
ink rgb(100,100,100),0 : box (_hslider(s).x+_hslider(s).slide)-2,_hslider(s).y-5,(_hslider(s).x+_hslider(s).slide)+2,_hslider(s).y+5
_hslider(s).visible=1
endif
endif
if _hslider(s).show=0 then _hslider(s).visible=0
showHSlider(s)
next s
endfunction
function getHSliderValue(num)
local value as integer
value=_hslider(num).slide
endfunction value
function setHSliderValue(num,value)
_hslider(num).slide=value
endfunction
function showHSlider(num)
_hslider(num).show=1
endfunction
function hideHSlider(num)
_hslider(num).show=0
endfunction
function setHSliderTab(s,t,p)
_hslider(s).tabassigned=1
_hslider(s).tab=t : _hslider(s).tabpage=p
endfunction
function addMenu(txt as string)
local num as integer
array insert at bottom _menu()
num=array count(_menu())
_menu(num).name=txt
_menu(num).x=(num*100)-90
endfunction num
function addMenuItem(parent, item as string)
local i as integer
_menu(parent).count=_menu(parent).count+1
i=_menu(parent).count
_menuitem(parent,i)=item
_menu(parent).height=(text size()+2)*i
width=text width(item)+(text size()/2)+10
if width>_menu(parent).width then _menu(parent).width=width
endfunction
function handleMenus()
local num as integer : num=array count(_menu())
ink rgb(155,155,155),0 : box 0,0,screen width(),20
ink rgb(0,0,0),0 : line 0,20,screen width(),20
for m=1 to num
ink rgb(0,0,0),0 : text _menu(m).x,3,_menu(m).name
if mousex()>_menu(m).x and mousex()<_menu(m).x+100 and mouseclick()
_menu(m).active=1
endif
if mousey()>20
if mouseclick()
_menu(m).active=0
endif
endif
if mousex()<_menu(m).x or mousex()>_menu(m).x+100
if mousey()<20
_menu(m).active=0
endif
endif
if _menu(m).active=1
ink rgb(155,155,155),0 : box _menu(m).x,20,_menu(m).x+_menu(m).width,_menu(m).height+20
ink rgb(0,0,0),0
line _menu(m).x,20,_menu(m).x,_menu(m).height+20
line _menu(m).x+_menu(m).width,20,_menu(m).x+_menu(m).width,_menu(m).height+20
line _menu(m).x,_menu(m).height+20,_menu(m).x+_menu(m).width,_menu(m).height+20
line _menu(m).x,20,_menu(m).x+_menu(m).width,20
mshow=m
endif
for i=1 to _menu(m).count
if _menu(m).active=1
if mousey()>(((text size()+2)*i)-text size())+20 and mousey()<((text size()+2)*i)+20 and mousex()>_menu(m).x and mousex()<_menu(m).x+_menu(m).width
ink rgb(0,128,255),0
box _menu(m).x+2,(((text size()+2)*i)-text size())+20,(_menu(m).x+_menu(m).width)-2,((text size()+2)*i)+20
_menuselect.m=m : _menuselect.i=i
endif
ink rgb(0,0,0),0 : text _menu(m).x+10,(((text size()+2)*i)-(text size()+2))+20,_menuitem(m,i)
endif
next i
next m
endfunction
function checkMenuItem(m,i)
if _menuselect.m=m and _menuselect.i=i and mouseclick() then exitfunction 1
endfunction 0
function addLabel(x,y,s as string,w)
local num as integer
array insert at bottom _label()
num=array count(_label())
_label(num).x=x : _label(num).y=y
_label(num).s=s : _label(num).w=w
_label(num).i=freeimage()
endfunction num
function createLabels()
num=array count(_label())
for l=1 to num
_label(l).l=totalLines(_label(l).w,_label(l).s) : _label(l).h=_label(l).l*text size()
create bitmap 1,_label(l).w,_label(l).h : set current bitmap 1
for ln=1 to _label(l).l
ink rgb(20,20,20),0
text 3,(ln*text size())-text size(),getLine(_label(l).w,_label(l).s,ln)
next ln
get image _label(l).i,0,0,_label(l).w,_label(l).h
set current bitmap 0 : delete bitmap 1
next l
endfunction
function handlelabels()
local num as integer : num=array count(_label())
for l=1 to num
if _label(l).show
if _label(l).tabassigned
if tabPageSelected(_label(l).tab,_label(l).tabpage) and _tab(_label(l).tab).show
paste image _label(l).i,_label(l).x,_label(l).y,1
endif
else
paste image _label(l).i,_label(l).x,_label(l).y,1
endif
endif
showLabel(l)
next l
endfunction
function showLabel(num)
_label(num).show=1
endfunction
function hideLabel(num)
_label(num).show=0
endfunction
function setLabelTab(l,t,p)
_label(l).tabassigned=1
_label(l).tab=t : _label(l).tabpage=p
endfunction
function addButton(x,y,sx,sy,capt as string,col1,col2)
local num as integer
array insert at bottom _Button()
num=array count(_Button())
_button(num).x=x
_button(num).y=y
_button(num).sx=sx
_button(num).sy=sy
_button(num).capt=capt
_button(num).col1=col1
_button(num).col2=col2
_button(num).img1=freeimage()
_button(num).img2=freeimage()
_button(num).img3=freeimage()
_button(num).state=1
endfunction num
function createButtons()
local num as integer : num=array count(_button())
for b=1 to num
create bitmap 1,_button(b).sx,_button(b).sy : set current bitmap 1
box 0,0,_button(b).sx,_button(b).sy,_button(b).col2,_button(b).col1,_button(b).col2,_button(b).col1
buttonEdge(_button(b).sx,_button(b).sy)
ink _button(b).col2,0
box 1,1,_button(b).sx-1,2 : box 1,_button(b).sy-2,_button(b).sx-1,_button(b).sy-1
box 1,1,2,_button(b).sy-2 : box _button(b).sx-2,1,_button(b).sx-1,_button(b).sy-1
ink rgb(20,20,20),0 : center text _button(b).sx/2,(_button(b).sy/2)-(text size()/2),_button(b).capt
get image _button(b).img1,0,0,_button(b).sx,_button(b).sy
set current bitmap 0 : delete bitmap 1
create bitmap 1,_button(b).sx,_button(b).sy : set current bitmap 1
box 0,0,_button(b).sx,_button(b).sy,_button(b).col2,_button(b).col1,_button(b).col2,_button(b).col1
ink _button(b).col2,0
box 1,1,_button(b).sx-2,3 : box 1,_button(b).sy-3,_button(b).sx-2,_button(b).sy-2
box 1,1,3,_button(b).sy-3 : box _button(b).sx-3,1,_button(b).sx-2,_button(b).sy-2
buttonEdge(_button(b).sx,_button(b).sy)
ink rgb(20,20,20),0 : center text _button(b).sx/2,(_button(b).sy/2)-(text size()/2),_button(b).capt
get image _button(b).img2,0,0,_button(b).sx,_button(b).sy
set current bitmap 0 : delete bitmap 1
create bitmap 1,_button(b).sx,_button(b).sy : set current bitmap 1
box 0,0,_button(b).sx,_button(b).sy,_button(b).col1,_button(b).col2,_button(b).col1,_button(b).col2
ink _button(b).col2,0
box 1,1,_button(b).sx-2,3 : box 1,_button(b).sy-3,_button(b).sx-2,_button(b).sy-2
box 1,1,3,_button(b).sy-3 : box _button(b).sx-3,1,_button(b).sx-2,_button(b).sy-2
buttonEdge(_button(b).sx,_button(b).sy)
ink rgb(20,20,20),0 : center text _button(b).sx/2,(_button(b).sy/2)-(text size()/2),_button(b).capt
get image _button(b).img3,0,0,_button(b).sx,_button(b).sy
set current bitmap 0 : delete bitmap 1
next b
endfunction
function handleButtons()
local num as integer : num=array count(_button())
for b=1 to num
if _button(b).visible=1
if mousex()>_button(b).x and mousex()<_button(b).x+_button(b).sx and mousey()>_button(b).y and mousey()<_button(b).y+_button(b).sy
_button(b).state=2
else
_button(b).state=1
endif
if _button(b).state=2 and mouseclick() then _button(b).state=3
endif
if _button(b).state=1 then bi=_button(b).img1
if _button(b).state=2 then bi=_button(b).img2
if _button(b).state=3 then bi=_button(b).img3
if _button(b).show
if _button(b).tabassigned
if tabPageSelected(_button(b).tab,_button(b).tabpage) and _tab(_button(b).tab).show
paste image bi,_button(b).x,_button(b).y,1
_button(b).visible=1
else
_button(b).visible=0
endif
else
paste image bi,_button(b).x,_button(b).y,1
_button(b).visible=1
endif
endif
if _button(b).show=0 then _button(b).visible=0
_button(b).show=1
next b
endfunction
function buttonclicked(num)
if _button(num).state=3 then exitfunction 1
endfunction 0
function buttonEdge(sx,sy)
ink 0,0
cdot(0,0)
cdot(1,0) : cdot(0,1)
cdot(2,0) : cdot(0,2) : cdot(1,1)
cdot(3,0) : cdot(0,3) : cdot(1,2) : cdot(2,1)
cdot(4,0) : cdot(0,4)
cdot(sx-0,0)
cdot(sx-1,0) : cdot(sx-0,1)
cdot(sx-2,0) : cdot(sx-0,2) : cdot(sx-1,1)
cdot(sx-3,0) : cdot(sx-0,3) : cdot(sx-1,2) : cdot(sx-2,1)
cdot(sx-4,0) : cdot(sx-0,4)
cdot(0,sy-0)
cdot(1,sy-0) : cdot(0,sy-1)
cdot(2,sy-0) : cdot(0,sy-2) : cdot(1,sy-1)
cdot(3,sy-0) : cdot(0,sy-3) : cdot(1,sy-2) : cdot(2,sy-1)
cdot(4,sy-0) : cdot(0,sy-4)
cdot(sx-0,sy-0)
cdot(sx-1,sy-0) : cdot(sx-0,sy-1)
cdot(sx-2,sy-0) : cdot(sx-0,sy-2) : cdot(sx-1,sy-1)
cdot(sx-3,sy-0) : cdot(sx-0,sy-3) : cdot(sx-1,sy-2) : cdot(sx-2,sy-1)
cdot(sx-4,sy-0) : cdot(sx-0,sy-4)
endfunction
function showButton(b)
_button(b).show=1
endfunction
function hideButton(b)
_button(b).show=0
endfunction
function setButtonTab(b,t,p)
_button(b).tabassigned=1
_button(b).tab=t : _button(b).tabpage=p
endfunction
`draw--
function FloodFill(x,y,c)
__FloodFillGlobal.BitmapWidth=bitmap width()-1
__FloodFillGlobal.BitmapHeight=bitmap height()-1
__InitialiseFillSpan()
if x >= 0 and x <= __FloodFillGlobal.BitmapWidth
if y >= 0 and y <= __FloodFillGlobal.BitmapHeight
lock pixels
__FloodFillGlobal.CoverColour = point(x,y)
if __FloodFillGlobal.CoverColour <> c
ink c,0
__FloodLoop(x,y)
endif
unlock pixels
endif
endif
endfunction
function __FloodLoop(x as integer,y as integer)
local Left as integer
local Right as integer
local SpanSize as integer
for Left=x-1 to 0 step -1
if point(Left,y) <> __FloodFillGlobal.CoverColour then exit
next Left
inc Left
for Right=x+1 to __FloodFillGlobal.BitmapWidth
if point(Right,y) <> __FloodFillGlobal.CoverColour then exit
next Right
box Left,y,Right,y+1
__AddFillSpan(y,Left-1,Right+1)
if y > 0
dec y
x=Left
while x < Right
SpanSize=__CheckFillSpan(x,y)
if SpanSize = 0
if point(x,y) = __FloodFillGlobal.CoverColour
__FloodLoop(x,y)
endif
inc x
else
inc x,SpanSize
endif
endwhile
inc y
endif
if y < __FloodFillGlobal.BitmapHeight
inc y
x=Left
while x < Right
SpanSize=__CheckFillSpan(x,y)
if SpanSize = 0
if point(x,y) = __FloodFillGlobal.CoverColour
__FloodLoop(x,y)
endif
inc x
else
inc x,SpanSize
endif
endwhile
endif
endfunction
function __InitialiseFillSpan()
local i as integer
if __FloodFillGlobal.Initialised = 0
undim __FilledSpans()
global dim __FilledSpans(__SpanListSize,2048) as __FillSpan
undim __FilledSpansCount()
global dim __FilledSpansCount(2048) as integer
__FloodFillGlobal.Initialised=1
else
for i=__FloodFillGlobal.BitmapHeight to 0 step -1
__FilledSpansCount(i)=0
next i
endif
endfunction
function __AddFillSpan(y as integer,Left as integer,Right as integer)
local i as integer
i=__FilledSpansCount(y)
if i < __SpanListSize
__FilledSpans(i, y).Left=Left
__FilledSpans(i, y).Right=Right
inc __FilledSpansCount(y)
endif
endfunction
function __CheckFillSpan(x as integer,y as integer)
local i as integer
for i=__FilledSpansCount(y)-1 to 0 step -1
if x >= __FilledSpans(i, y).Left
if x < __FilledSpans(i, y).Right then exitfunction __FilledSpans(i, y).Right-x
endif
next i
endfunction 0
`free--
function freeimage()
for i=1 to 65535
if imgtaken(i)=0 and image exist(i)=0
imgtaken(i)=1 : exitfunction i
endif
next i
endfunction 0
`draw
function circ(x1,y1,r,t)
for x=1 to r
for y=1 to r
if sqrt((x-(r/2))^2 + (y-(r/2))^2)<(r/2) and sqrt((x-(r/2))^2 + (y-(r/2))^2)>(r/2)-t
`box (x1+x)-(r/2),(y1+y)-(r/2),((x1+x)-(r/2))+1,((y1+y)-(r/2))+1
cdot((x1+x)-(r/2),(y1+y)-(r/2))
endif
next x
next y
endfunction
function cdot(x,y)
box x,y,x+1,y+1
endfunction
`misc
function totalLines(xMax, string$)
linePos = 0 : cursorPos =0
repeat
inc linePos : txt$ = ""
repeat
inc cursorPos
txt$ = txt$ + mid$(string$, cursorPos)
until cursorPos => len(string$) Or text width(txt$) > xMax
if text width(txt$) > xMax
dec cursorPos : txt$ = left$(txt$, (len(txt$) - 1))
a = 0
while (mid$(string$, cursorPos) <> " ")
dec cursorPos : inc a
endwhile
txt$ = left$(txt$, (len(txt$) - a))
endif
until cursorPos => len(string$)
endfunction linePos
Function getLine(xMax, string$, getLine)
linePos = 0 : cursorPos =0
repeat
inc linePos : txt$ = ""
repeat
inc cursorPos
txt$ = txt$ + mid$(string$, cursorPos)
until cursorPos => len(string$) Or text width(txt$) > xMax
if text width(txt$) > xMax
dec cursorPos : txt$ = left$(txt$, (len(txt$) - 1))
a = 0
while (mid$(string$, cursorPos) <> " ")
dec cursorPos : inc a
endwhile
txt$ = left$(txt$, (len(txt$) - a))
endif
until cursorPos => len(string$) Or linePos = getLine
endfunction txt$
[edit]
Oh, and yeah, the line tool doesn't work.