' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.10.26.02.14]) on 2023.11.05 at 03:52 (Coordinated Universal Time) _TITLE "BAM Draw" ' Program by Charlie Veniot ' 🟠🟠🟠 DECLARATIONS ' screen variables DIM w% = 0, h% = 0, minw% = 52, maxw% = 260, minh% = 1, maxh% = 51 DIM grid% = TRUE ' menu variables DIM menuh% = 3 ' pen variables DIM pen$ ' 🟠🟠🟠 MAIN PROGRAM GOSUB ⚙init_program 🔃drawing_cycle: GOSUB ♻do_refresh LET temp$ = INKEY$ IF temp$ <> "" THEN pen$ = temp$ : GOSUB ✒set_pen IF _MOUSEBUTTON THEN IF _MOUSEZONE (0, 0, _WIDTH, [_HEIGHT-(menuh%*8)] ) THEN _ LET x% = _MOUSEX : _ LET y% = _MOUSEY : _ GOSUB ✒do_pen_stroke : GOTO ⏩done IF _MOUSEZONE(0, yMAX - 15, 40, 8 ) THEN GOSUB ✒change_pen : GOTO ⏩done IF _MOUSEZONE(0, yMAX - 7, 32, 8 ) THEN GOSUB 🖥toggle_grid : GOTO ⏩done ⏩done: END IF GOTO 🔃drawing_cycle END ' 🟠🟠🟠 SUBROUTINES ⚙init_program: SetLocalStorageItem( _ "draw:width", _ MAX( minw%, _ _PROMPT( "Canvas Width (i.e. how many characters wide, minimum = " + minw% + ")", minw%) ) ) SetLocalStorageItem( _ "draw:height", _ MAX( minh%, _ _PROMPT( "Canvas Width (i.e. how many characters wide, minimum = " + minh% + ")", 20) ) ) RETURN 🖥toggle_grid: WHILE _MOUSEBUTTON : WEND grid% = NOT grid% IF grid% THEN GOSUB 🖥do_grid ELSE GOSUB 🖥undo_grid RETURN 🖥do_grid: FOR i = 0 TO xMAX STEP 8 LINE (i,0) TO (i,(yMAX-menuh%*8)), 7 NEXT i FOR i = 7 TO (yMAX-menuh%*8) STEP 8 LINE (0,i) TO (xMAX,i), 7 NEXT i RETURN 🖥undo_grid: FOR i = 0 TO xMAX STEP 8 LINE (i,0) TO (i,(yMAX-menuh%*8)), 0 NEXT i FOR i = 7 TO (yMAX-menuh%*8) STEP 8 LINE (0,i) TO (xMAX,i), 0 NEXT i RETURN 📐do_canvas_resize: IF w% <> [ MAX(minw%, GetLocalStorageItem( "draw:width" ) ) ] * 8 _ OR h% <> [ MAX(minh%, GetLocalStorageItem( "draw:height" ) ) + menuh% ] * 8 _ THEN LET w% = [ MAX(minw%, GetLocalStorageItem( "draw:width" ) ) ] * 8 LET h% = [ MAX(minh%, GetLocalStorageItem( "draw:height" ) ) + menuh% ] * 8 SCREEN _NEWIMAGE( w%, h%, 7 ) GOSUB 🖥do_grid LINE (0,_HEIGHT-20) TO (xMAX,_HEIGHT-20), 15 LOCATE (_HEIGHT/8)-1, 1 : PRINT "Pen:"; LOCATE (_HEIGHT/8), 1 : PRINT "Grid"; END IF RETURN ♻do_refresh: GOSUB 📐do_canvas_resize RETURN ✒change_pen: WHILE _MOUSEBUTTON : WEND LET pen$ = LEFT$(_PROMPT("Enter one simple keyboard character as a new pen shape.", pen$), 1) GOSUB ✒set_pen RETURN ✒do_pen_stroke: new_y = FIX(y%/8)+1 : new_x = FIX(x%/8)+1 LET f_color = 15 : LET b_color = 0 LOCATE new_y, new_x : PRINT pen$; IF grid% THEN GOSUB 🖥do_grid SetLocalStorageItem( "draw:stroke:" + new_y + "," + new_x, pen$ + " " + f_color + "," + b_color) RETURN ✒set_pen: LOCATE (_HEIGHT/8)-1, 5 : PRINT pen$; SetLocalStorageItem( "draw:pen", pen$ ) RETURN