Code archives/Miscellaneous/Paint program

This code has been declared by its author to be Public Domain code.

Download source code

Paint program by blitz monkey
(Posted 19 years ago)
This is a short basic paint program that involves pixil ploting and short simple functions. Im 13 WOO!
Graphics 1280,960
Global sx=50
Global sy=50
Global r=255
Global g=255
Global b=255
Global save=0
Global load=0
Global width=GraphicsWidth():height=GraphicsHeight()

Function size()
Locate 0,60
sx=Input("size x ")
sy=Input("size y ")
End Function

Function colorsel()
Locate 0,60
r=Input("red " )
g=Input("green " )
b=Input("blue " )
End Function 

Function Inser()
Color r,b,g
Locate MouseX(),MouseY()
d1$=Input$("")
End Function




While Not KeyDown(1)
If KeyDown(46) Colorsel
If KeyDown(56) Then r=0:g=0:b=0
If KeyDown(59) Then 
Color r,g,b
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
Plot Rnd(width),Rnd(height)
EndIf
If KeyHit(29) size
If KeyHit(19)r=255:g=0:b=0
If KeyHit(34)r=0:g=255:b=0
If KeyHit(48)r=0:g=0:b=255
If KeyHit(17)r=255:g=255:b=255
If KeyHit(25)r=111:g=0:b=111
If KeyHit(21)r=255:g=255:b=0
If KeyHit(20)r=0:g=255:b=255
If KeyHit(24)r=249:g=81:b=0
If KeyHit(31)r=98:g=98:b=0
If KeyHit(210) Inser
If MouseDown(1)
Color r,g,b
Plot MouseX(),MouseY()
Plot MouseX()+1,MouseY()
Plot MouseX(),MouseY()+1
Plot MouseX()-1,MouseY()
Plot MouseX(),MouseY()-1
Plot MouseX(),MouseY()
Plot MouseX()+1,MouseY()
Plot MouseX(),MouseY()+1
Plot MouseX()-1,MouseY()
Plot MouseX(),MouseY()-1
EndIf
If MouseDown(2)
Color 0,0,0
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
EndIf
If KeyHit(211)
Cls
EndIf
If MouseDown(3)
Color r,g,b
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
Plot MouseX()+Rnd(sx),MouseY()+Rnd(sy)
EndIf
Color 0,0,0
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Plot -1+Rnd(100),35+Rnd(100)
Color 255,255,255
Text 0,20,"Keys are S,R,G,B,T,Y,O,P,END,INSERT,F1,F5,DELETE,Left CONTROL,left ALT,C"
Wend

Comments

z80jim
(Posted 19 years ago)
doesn't seem to work... it keeps finding errors with your code.
When I was 12-13, I wrote my first finished program which also was a paint program lol. I can't seem to find it on the computer though, must have gotten deleted at some point :(

Rob Farley
(Posted 19 years ago)
I've just knocked this up which might help you a little

Graphics 1024,768,32,2

BrushSize = 20
Flow = 50

SetBuffer BackBuffer()

Dim Colours$(7)
Data "000","001","010","011","100","101","110","111"
For n=0 To 7
	Read colours(n)
Next
ColourNumber = 7


Repeat
	ColourNumber = ColourNumber + MouseZSpeed()
	If ColourNumber > 7 Then ColourNumber = 0 
	If ColourNumber < 0 Then ColourNumber = 7
	C$ = Colours(ColourNumber)
	R = Mid(C,1,1)
	G = Mid(C,2,1)
	B = Mid(C,3,1)
	Color R*255,G*255,B*255

	If MouseDown(1)
		For n=1 To Flow
			x = MouseX()
			y = MouseY()
			r = Rand(0,359)
			d = Rand(0,BrushSize)
			
			Plot x + (Sin(r) * d), y + (Cos(r) * d)
		Next
	EndIf
	

	Rect 1,1,48,10
	Color 255,255,255
	Rect 0,0,50,12,False
	
	Text 80,0,"Mouse Wheel to change Colour"
 
	
	Flip
Until KeyHit(1)
Any questions... Just ask

Mortifer Nex
(Posted 19 years ago)
Lol... I made my first make my paint program at 9, 10 now.

Here's the program:

Graphics 800,600,16,2
Global w
Global x=255
Global y
AppTitle "Drawing"
Color 255,255,255
Line 1,500,800,500
Color 0,0,255
Rect 1,520,50,50,1
Text 20,580, "1"
Color 255,0,0
Rect 61,520,50,50,1
Text 80,580, "2"
Color 0,255,0
Rect 121,520,50,50,1
Text 140,580, "3"
Color 255,255,255
Rect 181,520,50,50,1
Text 200,580, "4"
Color 255,0,255
Rect 241,520,50,50,1
Text 260,580, "5"
Color 0,255,255
Rect 301,520,50,50,1
Text 320,580, "6"
Color 255,255,0
Rect 361,520,50,50,1
Text 380,580, "7"
Color 255,255,255
Text 421,520, "BSP-Clear Screen"
Text 421,532, "ESC-Quit"
Text 575,510, "Current Color:"
Color 255,255,255
Rect 590,530,60,60,1
Color 0,0,255
Rect 595,535,50,50,1
While Not KeyDown(1)
	While MouseDown(1) And MouseY()<490
		Color w,y,x
		Oval MouseX(),MouseY(),10,10,1
		CheckForColors()

	Wend
	CheckForColors()
Wend
End
Function CheckForColors()
If KeyHit(2) Then
		x=255
		w=0
		y=0
		Color w,y,x
		Rect 595,535,50,50,1
	EndIf
	If KeyHit(3) Then
		x=0
		w=255
		y=0
		Color w,y,x
		Rect 595,535,50,50,1
	EndIf
	If KeyHit(4) Then
		x=0
		w=0
		y=255
		Color w,y,x
		Rect 595,535,50,50,1
	EndIf
	If KeyHit(5) Then
		x=255
		w=255
		y=255
		Color w,y,x
		Rect 595,535,50,50,1
	EndIf
	If KeyHit(6) Then
		x=255
		w=255
		y=0
		Color w,y,x
		Rect 595,535,50,50,1
	EndIf								
	If KeyHit(7) Then
		x=255
		w=0
		y=255
		Color w,y,x
		Rect 595,535,50,50,1
	EndIf	
	If KeyHit(8) Then
		x=0
		w=255
		y=255
		Color w,y,x
		Rect 595,535,50,50,1
	EndIf
	
		
	If KeyHit(14) Then
		Cls
		Color 255,255,255
		Line 1,500,800,500
		Color 0,0,255
		Rect 1,520,50,50,1
		Text 20,580, "1"
		Color 255,0,0
		Rect 61,520,50,50,1
	  	Text 80,580, "2"
		Color 0,255,0
		Rect 121,520,50,50,1
		Text 140,580, "3"
		Color 255,255,255
		Rect 181,520,50,50,1
		Text 200,580, "4"
		Color 255,0,255
		Rect 241,520,50,50,1
		Text 260,580, "5"
		Color 0,255,255
		Rect 301,520,50,50,1
		Text 320,580, "6"
		Color 255,255,0
		Rect 361,520,50,50,1
		Text 380,580, "7"
		Color 255,255,255
		Text 421,520, "BSP-Clear Screen"
		Text 421,532, "ESC-Quit"
		Text 575,510, "Current Color:"
		Color 255,255,255
		Rect 590,530,60,60,1 
		Color w,y,x
		Rect 595,535,50,50,1
	EndIf
	End Function


z80jim
(Posted 19 years ago)
painting definitely is like the "hello world!" as in it makes a great first learning program :)

Code Archives Forum