'This program was finished on December 17, 2019.
'Technical Notes:
'This version lets people save their .bmp files with spaces in their filenames.
'This version doesn't use the temp.bmp when saving anymore.
'This version jumps right to Draw mode when starting and also after Saving and Loading.
'This version lets you continue to draw on the same picture after Saving.
'
'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,
'the ray line making code, and general help in making this program.
'-------------------------------------------------------------------------------------------
start:
PRINT " By Ken G. and B+" PRINT " Use your Mouse for:" PRINT " (R)ays, (B)oxes, (O)rbits," PRINT " (D)raw, (E)rase, (C)olors," PRINT " (P)rint to your Printer." PRINT " (I)nstructions - which will" PRINT " cause your picture to be lost." PRINT " Space Bar to erase picture." PRINT " Press the Space Bar to" PRINT " skip instructions." PRINT " Press Esc to end." PRINT " * Any other key to continue. *" gggo:
PRINT " Commands are self-explanatory" PRINT " on Title Bar of Paint Window." PRINT " Here are some others:" PRINT " * Space Bar clears the screen." PRINT " * A color choosing window" PRINT " will come up right before" PRINT " you start painting. It also" PRINT " comes up when you press Space" PRINT " Bar to clear the screen." PRINT " Move the slides to the color" PRINT " you wish to use." PRINT " * Esc to end program." PRINT " * Use Left Mouse Button" PRINT " * (I)nstructions" PRINT " - There is no Undo feature." PRINT " It saves under .bmp files which can" PRINT " be used with most other programs." PRINT " It saves as 800 x 600 pixels." PRINT " Press Esc to end." PRINT " * Any other key to start. *" ggggo:
start2:
begin = 1
PRINT " Background Color" PRINT " Or Esc to end program." start3:
bcol = 1
bcol = 2
more2:
begin = 1
dMode = 1
m = 1
_TITLE "(D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" '---------------------------------------------------
'Here is the main loop of the program when painting.
'---------------------------------------------------
dMode = 1 - dMode
m = 1
_TITLE "Mode: (D)raw | (D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" LINE (mouseX
, mouseY
)-(mouseX
+ 1, mouseY
+ 1), clr~&
, BF
_TITLE "(D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" eMode = 1 - eMode
m = 2
_TITLE "Mode: (E)raser | (D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" LINE (mouseX
, mouseY
)-(mouseX
+ 1, mouseY
+ 1), _RGB32(255, 255, 255), BF
LINE (mouseX
, mouseY
)-(mouseX
+ 1, mouseY
+ 1), _RGB32(0, 0, 0), BF
_TITLE "(D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" '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
m = 3
IF rMode
THEN lastx
= mouseX: lastY
= mouseY
'set first lastx, lasty _TITLE "Mode: (R)ays | (D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" LINE (lastx
, lastY
)-(mouseX
, mouseY
), clr~&
lastx = mouseX: lastY = mouseY
_TITLE "(D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" 'Here is the Orbit Circles code.
oMode = 1 - oMode
m = 4
IF oMode
THEN lastx
= mouseX: lastY
= mouseY
_TITLE "Mode: (O)rbits | (D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" IF mouseX
< lastx
THEN size
= lastx
- mouseX
IF mouseX
> lastx
THEN size
= mouseX
- lastx
IF mouseY
< lastY
THEN size2
= lastY
- mouseY
IF mouseY
> lastY
THEN size2
= mouseY
- lastY
one:
seconds = seconds + .01
s = (60 - seconds) * 6 + size
x
= INT(SIN(s
/ 180 * 3.141592) * size
) + lastx
Y
= INT(COS(s
/ 180 * 3.141592) * size2
) + lastY
seconds = 0
two:
size = 0: size2 = 0
lastx = mouseX
lastY = mouseY
_TITLE "(D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" 'Here is the Boxes code.
bMode = 1 - bMode
m = 5
IF bMode
THEN lastx
= mouseX: lastY
= mouseY
_TITLE "Mode: (B)oxes | (D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" LINE (lastx
, lastY
)-(mouseX
, mouseY
), clr~&
, BF
lastx = mouseX:
lastY = mouseY
_TITLE "(D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" 'Here is the Printing of the picture.
_TITLE "Mode: (P)rint | (D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" m = 0
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
s& = j&
_TITLE "(D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint"
'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:
_TITLE "Mode: (S)ave | (D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" 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: 800 height: 600 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 " 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 " Esc goes to start screen." llloop:
saving2:
SaveImage 0, nm$
nm$ = ""
'This section loads your picture from your computer.
loading:
_TITLE "Mode: (L)oad | (D)raw, (E)rase, (C)olors, (R)ays, (O)rbits, (B)oxes, (S)ave, (L)oad, (P)rint" 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 goes to start screen." llloop2:
l = 0
s& = i&
i& = 0
dMode = 1
m = 1
'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$