cls rgb(255,200,200)
sync on
sync rate 0
set text font "verdana"
set text size 10
set display mode 800,600,16
cls rgb(255,200,200) : sync
 
colourval=0
ink colourval,rgb(255,255,255)
 
`bitmap 2 = image
create bitmap 2,660,570
cls rgb(255,255,255)
`bitmap 3 = alterations
create bitmap 3,660,570
set current bitmap 0
 
gosub toolbar
gosub newpage
dmethod = 5
airbrushrad=10
 
 
do
 
 
 
if mouseclick()=1
	if mousex()<660 and mousey()<570
		if dmethod = 0
			set current bitmap 2
			if sStarted=0 then x#=mousex() : y#=mousey()
			line x#,y#,mousex(),mousey()
			x#=mousex()
			y#=mousey()
			sStarted = 1
			set current bitmap 0
			copy bitmap 2,0
		endif
		if dmethod = 1
			set current bitmap 2
			copy bitmap 3,2
			if sStarted=0 then x#=mousex() : y#=mousey()
			line x#,y#,mousex(),mousey()
			sStarted = 1
			set current bitmap 0
			copy bitmap 2,0
		endif
		if dmethod = 2
			set current bitmap 2
			copy bitmap 3,2
			if sStarted=0 
				x#=mousex()
				y#=mousey()
			endif
			xcenter=(x#+mousex())/2
			ycenter=(y#+mousey())/2
			xrad=ABS(xcenter-mousex())
			yrad=ABS(ycenter-mousey())
			ellipse xcenter,ycenter,xrad,yrad
			sStarted = 1
			set current bitmap 0
			copy bitmap 2,0
		endif
		if dmethod = 3
			set current bitmap 2
			copy bitmap 3,2
			if sStarted=0 
				x#=mousex()
				y#=mousey()
			endif
			xcenter=(x#+mousex())/2
			ycenter=(y#+mousey())/2
			rad=(ABS(xcenter-mousex())+ABS(ycenter-mousey()))/2
			for t=0 to rad
				circle xcenter,ycenter,t
			next t
			sStarted = 1
			set current bitmap 0
			copy bitmap 2,0
		endif
		if dmethod = 4
			set current bitmap 2
			copy bitmap 3,2
			if sStarted=0 then x#=mousex() : y#=mousey()
			line x#,y#,x#,mousey()
			line x#,y#,mousex(),y#
			line mousex(),y#,mousex(),mousey()
			line x#,mousey(),mousex(),mousey()
			sStarted = 1
			set current bitmap 0
			copy bitmap 2,0
		endif
		if dmethod = 5
			set current bitmap 2
			copy bitmap 3,2
			if sStarted=0 then x#=mousex() : y#=mousey()
			if mousex()>x# and mousey()>y# then box x#,y#,mousex(),mousey()
			if mousex()<x# and mousey()>y# then box mousex(),y#,x#,mousey()
			if mousex()>x# and mousey()<y# then box x#,mousey(),mousex(),y#
			if mousex()<x# and mousey()<y# then box mousex(),mousey(),x#,y#
			sStarted = 1
			set current bitmap 0
			copy bitmap 2,0
		endif
		if dmethod = 6
			set current bitmap 2
			for x=mousex()-airbrushrad to mousex()+airbrushrad
				for y=mousey()-airbrushrad to mousey()+airbrushrad
					if SQRT((x-mousex())^2+(y-mousey())^2)<airbrushrad
						airbrushvar=rnd(4)
						if airbrushvar=4 then dot x,y
					endif
				next y
			next x
			set current bitmap 0
			copy bitmap 2,0
		endif
	endif
	if mousex()>690 and mousex()<770 and mousey()>100 and mousey()<400
		colourval=point(mousex(),mousey())
		ink colourval,rgb(255,255,255)
		box 701,411,759,414
	endif
	if mousex()>700 and mousex()<760 and mousey()>20 and mousey()<80 then gosub newpage
	for t=0 to 3
		for q=0 to 1
			if mousey()>(425+40*t) and mousey()<(425+40*(t+1)) and mousex()>(690+40*q) and mousex()<(690+40*(q+1))
				dmethod=(t*2)+q
			endif
		next q
	next t
else
	sStarted = 0
	copy bitmap 2,0
	copy bitmap 2,3
endif
 
 
 
sync
loop
 
newpage:
ink 0,rgb(255,255,255)
cls
copy bitmap 1,0,0,139,599,0,660,0,799,599
 
return
 
 
 
 
toolbar:
create bitmap 1,140,600
ink rgb(155,155,155),0
box 0,0,139,599
ink 0,rgb(255,255,255)
box 40,20,100,80
ink rgb(255,255,255),0
box 41,21,99,79
ink 0,rgb(255,255,255)
line 83,30,83,70
line 57,40,57,70
line 67,30,83,30
line 57,70,83,70
line 57,40,67,30
line 57,40,67,40
line 67,30,67,40
 
`colour chart
for t=30 to 110 step 20
	line t,100,t,400
next t
for t=100 to 400 step 20
	line 30,t,110,t
next t
 
`grayscale
for t=0 to 14
	ink rgb(t*17,t*17,t*17),0 : box 31,101+(t*20),49,119+(t*20)
next t
 
`red-yellow-green
for t=0 to 4
	ink rgb(t*51,0,0),0 : box 51,101+(t*20),69,119+(t*20)
next t
for t=0 to 4
	ink rgb(255,t*51,0),0 : box 51,201+(t*20),69,219+(t*20)
next t
for t=0 to 4
	ink rgb(255-(t*51),255,0),0 : box 51,301+(t*20),69,319+(t*20)
next t
 
`green-cyan-blue
for t=0 to 4
	ink rgb(0,t*51,0),0 : box 71,101+(t*20),89,119+(t*20)
next t
for t=0 to 4
	ink rgb(0,255,t*51),0 : box 71,201+(t*20),89,219+(t*20)
next t
for t=0 to 4
	ink rgb(0,255-(t*51),255),0 : box 71,301+(t*20),89,319+(t*20)
next t
 
`blue-purple-red
for t=0 to 4
	ink rgb(0,0,t*51),0 : box 91,101+(t*20),109,119+(t*20)
next t
for t=0 to 4
	ink rgb(t*51,0,255),0 : box 91,201+(t*20),109,219+(t*20)
next t
for t=0 to 4
	ink rgb(255,0,255-(t*51)),0 : box 91,301+(t*20),109,319+(t*20)
next t
 
ink 0,0
colourval=0
box 40,410,100,415
 
 
 
`tools
for t=30 to 110 step 40
	line t,425,t,585
next t
for t=425 to 585 step 40
	line 30,t,110,t
next t
 
`pencil tool - 0
ink 0,0
line 35,455,65,435 : line 33,453,63,433 : line 37,457,67,437 : line 33,453,37,457 : line 67,437,63,433 : line 67,437,67,433 : line 67,433,63,433 : dot 66,434
 
 
`line tool - 1
ink 0,0
line 75,455,105,435
 
`ellipse/circle tool - 2
ellipse 50,485,9,6
 
`filled circle - 3
for t=0 to 8
	circle 90,485,t
next t
 
`box - 4
line 40,516,60,516
line 40,535,60,535
line 40,516,40,535
line 60,516,60,535
 
`filled box - 5
box 80,516,100,535
 
`Airbrush - 6
for x=31 to 69
	for y=546 to 584
		if SQRT((x-50)^2+(y-565)^2)<15
			airbrushvar=rnd(4)
			if airbrushvar=4 then dot x,y
		endif
	next y
next x
 
`Fill With Colour - 7
box 70,545,110,585
 
 
set current bitmap 0
return