indenting and case lowering
This commit is contained in:
parent
1983b3b32d
commit
7aacca5803
1 changed files with 446 additions and 446 deletions
536
pixler.bas
536
pixler.bas
|
|
@ -46,7 +46,7 @@ _dest layers(0).ihandle
|
|||
addcommand "canvas ("+tst(_width)+","+tst(_height)+")"
|
||||
for y = 0 to _height - 16 step 16
|
||||
for x = 0 to _width - 16 step 16
|
||||
if ((x + y) / 16 AND 1) = 0 then
|
||||
if ((x + y) / 16 and 1) = 0 then
|
||||
line (x, y)-(x + 16, y + 16), _rgb32(127), bf
|
||||
else
|
||||
line (x, y)-(x + 16, y + 16), _rgb32(192), bf
|
||||
|
|
@ -76,7 +76,7 @@ dim oldHeight as integer
|
|||
oldWidth=_width
|
||||
oldHeight=_height
|
||||
do
|
||||
if CheckResize(_source) = -1 THEN
|
||||
if CheckResize(_source) = -1 then
|
||||
diffX = _width - oldWidth
|
||||
diffY = _height - oldHeight
|
||||
state.offsetX = state.offsetX + (diffX / 2)
|
||||
|
|
@ -207,7 +207,7 @@ sub redraw
|
|||
_dest layers(0).ihandle
|
||||
for y = 0 to _height - 16 step 16
|
||||
for x = 0 to _width - 16 step 16
|
||||
if ((x + y) / 16 AND 1) = 0 then
|
||||
if ((x + y) / 16 and 1) = 0 then
|
||||
line (x, y)-(x + 16, y + 16), _rgb32(127), bf
|
||||
else
|
||||
line (x, y)-(x + 16, y + 16), _rgb32(192), bf
|
||||
|
|
@ -236,9 +236,9 @@ sub redraw
|
|||
case "polygon"
|
||||
polygon numarr(),state.fcolor
|
||||
case "fpolygon"
|
||||
filledpolygon numarr(),state.fcolor
|
||||
filledPolygon numarr(),state.fcolor
|
||||
case "floodfill"
|
||||
floodfill numarr(0),numarr(1),numarr(2)
|
||||
FloodFill numarr(0),numarr(1),numarr(2)
|
||||
case ""
|
||||
' blank line do nothing
|
||||
case else
|
||||
|
|
@ -250,48 +250,48 @@ sub redraw
|
|||
_source 0
|
||||
end sub
|
||||
|
||||
SUB getnums (inputStr$, numArray() AS LONG)
|
||||
sub getnums (inputStr$, numArray() as long)
|
||||
' 1. Extract inner content
|
||||
sPos = INSTR(inputStr$, "(")
|
||||
ePos = INSTR(inputStr$, ")")
|
||||
IF sPos = 0 OR ePos <= sPos THEN EXIT SUB
|
||||
sPos = instr(inputStr$, "(")
|
||||
ePos = instr(inputStr$, ")")
|
||||
if sPos = 0 or ePos <= sPos then exit sub
|
||||
|
||||
content$ = MID$(inputStr$, sPos + 1, ePos - sPos - 1)
|
||||
content$ = mid$(inputStr$, sPos + 1, ePos - sPos - 1)
|
||||
idx = -1 ' Start at -1 so the first increment hits 0
|
||||
|
||||
' 2. Parse segments
|
||||
DO
|
||||
cPos = INSTR(content$, ",")
|
||||
IF cPos > 0 THEN
|
||||
part$ = LTRIM$(RTRIM$(LEFT$(content$, cPos - 1)))
|
||||
content$ = MID$(content$, cPos + 1)
|
||||
ELSE
|
||||
part$ = LTRIM$(RTRIM$(content$))
|
||||
do
|
||||
cPos = instr(content$, ",")
|
||||
if cPos > 0 then
|
||||
part$ = ltrim$(rtrim$(left$(content$, cPos - 1)))
|
||||
content$ = mid$(content$, cPos + 1)
|
||||
else
|
||||
part$ = ltrim$(rtrim$(content$))
|
||||
content$ = ""
|
||||
END IF
|
||||
end if
|
||||
|
||||
IF LEN(part$) > 0 THEN
|
||||
if len(part$) > 0 then
|
||||
idx = idx + 1
|
||||
REDIM _PRESERVE numArray(idx) AS LONG
|
||||
redim _preserve numArray(idx) as long
|
||||
|
||||
' Determine if part is Hex (contains A-F)
|
||||
isHex = 0
|
||||
FOR i = 1 TO LEN(part$)
|
||||
c$ = UCASE$(MID$(part$, i, 1))
|
||||
IF c$ >= "A" AND c$ <= "F" THEN
|
||||
for i = 1 to len(part$)
|
||||
c$ = ucase$(mid$(part$, i, 1))
|
||||
if c$ >= "A" and c$ <= "F" then
|
||||
isHex = 1
|
||||
EXIT FOR
|
||||
END IF
|
||||
NEXT i
|
||||
exit for
|
||||
end if
|
||||
next i
|
||||
|
||||
IF isHex THEN
|
||||
numArray(idx) = VAL("&H" + part$)
|
||||
ELSE
|
||||
numArray(idx) = VAL(part$)
|
||||
END IF
|
||||
END IF
|
||||
LOOP WHILE LEN(content$) > 0
|
||||
END SUB
|
||||
if isHex then
|
||||
numArray(idx) = val("&H" + part$)
|
||||
else
|
||||
numArray(idx) = val(part$)
|
||||
end if
|
||||
end if
|
||||
loop while len(content$) > 0
|
||||
end sub
|
||||
|
||||
sub toolbox
|
||||
dim i, x, y
|
||||
|
|
@ -305,7 +305,7 @@ sub toolbox
|
|||
|
||||
' y will only increase every 2 buttons
|
||||
' Use Int() if your language doesn't support the \ operator
|
||||
y = Int(i / 2) * (btnSize + spacing)
|
||||
y = int(i / 2) * (btnSize + spacing)
|
||||
|
||||
if imagebutton(x, y, btnSize, btnSize, icon(i)) then
|
||||
state.tool = i + 1
|
||||
|
|
@ -472,126 +472,126 @@ sub canvas
|
|||
end sub
|
||||
|
||||
sub do.pencil(x as long,y as long, col as long)
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
osource = _source
|
||||
odest = _dest
|
||||
_dest layers(1).ihandle
|
||||
if _mousebutton(1) or _mousebutton(2) then
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
osource = _source
|
||||
odest = _dest
|
||||
_dest layers(1).ihandle
|
||||
if _mousebutton(1) or _mousebutton(2) then
|
||||
thickpixel x,y,col
|
||||
addcommand "pixel ("+tst(x)+","+tst(y)+","+hex$(col)+")"
|
||||
end if
|
||||
state.isdrawing=0
|
||||
_dest odest
|
||||
end if
|
||||
state.isDrawing=0
|
||||
_dest odest
|
||||
end sub
|
||||
|
||||
sub do.line(sx as long,sy as long,ex as long,ey as long,col as long)
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
if state.isdrawing then
|
||||
osource = _source
|
||||
odest = _dest
|
||||
if mouseclicked or rmouseclicked then
|
||||
_dest layers(1).ihandle
|
||||
addcommand "line (" + tst(sx) + "," + tst(sy) + "," + tst(ex) + "," + tst(ey) + "," + hex$(col) + ")"
|
||||
state.isdrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
thickline sx, sy, ex, ey, col
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
if state.isDrawing then
|
||||
osource = _source
|
||||
odest = _dest
|
||||
if mouseclicked or rmouseclicked then
|
||||
_dest layers(1).ihandle
|
||||
addcommand "line (" + tst(sx) + "," + tst(sy) + "," + tst(ex) + "," + tst(ey) + "," + hex$(col) + ")"
|
||||
state.isDrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
thickline sx, sy, ex, ey, col
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub do.circle (x as long,y as long,r as long,col as long)
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
if state.isdrawing then
|
||||
osource = _source
|
||||
odest = _dest
|
||||
if mouseclicked or rmouseclicked then
|
||||
_dest layers(1).ihandle
|
||||
addcommand "circle ("+tst(x)+","+tst(y)+","+tst(int(r))+","+hex$(col)+")"
|
||||
state.isdrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
thickcircle x, y, r, col
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
if state.isDrawing then
|
||||
osource = _source
|
||||
odest = _dest
|
||||
if mouseclicked or rmouseclicked then
|
||||
_dest layers(1).ihandle
|
||||
addcommand "circle ("+tst(x)+","+tst(y)+","+tst(int(r))+","+hex$(col)+")"
|
||||
state.isDrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
thickcircle x, y, r, col
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub do.fcircle (x as long,y as long,r as long,col as long)
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
if state.isdrawing then
|
||||
osource = _source
|
||||
odest = _dest
|
||||
if mouseclicked or rmouseclicked then
|
||||
_dest layers(1).ihandle
|
||||
addcommand "fcircle ("+tst(x)+","+tst(y)+","+tst(int(r))+","+hex$(col)+")"
|
||||
state.isdrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
filledcircle x, y, r, col
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
if state.isDrawing then
|
||||
osource = _source
|
||||
odest = _dest
|
||||
if mouseclicked or rmouseclicked then
|
||||
_dest layers(1).ihandle
|
||||
addcommand "fcircle ("+tst(x)+","+tst(y)+","+tst(int(r))+","+hex$(col)+")"
|
||||
state.isDrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
filledcircle x, y, r, col
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub do.box(sx as long,sy as long,ex as long,ey as long,col as long)
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
if state.isdrawing then
|
||||
osource = _source
|
||||
odest = _dest
|
||||
if mouseclicked or rmouseclicked then
|
||||
_dest layers(1).ihandle
|
||||
addcommand "box ("+tst(sX)+","+tst(sY)+","+tst(eX)+","+tst(eY)+","+hex$(Col)+")"
|
||||
state.isdrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
thickbox sX,sy,eX,eY,Col
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
if state.isDrawing then
|
||||
osource = _source
|
||||
odest = _dest
|
||||
if mouseclicked or rmouseclicked then
|
||||
_dest layers(1).ihandle
|
||||
addcommand "box ("+tst(sx)+","+tst(sy)+","+tst(ex)+","+tst(ey)+","+hex$(col)+")"
|
||||
state.isDrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
thickbox sx,sy,ex,ey,col
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub do.fbox(sx as long,sy as long,ex as long,ey as long,col as long)
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
if state.isdrawing then
|
||||
osource = _source
|
||||
odest = _dest
|
||||
if mouseclicked or rmouseclicked then
|
||||
_dest layers(1).ihandle
|
||||
addcommand "fbox ("+tst(sX)+","+tst(sY)+","+tst(eX)+","+tst(eY)+","+hex$(Col)+")"
|
||||
state.isdrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
filledbox sX,sy,eX,eY,Col
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
if state.isDrawing then
|
||||
osource = _source
|
||||
odest = _dest
|
||||
if mouseclicked or rmouseclicked then
|
||||
_dest layers(1).ihandle
|
||||
addcommand "fbox ("+tst(sx)+","+tst(sy)+","+tst(ex)+","+tst(ey)+","+hex$(col)+")"
|
||||
state.isDrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
filledbox sx,sy,ex,ey,col
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub do.polygon(x as long, y as long)
|
||||
' 1. Internalized State Memory
|
||||
static polypoints(500) as long
|
||||
static pointCount as integer
|
||||
' 1. Internalized State Memory
|
||||
static polypoints(500) as long
|
||||
static pointCount as integer
|
||||
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
dim p as integer
|
||||
dim i as integer
|
||||
dim tmpstr as string
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
dim p as integer
|
||||
dim i as integer
|
||||
dim tmpstr as string
|
||||
|
||||
if state.isdrawing then
|
||||
if state.isDrawing then
|
||||
osource = _source
|
||||
odest = _dest
|
||||
|
||||
|
|
@ -619,7 +619,7 @@ if state.isdrawing then
|
|||
addcommand tmpstr
|
||||
|
||||
' Clean up local tool state
|
||||
state.isdrawing = 0
|
||||
state.isDrawing = 0
|
||||
pointCount = 0
|
||||
else
|
||||
' Live preview rendering loop
|
||||
|
|
@ -634,21 +634,21 @@ if state.isdrawing then
|
|||
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub do.fpolygon(x as long, y as long)
|
||||
' 1. Internalized State Memory
|
||||
static polypoints(500) as long
|
||||
static pointCount as integer
|
||||
' 1. Internalized State Memory
|
||||
static polypoints(500) as long
|
||||
static pointCount as integer
|
||||
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
dim p as integer
|
||||
dim i as integer
|
||||
dim tmpstr as string
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
dim p as integer
|
||||
dim i as integer
|
||||
dim tmpstr as string
|
||||
|
||||
if state.isdrawing then
|
||||
if state.isDrawing then
|
||||
osource = _source
|
||||
odest = _dest
|
||||
|
||||
|
|
@ -666,7 +666,7 @@ if state.isdrawing then
|
|||
redim finalP(pointCount * 2 - 1) as long
|
||||
for p = 0 to (pointCount * 2) - 1: finalP(p) = polypoints(p): next
|
||||
|
||||
filledpolygon finalP(), state.fcolor
|
||||
filledPolygon finalP(), state.fcolor
|
||||
|
||||
tmpstr = "fpolygon ("
|
||||
for i = 0 to ubound(finalP) - 1
|
||||
|
|
@ -676,7 +676,7 @@ if state.isdrawing then
|
|||
addcommand tmpstr
|
||||
|
||||
' Clean up local tool state
|
||||
state.isdrawing = 0
|
||||
state.isDrawing = 0
|
||||
pointCount = 0
|
||||
else
|
||||
' Live preview rendering loop
|
||||
|
|
@ -691,30 +691,30 @@ if state.isdrawing then
|
|||
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub do.floodfill(x as long,y as long, col as long)
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
osource = _source
|
||||
odest = _dest
|
||||
if mouseclicked or rmouseclicked then
|
||||
_source layers(1).ihandle
|
||||
_dest layers(1).ihandle
|
||||
floodfill x,y,col
|
||||
addcommand "floodfill ("+tst(x)+","+tst(y)+","+hex$(col)+")"
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
osource = _source
|
||||
odest = _dest
|
||||
if mouseclicked or rmouseclicked then
|
||||
_source layers(1).ihandle
|
||||
_dest layers(1).ihandle
|
||||
FloodFill x,y,col
|
||||
addcommand "floodfill ("+tst(x)+","+tst(y)+","+hex$(col)+")"
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub do.eyedropper(x,y)
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
osource = _source
|
||||
odest = _dest
|
||||
_source layers(1).ihandle
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
osource = _source
|
||||
odest = _dest
|
||||
_source layers(1).ihandle
|
||||
|
||||
end sub
|
||||
|
||||
|
|
@ -822,98 +822,98 @@ function __internaluiicon&(index as long,imagehandle as long,mode as integer)
|
|||
end function
|
||||
|
||||
|
||||
FUNCTION CheckResize (CurrentScreen AS _UNSIGNED LONG) 'pulled straight out of the wiki'
|
||||
DIM TempScreen AS _UNSIGNED LONG
|
||||
function CheckResize (CurrentScreen as _unsigned long) 'pulled straight out of the wiki'
|
||||
dim TempScreen as _unsigned long
|
||||
CheckResize = 0
|
||||
IF _RESIZE THEN
|
||||
TempScreen = _COPYIMAGE(CurrentScreen, 32)
|
||||
SCREEN TempScreen
|
||||
_FREEIMAGE CurrentScreen
|
||||
CurrentScreen = _NEWIMAGE(_RESIZEWIDTH, _RESIZEHEIGHT, 32)
|
||||
SCREEN CurrentScreen
|
||||
_PUTIMAGE (0, 0), TempScreen, CurrentScreen
|
||||
_DISPLAY
|
||||
_FREEIMAGE TempScreen
|
||||
if _resize then
|
||||
TempScreen = _copyimage(CurrentScreen, 32)
|
||||
screen TempScreen
|
||||
_freeimage CurrentScreen
|
||||
CurrentScreen = _newimage(_resizewidth, _resizeheight, 32)
|
||||
screen CurrentScreen
|
||||
_putimage (0, 0), TempScreen, CurrentScreen
|
||||
_display
|
||||
_freeimage TempScreen
|
||||
CheckResize = -1
|
||||
END IF
|
||||
END FUNCTION
|
||||
end if
|
||||
end function
|
||||
|
||||
sub menu()
|
||||
dim logo as long
|
||||
dim filename as string
|
||||
' A logo is needed'
|
||||
'logo=_loadimage("logo.png")
|
||||
Line (0,0)-(_width-1,_height-1),_rgb32(0,192),bf
|
||||
'_putimage ((_width(0)-_width(logo))/2,10),logo
|
||||
dim i as integer
|
||||
dim fh as integer
|
||||
do until done
|
||||
k$=inkey$
|
||||
while _mouseinput:wend
|
||||
mouseclicked=mbd and not _mousebutton(1)
|
||||
mbd=_mousebutton(1)
|
||||
dim logo as long
|
||||
dim filename as string
|
||||
' A logo is needed'
|
||||
'logo=_loadimage("logo.png")
|
||||
line (0,0)-(_width-1,_height-1),_rgb32(0,192),bf
|
||||
'_putimage ((_width(0)-_width(logo))/2,10),logo
|
||||
dim i as integer
|
||||
dim fh as integer
|
||||
do until done
|
||||
k$=inkey$
|
||||
while _mouseinput:wend
|
||||
mouseclicked=mbd and not _mousebutton(1)
|
||||
mbd=_mousebutton(1)
|
||||
|
||||
if link(10,10,"open") then
|
||||
filename=textinput(10,10,100,23,"")
|
||||
if filename="" then exit sub
|
||||
fh = freefile
|
||||
redim commands(2000) as string
|
||||
open filename for input as fh
|
||||
do until eof(fh)
|
||||
line input #fh, commands(i)
|
||||
i=i+1
|
||||
if i>ubound(commands) then redim _preserve commands(ubound(commands)*2) as string
|
||||
loop
|
||||
close fh
|
||||
redim _preserve commands(i-1) as string
|
||||
redraw
|
||||
done=-1
|
||||
end if
|
||||
if link(10,10,"open") then
|
||||
filename=textinput(10,10,100,23,"")
|
||||
if filename="" then exit sub
|
||||
fh = freefile
|
||||
redim commands(2000) as string
|
||||
open filename for input as fh
|
||||
do until eof(fh)
|
||||
line input #fh, commands(i)
|
||||
i=i+1
|
||||
if i>ubound(commands) then redim _preserve commands(ubound(commands)*2) as string
|
||||
loop
|
||||
close fh
|
||||
redim _preserve commands(i-1) as string
|
||||
redraw
|
||||
done=-1
|
||||
end if
|
||||
|
||||
if link(10,34,"save") then
|
||||
filename=textinput(1,34,100,23,"")
|
||||
if filename="" then exit sub
|
||||
fh = freefile
|
||||
open filename for output as fh
|
||||
for i=0 to ubound(commands)
|
||||
print #fh, commands(i)
|
||||
next i
|
||||
close fh
|
||||
done=-1
|
||||
end if
|
||||
if link(10,34,"save") then
|
||||
filename=textinput(1,34,100,23,"")
|
||||
if filename="" then exit sub
|
||||
fh = freefile
|
||||
open filename for output as fh
|
||||
for i=0 to ubound(commands)
|
||||
print #fh, commands(i)
|
||||
next i
|
||||
close fh
|
||||
done=-1
|
||||
end if
|
||||
|
||||
if link(10,56,"export") then
|
||||
filename=textinput(10,56,100,23,"")
|
||||
if filename="" then exit sub
|
||||
select case lcase$(right$(filename,4))
|
||||
case ".png"
|
||||
save32bitPNG layers(1).ihandle, filename
|
||||
case ".bmp"
|
||||
save24bitBmp layers(1).ihandle, filename
|
||||
case ".ppm"
|
||||
savebinaryPPM layers(1).ihandle, filename
|
||||
case else
|
||||
save32bitPNG layers(1).ihandle, filename
|
||||
end select
|
||||
done=-1
|
||||
end if
|
||||
if link(10,56,"export") then
|
||||
filename=textinput(10,56,100,23,"")
|
||||
if filename="" then exit sub
|
||||
select case lcase$(right$(filename,4))
|
||||
case ".png"
|
||||
save32bitPNG layers(1).ihandle, filename
|
||||
case ".bmp"
|
||||
save24bitBmp layers(1).ihandle, filename
|
||||
case ".ppm"
|
||||
SaveBinaryPPM layers(1).ihandle, filename
|
||||
case else
|
||||
save32bitPNG layers(1).ihandle, filename
|
||||
end select
|
||||
done=-1
|
||||
end if
|
||||
|
||||
if link(10,78,"refenece img") then
|
||||
filename=textinput(10,78,100,23,"")
|
||||
if filename="" then exit sub
|
||||
if not _fileexists(filename) then exit sub
|
||||
if layers(3).ihandle <> 0 then _freeimage layers(3).ihandle
|
||||
layers(3).ihandle=_loadimage(filename)
|
||||
_setalpha 20, layers(3).ihandle
|
||||
done=-1
|
||||
end if
|
||||
if link(10,78,"refenece img") then
|
||||
filename=textinput(10,78,100,23,"")
|
||||
if filename="" then exit sub
|
||||
if not _fileexists(filename) then exit sub
|
||||
if layers(3).ihandle <> 0 then _freeimage layers(3).ihandle
|
||||
layers(3).ihandle=_loadimage(filename)
|
||||
_setalpha 20, layers(3).ihandle
|
||||
done=-1
|
||||
end if
|
||||
|
||||
if link(10,100,"exit") then system
|
||||
if link(10,100,"exit") then system
|
||||
|
||||
if k$=chr$(27) then done=-1
|
||||
_limit 30
|
||||
_display
|
||||
loop
|
||||
if k$=chr$(27) then done=-1
|
||||
_limit 30
|
||||
_display
|
||||
loop
|
||||
end sub
|
||||
|
||||
sub palettemanager(col as _unsigned long)
|
||||
|
|
@ -921,30 +921,30 @@ sub palettemanager(col as _unsigned long)
|
|||
'TODO: build palette mamager ui
|
||||
end sub
|
||||
|
||||
FUNCTION closestcolor~& (colour AS _UNSIGNED LONG, carr() AS _UNSIGNED LONG)
|
||||
DIM r AS INTEGER
|
||||
DIM g AS INTEGER
|
||||
DIM b AS INTEGER
|
||||
DIM ar AS INTEGER
|
||||
DIM ag AS INTEGER
|
||||
DIM ab AS INTEGER
|
||||
DIM i AS INTEGER
|
||||
DIM nearest AS INTEGER
|
||||
DIM shortestdistance AS INTEGER
|
||||
DIM distance AS INTEGER
|
||||
r = _RED (colour)
|
||||
g = _GREEN(colour)
|
||||
b = _BLUE (colour)
|
||||
function closestcolor~& (colour as _unsigned long, carr() as _unsigned long)
|
||||
dim r as integer
|
||||
dim g as integer
|
||||
dim b as integer
|
||||
dim ar as integer
|
||||
dim ag as integer
|
||||
dim ab as integer
|
||||
dim i as integer
|
||||
dim nearest as integer
|
||||
dim shortestdistance as integer
|
||||
dim distance as integer
|
||||
r = _red (colour)
|
||||
g = _green(colour)
|
||||
b = _blue (colour)
|
||||
shortestdistance = 443
|
||||
FOR i = 0 TO UBOUND(carr)
|
||||
ar = _RED (carr(i))
|
||||
ag = _GREEN(carr(i))
|
||||
ab = _BLUE (carr(i))
|
||||
distance = SQR((r - ar) ^ 2 + (g - ag) ^ 2 + (b - ab) ^ 2)
|
||||
IF distance <= shortestdistance THEN shortestdistance = distance: nearest = i
|
||||
NEXT i
|
||||
for i = 0 to ubound(carr)
|
||||
ar = _red (carr(i))
|
||||
ag = _green(carr(i))
|
||||
ab = _blue (carr(i))
|
||||
distance = sqr((r - ar) ^ 2 + (g - ag) ^ 2 + (b - ab) ^ 2)
|
||||
if distance <= shortestdistance then shortestdistance = distance: nearest = i
|
||||
next i
|
||||
closestcolor = carr(nearest)
|
||||
END FUNCTION
|
||||
end function
|
||||
|
||||
' trimmed str$
|
||||
function tst$(numb)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue