If you're having problems implementing the save thing, I tried writing such a function for you:
It assumes you have also defined single number versions of the colors:
The toRGB function looks like this:
Do you really need the array versions of the colors? If you use the single number versions of the colors you can use 'set colori' instead of 'set color'. When you use single numbers it's much easier to compare colors (if pixeli(x, y) = blacki ...).
The program looks great, simple to use!
I've attached the modified source code, changes are marked with Marcus.
Edit The window size was too large for my computer (mini laptop, 1366x768 pixels), but I changed to fullscreen mode, which actually downscales in this case I forgot to change it back, I think ...
Code:
function storefile()
fn = savefiledialog("txt")
if not typeof(fn) return
f = createfile(fn)
for chary = 0 to gridsize - 1
for charx = 0 to gridsize - 1
select pixeli(charx * gsize + 1, chary*gsize + 1)
case blacki write file f, "0"
case orangei write file f, "1"
case yellowi write file f, "2"
case bluei write file f, "6"
case greeni write file f, "7"
case whitei write file f, "8"
case cyani write file f, "9"
default
assert false, "Bad colour"
endsel
next
wln file f
next
free file f
endfunc
It assumes you have also defined single number versions of the colors:
Code:
visible gridcolouri = toRGB(64, 64, 64)
visible bgridcolouri = toRGB(96, 96, 96)
visible redi = toRGB(255, 0, 0)
visible darkredi = toRGB(160, 0, 0)
visible dgreeni = toRGB(0, 128, 0)
visible bluei = toRGB(0, 0, 255)
visible greeni = toRGB(0, 255, 0)
visible yellowi = toRGB(255, 255, 0)
visible blacki = toRGB(0, 0, 0)
visible whitei = toRGB(255, 255, 255)
visible orangei = toRGB(255, 128, 0)
visible cyani = toRGB(0, 255, 255)
The toRGB function looks like this:
Code:
function toRGB(r, g, b)
return 255*16777216 + r*65536 + g*256 + b
endfunc
Do you really need the array versions of the colors? If you use the single number versions of the colors you can use 'set colori' instead of 'set color'. When you use single numbers it's much easier to compare colors (if pixeli(x, y) = blacki ...).
The program looks great, simple to use!
I've attached the modified source code, changes are marked with Marcus.
Edit The window size was too large for my computer (mini laptop, 1366x768 pixels), but I changed to fullscreen mode, which actually downscales in this case I forgot to change it back, I think ...