' =========================================================
'
' SPRITE DRAW v03 by johnno b+ mods 2020-09-07 comment with " '<
'
' =========================================================
_SCREENMOVE 66, 50 '< get it off my left side title bar, you will likely want some other adjustment
'DIM SHARED clr AS _UNSIGNED LONG
gridcolour
= _RGB32(64, 64, 64)currentcolour
= _RGB32(0, 0, 0)
DIM SHARED gridsize
, gsize
' < the rest of these too gridsize = 64
gsize = 9
psize = 1
tools = 5
resetcurrentcolour = 0
symmetry = 0
exist = 0
' < for ? don't need
'r5 = 0
'g5 = 0
'b5 = 0
zones = 9 ' < mouse cleck areas
quit = 0
'mousegridx = 0
'mousegridy = 0
'mousegridx2 = 0
'mousegridy2 = 0
'DIM SHARED bgrid(gridsize, gridsize)
'DIM SHARED prevgrid(gridsize, gridsize)
buttonclick
= _SNDOPEN("assets/buttonClick.wav")buttonclick2
= _SNDOPEN("assets/buttonClick2.wav")buttonclick3
= _SNDOPEN("assets/buttonClick3.wav")
sample
= _LOADIMAGE("assets/sample64x64.png", 32) ' < ok let's try'PRINT sample '< got it
'end ' < test sample load
setup '< dang where is sample
' Wait for mouse movement or button press
'
' ----------------------------
' Determine Mouse Zone
' ----------------------------
' Zone 1 - Main Grid
'
zone(1) = 1
zone(1) = 0
' Zone 2 - NEW Button
'
zone(2) = 1
zone(2) = 0
' Zone 3 - LOAD Button
'
zone(3) = 1
zone(3) = 0
' Zone 4 - SAVE Button
'
zone(4) = 1
zone(4) = 0
' Zone 5 - QUIT Button
'
zone(5) = 1
zone(5) = 0
' Zone 6 - PENCIL Button
'
zone(6) = 1
zone(6) = 0
' Zone 7 - LINE Button
'
zone(7) = 1
zone(7) = 0
' Zone 8 - MIRROR Button
'
zone(8) = 1
zone(8) = 0
' Zone 9 - CLEAR Button
'
zone(9) = 1
zone(9) = 0
' --------------------
' Draw On Grid
' --------------------
drawongrid
' -----------------------
' Erase From Grid
' -----------------------
erasefromgrid
'updatepreview ' < should these be outside IF?
'redrawgrid
' ------------
' QUIT
' ------------
quit = 1
' ------------------
' LOAD Image
' ------------------
tool(1) = 0
pencil
loadfile
' ------------------
' SAVE Image
' ------------------
'savefile
' -----------------
' NEW Image
' -----------------
newimage
' -------------------
' CLEAR Image
' -------------------
clearimage
' ----------------------
' TOOLS - Pencil
' ----------------------
tool(1) = 1
pencil
tool(2) = 0
drawline
tool(3) = 0
symmetry = 0
mirror
' --------------------------
' TOOLS - Line (wip)
' --------------------------
'tool(1) = 1
'pencil
'tool(2) = 1
'drawline
'tool(3) = 0
'symmetry = 0
'mirror
' ---------------------------------
' TOOLS - Mirror / Symmetry
' ---------------------------------
tool(1) = 1
pencil
tool(2) = 0
drawline
tool(3) = 1
symmetry = 1
mirror
' -----------------------------
' Select Current Colour
' -----------------------------
'convert (currentcolour)
'r5 = getR(currentcolour)
'g5 = getG(currentcolour)
'b5 = getB(currentcolour)
_LIMIT 60 ' <<< cut down the looping save the CPU!
'==================================================================
' ----------------------
' Convert to RGB
' ----------------------
'SUB convert (clr)
' r5 = _RED32(clr)
' g5 = _GREEN32(clr)
' b5 = _BLUE32(clr)
'END SUB
' ==================================================================
'
' PROCEDURES AND FUNCTIONS
'
' ==================================================================
' -----------------------
' Initial Display
' -----------------------
gsize = 9
' ------------------------
' Reset Tool flags
' ------------------------
tool(i) = 0
' ------------------------
' Reset Zone flags
' ------------------------
zone(i) = 0
' ----------------------
' Draw Main Grid
' ----------------------
x = x + gsize
y = y + gsize
'redrawgrid
' ---------------------
' Program Logo
' ---------------------
' -----------------------------
' Colour Selection Grid
' -----------------------------
' ----------------------------------
' Sprite Preview Box - 64x64
' ----------------------------------
_PUTIMAGE (700, 100), sample
, 0 ' < add sample 'update grid
preview2grid
' -----------------------------------------
' Sprite Preview Box - Magnified x2
' -----------------------------------------
' -----------------------------------
' Current Selected Colour Box
' -----------------------------------
' --------------------
' Menu Buttons
' --------------------
' --------------------
' TOOL BUTTONS
' --------------------
' Pencil
tool(1) = 0
' Line
tool(2) = 0
' Mirror / Symmetry
tool(3) = 0
' Spares
LINE (mousegridx
, mousegridy
)-STEP(10, 10), , BF
LINE (mousegridx2
, mousegridy2
)-STEP(10, 10), , BF
LINE (mousegridx
, mousegridy
)-STEP(10, 10), , BF
sure
savefile
exist = 0
tool(1) = 0
pencil
tool(2) = 0
drawline
tool(3) = 0
symmetry = 0
mirror
maingrid(imagex, imagey) = black
COLOR maingrid
(imagex
, imagey
) ' -------------------------
' "Poor Man's" Fill
' -------------------------
'r5 = getR(maingrid[imagex][imagey])
'g5 = getG(maingrid[imagex][imagey])
'b5 = getB(maingrid[imagex][imagey])
'set color r5,g5,b5
dotx = imagex * 10
doty = imagey * 10
' --------------------
' Draw Preview
' --------------------
PSET (700 + imagex
, 100 + imagey
) ' ------------------------------
' Draw Magnified Preview
' ------------------------------
PSET (800 + imagex
, 100 + imagey
)
resetcurrentcolour = 1
redrawgrid
'free file 1
' --------------------
' SCAN IMAGE ?
' --------------------
maingrid
(imagex
, imagey
) = POINT(700 + imagex
, 100 + imagey
) ' -------------------------------
' TRANSFER TO MAIN GRID ?
' -------------------------------
COLOR maingrid
(imagex
, imagey
) ' -------------------------
' "Poor Man's" Fill
' -------------------------
'r5 = getR(maingrid[imagex][imagey])
'g5 = getG(maingrid[imagex][imagey])
'b5 = getB(maingrid[imagex][imagey])
'set color r5,g5,b5
dotx = imagex * 10
doty = imagey * 10
redrawgrid
tool(1) = 0
pencil
tool(2) = 0
drawline
tool(3) = 0
mirror
maingrid(imagex, imagey) = black
COLOR maingrid
(imagex
, imagey
) ' -------------------------
' "Poor Man's" Fill
' -------------------------
'r5 = getR(maingrid[imagex][imagey])
'g5 = getG(maingrid[imagex][imagey])
'b5 = getB(maingrid[imagex][imagey])
'set color r5,g5,b5
dotx = imagex * 10
doty = imagey * 10
' --------------------
' Draw Preview
' --------------------
PSET (700 + imagex
, 100 + imagey
) ' ------------------------------
' Draw Magnified Preview
' ------------------------------
PSET (800 + imagex
, 100 + imagey
)
resetcurrentcolour = 1
redrawgrid
'free file 1
exist = 0
exist = 1
' -----------------------
' TOOL PROCEDURES
' -----------------------
tool(2) = 0
drawline
tool(3) = 0
symmetry = 0
mirror
' -------------------------------------
' Change state of 'line' button
' -------------------------------------
'IF tool(2) = 0 THEN
'COLOR gridcolour
'LINE (1014, 148)-STEP(80, 40), , B
'_PRINTSTRING (1022, 151), "Line"
'END IF
'IF tool(2) = 1 THEN
'COLOR white
'LINE (1014, 148)-STEP(80, 40), , B
'COLOR yellow
'_PRINTSTRING (1022, 151), "Line"
'COLOR gridcolour
'END IF
' -----------------------------------------
' Line function goes here... W.I.P.
' -----------------------------------------
'COLOR currentcolour
'x1 = 0
'x2 = 0
'y1 = 0
'y2 = 0
'click = 0
'WHILE click = 0
'IF _MOUSEBUTTON(1) AND zone(1) = 1 THEN
'click = 1
'x = _MOUSEX
'y = _MOUSEY
'x1 = x
'y1 = y
'mousegridx = INT(x1 / 10) * 10
'mousegridy = INT(y1 / 10) * 10
'LINE (mousegridx, mousegridy)-STEP(10, 10), , BF
'END IF
'IF mb2 AND zone(1) = 1 THEN
' x = _MOUSEX
'y = _MOUSEY
'x2 = x
'y2 = y
'mousegridx = INT(x2 / 10) * 10
'mousegridy = INT(y2 / 10) * 10
'LINE (mousegridx, mousegridy)-STEP(10, 10), , BF
'click = 1
'dx = ABS(x2 - x1)
'sx = -1
'IF x1 < x2 THEN sx = 1
'dy = ABS(y2 - y1)
'sy = -1
'IF y1 < y2 THEN sy = 1
'er = -dy
'IF dx > dy THEN er = dx
'er = INT(er / 2)
'DO
' LINE (INT(x1 / 10) * 10, INT(y1 / 10) * 10)-STEP(10, 10), , BF
'e2 = er
'IF e2 > -dx THEN
' er = er - dy
'x1 = x1 + sx
'END IF
'IF e2 < dy THEN
' er = er + dx
'y1 = y1 + sy
'END IF
'_DISPLAY
'LOOP UNTIL x1 = x2 AND y1 = y2
'END IF
'_DISPLAY
'IF INKEY$ = CHR$(27) THEN SYSTEM
'WEND
'END IF
'
' Change state of 'symmetry' button
'
gsize = 9
x = x + gsize
y = y + gsize
PSET (700 + prevx
, 100 + prevy
) ' Magnified Preview
PSET (800 + (prevx
* 2), 100 + (prevy
* 2)) PSET (801 + (prevx
* 2), 100 + (prevy
* 2))
PSET (800 + (prevx
* 2), 101 + (prevy
* 2)) PSET (801 + (prevx
* 2), 101 + (prevy
* 2))
'REM draw rect 800+(prevx*2),100+(prevy*2),2,2,true
SUB preview2grid
'< this whole sub LINE (prevx
* 10, prevy
* 10)-STEP(gsize
, gsize
), , BF