'This program was finished on October 6, 2019.
'Technical Notes:
'This program uses around 55 MB RAM and 1% of the CPU on my semi-new computer.
'Use at your own risk. I hold no responsibility for any problems whatsoever.
'
'Thank you to B+ from the QB64.org forum for the color picker, the picture rotation code and
'the ray line making code!
'-------------------------------------------------------------------------------------------
start:
PRINT " By Ken G. and B+" PRINT "Use your mouse to paint on a" PRINT "You also can make lines: (R)ays," PRINT "(O)rbits, and (B)oxes." PRINT "You also can (P)rint to" PRINT "your USB printer as well as edit" PRINT "an old picture file." PRINT "It saves under .bmp files which can" PRINT "be used with most other programs." PRINT "Press the Space Bar to" PRINT "skip instructions." PRINT "Press Esc to end." PRINT "Press any other key to continue." gggo:
PRINT "* (S)ave (L)oad (I)nstructions" PRINT "* (R)ay for new line(s)." PRINT "Press R once to start line," PRINT "then use the mouse to where you" PRINT "want the end of it to be. You can" PRINT "keep using the mouse and the line" PRINT "will start where it left off at." PRINT "Press R again to go back to drawing." PRINT "* (O)rbit coordinates for circles." PRINT "Press O once to start circle." PRINT "and again to finish it." PRINT "The size of the circle depends" PRINT "on the length difference" PRINT "between where you pressed O" PRINT "both times. The center of the circle" PRINT "will be the first place you pressed O." PRINT "The shape of the circle depends on the" PRINT "angle between your 2 presses. A diagonal" PRINT "difference between them will show more" PRINT "of a circle than straight up and down" PRINT "or side to side between the presses." PRINT "* (B)oxes are the same way as (O)rbits." PRINT "* (P)rints the picture on" PRINT "your printer. It will not work" PRINT "if you choose a black background" PRINT "because of heavy ink or toner use." PRINT "To go around that, choose a white" PRINT "background and on the color picker" PRINT "window, choose black and press F" PRINT "to fill entire window." PRINT "* Esc to end program." PRINT "* Space Bar clears the screen." PRINT "* Left Mouse Button draws." PRINT "* Right Mouse Button erases." PRINT "- There is no Undo feature." PRINT "Press Esc to end." PRINT "Press any other key to continue." ggggo:
PRINT " Instructions Page 2" PRINT "(C)olor changes colors." PRINT "A window will come up to use" PRINT "your mouse to choose a color." PRINT "* This will also happen when you" PRINT " first start your painting." PRINT "(B)oxes makes a filled box." PRINT "First press B once to start the" PRINT "box corner, then press B again" PRINT "to set the 2nd corner and size" PRINT "diagonally from the first one." PRINT "Paint slowly to leave out gaps." PRINT "When you press S to save," PRINT "the program will create a temp.bmp" PRINT "of the screen and when asking you" PRINT "for a file name, it will rename temp.bmp" PRINT "to your chosen name." PRINT "Press Esc to end program." PRINT "Press any other key to start." gggggo:
start2:
begin = 1
PRINT "Or Esc to end program." start3:
LINE (0, 0)-(640, 480), _RGB(255, 255, 255), BF
more2:
begin = 1
'---------------------------------------------------
'Here is the main loop of the program when painting.
'---------------------------------------------------
LINE (mouseX
, mouseY
)-(mouseX
+ 1, mouseY
+ 1), clr~&
, BF
LINE (mouseX
, mouseY
)-(mouseX
+ 1, mouseY
+ 1), 0, BF
'Here is when someone whipes the screen blank with the space bar.
'Here is code needed to call up the Windows Color Picker.
'It also uses the code on top of this program and the Function at the end
'of this program.
chosencolor:
check$ = colorDialog$
IF check$
<> "" THEN clr~&
= VAL(check$
) ELSE clr~&
= &HFF0000FF '<<< I am blue if colorDialog does not work
'Here is the Ray Lines code.
rMode = 1 - rMode
IF rMode
THEN lastx
= mouseX: lastY
= mouseY
'set first lastx, lasty IF rMode
AND mouseLeftButton
THEN LINE (lastx
, lastY
)-(mouseX
, mouseY
), clr~&: lastx
= mouseX: lastY
= mouseY
'Here is the Orbit Circles code.
ck2 = ck2 + 1
xxx2 = mouseX: yyy2 = mouseY
orbit:
IF mouseX
< xxx2
THEN size
= xxx2
- mouseX
IF mouseX
> xxx2
THEN size
= mouseX
- xxx2
IF mouseY
< yyy2
THEN size2
= yyy2
- mouseY
IF mouseY
> yyy2
THEN size2
= mouseY
- yyy2
one:
seconds = seconds + .01
s = (60 - seconds) * 6 + size
x
= INT(SIN(s
/ 180 * 3.141592) * size
) + xxx2
y
= INT(COS(s
/ 180 * 3.141592) * size2
) + yyy2
seconds = 0
two:
xxx2 = 0: yyy2 = 0
size = 0: size2 = 0: size3 = 0
ck2 = 0
firstorbit:
'Here is the Boxes code.
ck3 = ck3 + 1
xxx3 = mouseX: yyy3 = mouseY
box:
LINE (mouseX
, mouseY
)-(xxx3
+ 1, yyy3
+ 1), clr~&
, BF
xxx3 = 0: yyy3 = 0
ck3 = 0
firstbox:
'Here is the Printing of the picture.
INPUT "Print on printer (Y/N)?", i$
'print screen page on printer 'printer prep (code copied and pasted from bplus Free Calendar Program)
_MAPTRIANGLE (XMAX
, 0)-(0, 0)-(0, YMAX
), 0 TO(0, 0)-(0, XMAX
)-(YMAX
, XMAX
), landscape&
_MAPTRIANGLE (XMAX
, 0)-(XMAX
, YMAX
)-(0, YMAX
), 0 TO(0, 0)-(YMAX
, 0)-(YMAX
, XMAX
), landscape&
landscape& = 0
j& = 0
'Saving
'This section first saves your picture as temp.bmp and then
'asks you a name for your picture and then renames temp.bmp to your name.
saving:
'Now we call up the SUB to save the image to BMP.
SaveImage 0, "temp.bmp"
PRINT " Your bmp file will be saved in the" PRINT " same directory as this program is." PRINT " It can be used with almost any" PRINT " other graphics program or website." PRINT " It is saved using:" PRINT " width: 640 height: 480 pixels." PRINT " Type a name to save your picture" PRINT " and press the Enter key. Do not" PRINT " add .bmp at the end, the program" PRINT " will do it automatically." PRINT " Also do not use the name temp" PRINT " because the program uses that name" PRINT " and it would be erased the next time" PRINT " you save a picture." PRINT " Quit and Enter key ends program." nm$ = nm$ + ".bmp"
'Checking to see if the file already exists on your computer.
PRINT " File Already Exists" PRINT " Saving will delete your old" PRINT " Would you like to still do it?" PRINT " (Y/N). Esc ends program." llloop:
saving2:
nm$ = ""
loading: 'This section loads your picture from your computer.
PRINT " Do not add .bmp at the end." PRINT " The bmp picture must be in the same" PRINT " directory as this program is." PRINT " You will not be able to edit your" PRINT " picture file with this program." PRINT " Type the name of your picture file" PRINT " here and press the Enter key." PRINT " Quit and Enter key ends program." nm$ = nm$ + ".bmp"
PRINT " File Does Not Exist." PRINT " Would you like to try again (Y/N)" PRINT " Esc ends program." llloop2:
l = 0
s& = i&
i& = 0
'Here is the SUB needed to save the image to BMP.
IF bytesperpixel&
= 1 THEN bpp&
= 8 ELSE bpp&
= 24 b$
= "BM????QB64????" + MKL$(40) + MKL$(x&
) + MKL$(y&
) + MKI$(1) + MKI$(bpp&
) + MKL$(0) + "????" + STRING$(16, 0) 'partial BMP header info(???? to be filled later) FOR c&
= 0 TO 255 ' read BGR color settings from JPG image + 1 byte spacer(CHR$(0)) MID$(b$
, 11, 4) = MKL$(LEN(b$
)) ' image pixel data offset(BMP header) FOR py&
= y&
- 1 TO 0 STEP -1 ' read JPG image pixel color data r$ = ""
c&
= POINT(px&
, py&
) 'POINT 32 bit values are large LONG values d$ = d$ + r$ + padder$
MID$(b$
, 35, 4) = MKL$(LEN(d$
)) ' image size(BMP header) b$ = b$ + d$ ' total file data bytes to create file
MID$(b$
, 3, 4) = MKL$(LEN(b$
)) ' size of data file(BMP header)
'first screen dimensions items to restore at exit
'save old settings to restore at end ofsub
'screen snapshot
r = 128: g = 128: b = 128: a = 128
slider 16, 10, r, "Red"
slider 16, 60, g, "Green"
slider 16, 110, b, "Blue"
slider 16, 160, a, "Alpha"
_PRINTSTRING (150, 260), "Press enter or spacebar, if you want to use the color: " + makeConst$
_PRINTSTRING (210, 280), "Press escape or q, to not use any color, returns 0." LINE (90, 300)-(710, 590), , B
f = 255 * (i - 100) / 600
'put things back
'clear key presses
'clear mouse clicks
SUB slider
(x
, y
, value
, label$
) CASE "Red": c~&
= &HFFFF0000 CASE "Green": c~&
= &HFF008800 CASE "Blue": c~&
= &HFF0000FF CASE "Alpha": c~&
= &H88FFFFFF LINE (x
, y
)-STEP(3 * value
, 40), c~&
, BF
s$ = label$ + " = " + s3$