redraw, and fix floodfill.
This commit is contained in:
parent
9e5db80b0a
commit
b945e5f1b5
2 changed files with 86 additions and 9 deletions
83
pixler.bas
83
pixler.bas
|
|
@ -187,26 +187,93 @@ end sub
|
|||
|
||||
sub redraw
|
||||
redim numarr(0) as long
|
||||
_dest layers(1).ihandle
|
||||
_source layers(1).ihandle
|
||||
cls ,_rgb32(255)
|
||||
_clearcolor _rgb32(255)
|
||||
for i=lbound(commands) to ubound(commands)
|
||||
getnums commands(i),numarr()
|
||||
_dest layers(1).ihandle
|
||||
select case lcase$(_trim$(left$(commands(i),instr(commands(i),"(")-1)))
|
||||
case "canvas"
|
||||
case "fcolor"
|
||||
state.fcolor=numarr(0)
|
||||
case "bcolor"
|
||||
state.bcolor=numarr(0)
|
||||
case "brushsize"
|
||||
state.brushsize=numarr(0)
|
||||
case "pixel"
|
||||
thickpixel numarr(0),numarr(1),numarr(2)
|
||||
case "line"
|
||||
case "brushwidth"
|
||||
thickline numarr(0),numarr(1),numarr(2),numarr(3),numarr(4)
|
||||
case "box"
|
||||
thickbox numarr(0),numarr(1),numarr(2),numarr(3),numarr(4)
|
||||
case "fbox"
|
||||
filledbox numarr(0),numarr(1),numarr(2),numarr(3),numarr(4)
|
||||
case "circle"
|
||||
thickcircle numarr(0),numarr(1),numarr(2),numarr(3)
|
||||
case "fcircle"
|
||||
filledcircle numarr(0),numarr(1),numarr(2),numarr(3)
|
||||
case "polygon"
|
||||
polygon numarr(),state.fcolor
|
||||
case "fpolygon"
|
||||
filledpolygon numarr(),state.fcolor
|
||||
case "floodfill"
|
||||
floodfill numarr(0),numarr(1),numarr(2)
|
||||
case ""
|
||||
' blank line do nothing
|
||||
case else
|
||||
'debug info
|
||||
print "'"+lcase$(_trim$(left$(commands(i),instr(commands(i),"(")-1)))+"'"
|
||||
end select
|
||||
next i
|
||||
_dest 0
|
||||
_source 0
|
||||
end sub
|
||||
|
||||
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
|
||||
|
||||
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$))
|
||||
content$ = ""
|
||||
END IF
|
||||
|
||||
IF LEN(part$) > 0 THEN
|
||||
idx = idx + 1
|
||||
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
|
||||
isHex = 1
|
||||
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
|
||||
|
||||
sub toolbox
|
||||
dim i, x, y
|
||||
dim btnSize : btnSize = 32
|
||||
|
|
@ -420,12 +487,10 @@ sub canvas
|
|||
r = sqr((canX - state.startX)^2 + (canY - state.startY)^2)
|
||||
filledcircle state.startX, state.startY, r, drawCol
|
||||
case 5 ' Rect
|
||||
thickline state.startX, state.startY, canX, state.startY, drawCol
|
||||
thickline canX, state.startY, canX, canY, drawCol
|
||||
thickline canX, canY, state.startX, canY, drawCol
|
||||
thickline state.startX, canY, state.startX, state.startY, drawCol
|
||||
thickbox state.startX,state.starty,canX,canY,drawCol
|
||||
|
||||
case 6 ' Filled Rect
|
||||
line (state.startX, state.startY)-(canX, canY), drawCol, bf
|
||||
filledbox state.startX,state.startY,canX, canY, drawCol
|
||||
case 7, 8 ' Polygons
|
||||
if pointCount > 0 then
|
||||
for p = 1 to pointCount - 1
|
||||
|
|
@ -485,10 +550,12 @@ sub canvas
|
|||
filledcircle state.startX, state.startY, r + 1, drawCol
|
||||
addcommand "fcircle ("+tst(state.startX)+","+tst(state.startY)+","+tst(int(r))+","+hex$(drawCol)+")"
|
||||
case 5 ' Box
|
||||
line (state.startX, state.startY)-(canX, canY), drawCol, b
|
||||
thickbox state.startX,state.starty,canX,canY,drawCol
|
||||
'line (state.startX, state.startY)-(canX, canY), drawCol, b
|
||||
addcommand "box ("+tst(state.startX)+","+tst(state.startY)+","+tst(canX)+","+tst(canY)+","+hex$(drawCol)+")"
|
||||
case 6 ' Filled Box
|
||||
line (state.startX, state.startY)-(canX, canY), drawCol, bf
|
||||
filledbox state.startX,state.startY,canX, canY, drawCol
|
||||
'line (state.startX, state.startY)-(canX, canY), drawCol, bf
|
||||
addcommand "fbox ("+tst(state.startX)+","+tst(state.startY)+","+tst(canX)+","+tst(canY)+","+hex$(drawCol)+")"
|
||||
end select
|
||||
end if
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue