even lower cases, less spaces saving space.
This commit is contained in:
parent
f5add49708
commit
73e1655b80
1 changed files with 360 additions and 360 deletions
356
pixler.bas
356
pixler.bas
|
|
@ -2,13 +2,13 @@ type statetype
|
|||
tool as long
|
||||
fcolor as long
|
||||
bcolor as long
|
||||
offsetX as long
|
||||
offsetY as long
|
||||
offsetx as long
|
||||
offsety as long
|
||||
zoom as single
|
||||
brushsize as integer
|
||||
startX as long
|
||||
startY as long
|
||||
isDrawing as integer
|
||||
startx as long
|
||||
starty as long
|
||||
isdrawing as integer
|
||||
end type
|
||||
|
||||
type layertype
|
||||
|
|
@ -56,33 +56,33 @@ next
|
|||
_dest 0
|
||||
state.tool=1
|
||||
state.zoom=1.0
|
||||
state.offsetX = 70 + 20
|
||||
state.offsetY = 20
|
||||
state.offsetx=70+20
|
||||
state.offsety=20
|
||||
state. brushsize=1
|
||||
state.fcolor=closestcolor(_rgb32(0,0,0),pal())
|
||||
state.bcolor=closestcolor(_rgb32(255,255,255),pal())
|
||||
addcommand"fcolor ("+hex$(state.fcolor)+")"
|
||||
addcommand"bcolor ("+hex$(state.bcolor)+")"
|
||||
|
||||
dim lastMX, lastMY
|
||||
dim lastmx,lastmy
|
||||
dim keyin as string
|
||||
dim mouseWorldY as integer
|
||||
dim mouseWorldX as integer
|
||||
dim mouseworldy as integer
|
||||
dim mouseworldx as integer
|
||||
|
||||
dim diffX as integer
|
||||
dim diffY as integer
|
||||
dim oldWidth as integer
|
||||
dim oldHeight as integer
|
||||
oldWidth=_width
|
||||
oldHeight=_height
|
||||
dim diffx as integer
|
||||
dim diffy as integer
|
||||
dim oldwidth as integer
|
||||
dim oldheight as integer
|
||||
oldwidth=_width
|
||||
oldheight=_height
|
||||
do
|
||||
if CheckResize(_source) = -1 then
|
||||
diffX = _width - oldWidth
|
||||
diffY = _height - oldHeight
|
||||
state.offsetX = state.offsetX + (diffX / 2)
|
||||
state.offsetY = state.offsetY + (diffY / 2)
|
||||
oldWidth = _width
|
||||
oldHeight = _height
|
||||
if checkresize(_source)=-1 then
|
||||
diffx=_width-oldwidth
|
||||
diffy=_height-oldheight
|
||||
state.offsetx=state.offsetx+(diffx/2)
|
||||
state.offsety=state.offsety+(diffy/2)
|
||||
oldwidth=_width
|
||||
oldheight=_height
|
||||
end if
|
||||
|
||||
canvas
|
||||
|
|
@ -101,16 +101,16 @@ do
|
|||
|
||||
' Panning (Middle Mouse)
|
||||
if _mousebutton(3) then
|
||||
state.offsetX = int(state.offsetX + (_mousex - lastMX))
|
||||
state.offsetY = int(state.offsetY + (_mousey - lastMY))
|
||||
state.offsetx=int(state.offsetx+(_mousex-lastmx))
|
||||
state.offsety=int(state.offsety+(_mousey-lastmy))
|
||||
end if
|
||||
lastMX = _mousex: lastMY = _mousey
|
||||
lastmx=_mousex:lastmy=_mousey
|
||||
|
||||
' Zooming
|
||||
if mw<>0 then
|
||||
' 1. Capture current world position
|
||||
mouseWorldX = (_mousex - state.offsetX) / state.zoom
|
||||
mouseWorldY = (_mousey - state.offsetY) / state.zoom
|
||||
mouseworldx=(_mousex-state.offsetx)/state.zoom
|
||||
mouseworldy=(_mousey-state.offsety)/state.zoom
|
||||
|
||||
' 2. Calculate the new zoom level (Snap to whole numbers)
|
||||
if mw>0 then
|
||||
|
|
@ -124,8 +124,8 @@ do
|
|||
if state.zoom>20 then state.zoom=20
|
||||
|
||||
' 4. Adjust offsets
|
||||
state.offsetX = _mousex - (mouseWorldX * state.zoom)
|
||||
state.offsetY = _mousey - (mouseWorldY * state.zoom)
|
||||
state.offsetx=_mousex-(mouseworldx*state.zoom)
|
||||
state.offsety=_mousey-(mouseworldy*state.zoom)
|
||||
|
||||
mw=0
|
||||
end if
|
||||
|
|
@ -145,8 +145,8 @@ do
|
|||
menu
|
||||
case "h"
|
||||
state.zoom=1.0
|
||||
state.offsetX=(_width/2)- (_width(layers(0).ihandle)/2)
|
||||
state.offsetY=(_height/2)- (_height(layers(0).ihandle)/2)
|
||||
state.offsetx=(_width/2)-(_width(layers(0).ihandle)/2)
|
||||
state.offsety=(_height/2)-(_height(layers(0).ihandle)/2)
|
||||
case "t"
|
||||
showtoolbox=not showtoolbox
|
||||
case "c"
|
||||
|
|
@ -162,8 +162,8 @@ loop
|
|||
|
||||
sub commandlist
|
||||
dim i as long
|
||||
dim listWidth as integer:listWidth = 250
|
||||
dim x as integer:x=_width-listWidth
|
||||
dim listwidth as integer:listwidth=250
|
||||
dim x as integer:x=_width-listwidth
|
||||
|
||||
' Draw background for the list
|
||||
line (x,0)-(_width-1,_height-1),backgroundcolor1,bf
|
||||
|
|
@ -235,9 +235,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
|
||||
|
|
@ -249,21 +249,21 @@ 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)
|
||||
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$=""
|
||||
|
|
@ -271,22 +271,22 @@ sub getnums (inputStr$, numArray() as long)
|
|||
|
||||
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
|
||||
ishex=0
|
||||
for i=1 to len(part$)
|
||||
c$=ucase$(mid$(part$,i,1))
|
||||
if c$>="A"and c$<="F"then
|
||||
isHex = 1
|
||||
ishex=1
|
||||
exit for
|
||||
end if
|
||||
next i
|
||||
|
||||
if isHex then
|
||||
numArray(idx) = val("&H" + part$)
|
||||
if ishex then
|
||||
numarray(idx)=val("&H"+part$)
|
||||
else
|
||||
numArray(idx) = val(part$)
|
||||
numarray(idx)=val(part$)
|
||||
end if
|
||||
end if
|
||||
loop while len(content$)>0
|
||||
|
|
@ -294,25 +294,25 @@ end sub
|
|||
|
||||
sub toolbox
|
||||
dim i,x,y
|
||||
dim btnSize : btnSize = 32
|
||||
dim btnsize:btnsize=32
|
||||
dim spacing:spacing=1
|
||||
|
||||
for i=0 to 19
|
||||
' Force integer math to keep columns locked at 2
|
||||
' x will only ever be 0 or 33
|
||||
x = (i mod 2) * (btnSize + spacing)
|
||||
x=(i mod 2)*(btnsize+spacing)
|
||||
|
||||
' 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
|
||||
if imagebutton(x,y,btnsize,btnsize,icon(i)) then
|
||||
state.tool=i+1
|
||||
end if
|
||||
next
|
||||
|
||||
'colorindicator
|
||||
y=y+btnSize+16
|
||||
y=y+btnsize+16
|
||||
line (16,y+16)-(64,y+64),state.bcolor,bf
|
||||
line (16,y+16)-(64,y+64),highlightcolor,b
|
||||
line (0,y)-(48,y+48),state.fcolor,bf
|
||||
|
|
@ -354,57 +354,57 @@ end sub
|
|||
|
||||
sub canvas
|
||||
' 1. Define the Viewport (The "Window" on your screen)
|
||||
dim viewX1 as integer
|
||||
if showtoolbox then viewX1 = 70 else viewX1 = 0
|
||||
dim viewY1 as integer: viewY1 = 0
|
||||
dim viewX2 as integer
|
||||
if showcommands then viewX2 = _width - 151 else viewX2 = _width - 1
|
||||
dim viewY2 as integer
|
||||
if showcolorpicker then viewY2 = _height - 20 else viewY2 = _height - 1
|
||||
dim viewx1 as integer
|
||||
if showtoolbox then viewx1=70 else viewx1=0
|
||||
dim viewy1 as integer:viewy1=0
|
||||
dim viewx2 as integer
|
||||
if showcommands then viewx2=_width-151 else viewx2=_width-1
|
||||
dim viewy2 as integer
|
||||
if showcolorpicker then viewy2=_height-20 else viewy2=_height-1
|
||||
_dest 0
|
||||
|
||||
' 2. Render Layers with Clipping
|
||||
dim srcX1 as long
|
||||
dim srcY1 as long
|
||||
dim srcX2 as long
|
||||
dim srcY2 as long
|
||||
dim drawX1 as long
|
||||
dim drawY1 as long
|
||||
dim drawX2 as long
|
||||
dim drawY2 as long
|
||||
dim srcx1 as long
|
||||
dim srcy1 as long
|
||||
dim srcx2 as long
|
||||
dim srcy2 as long
|
||||
dim drawx1 as long
|
||||
dim drawy1 as long
|
||||
dim drawx2 as long
|
||||
dim drawy2 as long
|
||||
|
||||
dim i as integer
|
||||
for i=0 to ubound(layers)
|
||||
dim img as long:img=layers(i).ihandle
|
||||
dim imgW as integer: imgW = _width(img)
|
||||
dim imgH as integer: imgH = _height(img)
|
||||
dim imgw as integer:imgw=_width(img)
|
||||
dim imgh as integer:imgh=_height(img)
|
||||
|
||||
' Current scaled dimensions
|
||||
dim fullScaledW as single: fullScaledW = imgW * state.zoom
|
||||
dim fullScaledH as single: fullScaledH = imgH * state.zoom
|
||||
dim fullscaledw as single:fullscaledw=imgw*state.zoom
|
||||
dim fullscaledh as single:fullscaledh=imgh*state.zoom
|
||||
|
||||
' Calculate visible area in screen coordinates (Overlap of image and viewport)
|
||||
drawX1 = state.offsetX
|
||||
drawY1 = state.offsetY
|
||||
drawX2 = state.offsetX + fullScaledW
|
||||
drawY2 = state.offsetY + fullScaledH
|
||||
drawx1=state.offsetx
|
||||
drawy1=state.offsety
|
||||
drawx2=state.offsetx+fullscaledw
|
||||
drawy2=state.offsety+fullscaledh
|
||||
|
||||
' Clip the destination to the Viewport
|
||||
if drawX1 < viewX1 then drawX1 = viewX1
|
||||
if drawY1 < viewY1 then drawY1 = viewY1
|
||||
if drawX2 > viewX2 then drawX2 = viewX2
|
||||
if drawY2 > viewY2 then drawY2 = viewY2
|
||||
if drawx1<viewx1 then drawx1=viewx1
|
||||
if drawy1<viewy1 then drawy1=viewy1
|
||||
if drawx2>viewx2 then drawx2=viewx2
|
||||
if drawy2>viewy2 then drawy2=viewy2
|
||||
|
||||
' Only draw if the image is actually inside the viewport
|
||||
if drawX2 > drawX1 and drawY2 > drawY1 then
|
||||
if drawx2>drawx1 and drawy2>drawy1 then
|
||||
' Map screen-clipped coordinates back to the source image coordinates
|
||||
srcX1 = int((drawX1 - state.offsetX) / state.zoom)
|
||||
srcY1 = int((drawY1 - state.offsetY) / state.zoom)
|
||||
srcX2 = int((drawX2 - state.offsetX) / state.zoom)
|
||||
srcY2 = int((drawY2 - state.offsetY) / state.zoom)
|
||||
srcx1=int((drawx1-state.offsetx)/state.zoom)
|
||||
srcy1=int((drawy1-state.offsety)/state.zoom)
|
||||
srcx2=int((drawx2-state.offsetx)/state.zoom)
|
||||
srcy2=int((drawy2-state.offsety)/state.zoom)
|
||||
|
||||
' Syntax: _PUTIMAGE (destX1, destY1)-(destX2, destY2), sourceHandle, 0, (srcX1, srcY1)-(srcX2, srcY2)
|
||||
_putimage (drawX1, drawY1)-(drawX2, drawY2), img, 0, (srcX1, srcY1)-(srcX2, srcY2)
|
||||
_putimage (drawx1,drawy1)-(drawx2,drawy2),img,0,(srcx1,srcy1)-(srcx2,srcy2)
|
||||
end if
|
||||
next
|
||||
_dest layers(2).ihandle:cls,0:_dest 0
|
||||
|
|
@ -420,7 +420,7 @@ sub canvas
|
|||
end if
|
||||
end if
|
||||
if showcommands then
|
||||
if _mousex >= drawX2 then
|
||||
if _mousex>=drawx2 then
|
||||
exit sub
|
||||
end if
|
||||
end if
|
||||
|
|
@ -428,45 +428,45 @@ sub canvas
|
|||
dim r as integer
|
||||
|
||||
' 3. Calculate Canvas Coordinates
|
||||
dim canX as long
|
||||
dim canY as long
|
||||
canX = int((_mousex - state.offsetX) / state.zoom)
|
||||
canY = int((_mousey - state.offsetY) / state.zoom)
|
||||
dim canx as long
|
||||
dim cany as long
|
||||
canx=int((_mousex-state.offsetx)/state.zoom)
|
||||
cany=int((_mousey-state.offsety)/state.zoom)
|
||||
|
||||
static polypoints(200) as single
|
||||
static pointCount as integer
|
||||
static pointcount as integer
|
||||
|
||||
static drawCol
|
||||
if _mousebutton(1) then drawCol = state.fcolor
|
||||
if _mousebutton(2) then drawCol = state.bcolor
|
||||
static drawcol
|
||||
if _mousebutton(1) then drawcol=state.fcolor
|
||||
if _mousebutton(2) then drawcol=state.bcolor
|
||||
|
||||
if (mousedown or rmousedown) and state.isDrawing = 0 then
|
||||
state.startX = canX
|
||||
state.startY = canY
|
||||
state.isDrawing = -1
|
||||
if (mousedown or rmousedown) and state.isdrawing=0 then
|
||||
state.startx=canx
|
||||
state.starty=cany
|
||||
state.isdrawing=-1
|
||||
end if
|
||||
|
||||
select case state.tool
|
||||
case 1
|
||||
do.pencil canX,canY,drawCol
|
||||
do.pencil canx,cany,drawcol
|
||||
case 2
|
||||
do.line state.startX,state.startY,canX,canY,drawCol
|
||||
do.line state.startx,state.starty,canx,cany,drawcol
|
||||
case 3
|
||||
do.circle state.startX,state.startY,sqr((canX - state.startX)^2 + (canY - state.startY)^2),drawCol
|
||||
do.circle state.startx,state.starty,sqr((canx-state.startx)^2+(cany-state.starty)^2),drawcol
|
||||
case 4
|
||||
do.fcircle state.startX,state.startY,sqr((canX - state.startX)^2 + (canY - state.startY)^2),drawCol
|
||||
do.fcircle state.startx,state.starty,sqr((canx-state.startx)^2+(cany-state.starty)^2),drawcol
|
||||
case 5
|
||||
do.box state.startX,state.startY,canX,canY,drawCol
|
||||
do.box state.startx,state.starty,canx,cany,drawcol
|
||||
case 6
|
||||
do.fbox state.startX,state.startY,canX,canY,drawCol
|
||||
do.fbox state.startx,state.starty,canx,cany,drawcol
|
||||
case 7
|
||||
do.polygon canX,canY
|
||||
do.polygon canx,cany
|
||||
case 8
|
||||
do.fpolygon canX,canY
|
||||
do.fpolygon canx,cany
|
||||
case 9
|
||||
do.floodfill canX,canY,drawCol
|
||||
do.floodfill canx,cany,drawcol
|
||||
case 10
|
||||
do.eyedropper canX,canY
|
||||
do.eyedropper canx,cany
|
||||
end select
|
||||
end sub
|
||||
|
||||
|
|
@ -480,20 +480,20 @@ sub do.pencil(x as long,y as long, col as long)
|
|||
thickpixel x,y,col
|
||||
addcommand"pixel ("+tst(x)+","+tst(y)+","+hex$(col)+")"
|
||||
end if
|
||||
state.isDrawing=0
|
||||
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
|
||||
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
|
||||
state.isdrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
|
|
@ -506,13 +506,13 @@ 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
|
||||
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
|
||||
state.isdrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
|
|
@ -525,13 +525,13 @@ 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
|
||||
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
|
||||
state.isdrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
|
|
@ -544,13 +544,13 @@ 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
|
||||
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
|
||||
state.isdrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
|
|
@ -563,13 +563,13 @@ 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
|
||||
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
|
||||
state.isdrawing=0
|
||||
else
|
||||
_dest layers(2).ihandle
|
||||
end if
|
||||
|
|
@ -582,7 +582,7 @@ end sub
|
|||
sub do.polygon(x as long,y as long)
|
||||
' 1. Internalized State Memory
|
||||
static polypoints(500) as long
|
||||
static pointCount as integer
|
||||
static pointcount as integer
|
||||
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
|
|
@ -590,44 +590,44 @@ sub do.polygon(x as long, y as long)
|
|||
dim i as integer
|
||||
dim tmpstr as string
|
||||
|
||||
if state.isDrawing then
|
||||
if state.isdrawing then
|
||||
osource=_source
|
||||
odest=_dest
|
||||
|
||||
' If left-clicked, add the coordinate to this routine's local array
|
||||
if mouseclicked then
|
||||
polypoints(pointCount * 2) = x
|
||||
polypoints(pointCount * 2 + 1) = y
|
||||
pointCount = pointCount + 1
|
||||
polypoints(pointcount*2)=x
|
||||
polypoints(pointcount*2+1)=y
|
||||
pointcount=pointcount+1
|
||||
end if
|
||||
|
||||
' Finish shape on Right-Click
|
||||
if rmouseclicked and pointCount > 2 then
|
||||
if rmouseclicked and pointcount>2 then
|
||||
_dest layers(1).ihandle
|
||||
|
||||
redim finalP(pointCount * 2 - 1) as long
|
||||
for p = 0 to (pointCount * 2) - 1: finalP(p) = polypoints(p): next
|
||||
redim finalp(pointcount*2-1) as long
|
||||
for p=0 to (pointcount*2)-1:finalp(p)=polypoints(p):next
|
||||
|
||||
polygon finalP(), state.fcolor
|
||||
polygon finalp(),state.fcolor
|
||||
|
||||
tmpstr="polygon ("
|
||||
for i = 0 to ubound(finalP) - 1
|
||||
tmpstr = tmpstr + tst(finalP(i)) + ","
|
||||
for i=0 to ubound(finalp)-1
|
||||
tmpstr=tmpstr+tst(finalp(i))+","
|
||||
next i
|
||||
tmpstr = tmpstr + tst(finalP(i)) + ")"
|
||||
tmpstr=tmpstr+tst(finalp(i))+")"
|
||||
addcommand tmpstr
|
||||
|
||||
' Clean up local tool state
|
||||
state.isDrawing = 0
|
||||
pointCount = 0
|
||||
state.isdrawing=0
|
||||
pointcount=0
|
||||
else
|
||||
' Live preview rendering loop
|
||||
_dest layers(2).ihandle
|
||||
if pointCount > 0 then
|
||||
for p = 1 to pointCount - 1
|
||||
if pointcount>0 then
|
||||
for p=1 to pointcount-1
|
||||
thickline polypoints((p-1)*2),polypoints((p-1)*2+1),polypoints(p*2),polypoints(p*2+1),state.fcolor
|
||||
next p
|
||||
thickline polypoints((pointCount - 1) * 2), polypoints((pointCount - 1) * 2 + 1), x, y, state.fcolor
|
||||
thickline polypoints((pointcount-1)*2),polypoints((pointcount-1)*2+1),x,y,state.fcolor
|
||||
end if
|
||||
end if
|
||||
|
||||
|
|
@ -639,7 +639,7 @@ end sub
|
|||
sub do.fpolygon(x as long,y as long)
|
||||
' 1. Internalized State Memory
|
||||
static polypoints(500) as long
|
||||
static pointCount as integer
|
||||
static pointcount as integer
|
||||
|
||||
dim osource as long
|
||||
dim odest as long
|
||||
|
|
@ -647,44 +647,44 @@ sub do.fpolygon(x as long, y as long)
|
|||
dim i as integer
|
||||
dim tmpstr as string
|
||||
|
||||
if state.isDrawing then
|
||||
if state.isdrawing then
|
||||
osource=_source
|
||||
odest=_dest
|
||||
|
||||
' If left-clicked, add the coordinate to this routine's local array
|
||||
if mouseclicked then
|
||||
polypoints(pointCount * 2) = x
|
||||
polypoints(pointCount * 2 + 1) = y
|
||||
pointCount = pointCount + 1
|
||||
polypoints(pointcount*2)=x
|
||||
polypoints(pointcount*2+1)=y
|
||||
pointcount=pointcount+1
|
||||
end if
|
||||
|
||||
' Finish shape on Right-Click
|
||||
if rmouseclicked and pointCount > 2 then
|
||||
if rmouseclicked and pointcount>2 then
|
||||
_dest layers(1).ihandle
|
||||
|
||||
redim finalP(pointCount * 2 - 1) as long
|
||||
for p = 0 to (pointCount * 2) - 1: finalP(p) = polypoints(p): next
|
||||
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
|
||||
tmpstr = tmpstr + tst(finalP(i)) + ","
|
||||
for i=0 to ubound(finalp)-1
|
||||
tmpstr=tmpstr+tst(finalp(i))+","
|
||||
next i
|
||||
tmpstr = tmpstr + tst(finalP(i)) + ")"
|
||||
tmpstr=tmpstr+tst(finalp(i))+")"
|
||||
addcommand tmpstr
|
||||
|
||||
' Clean up local tool state
|
||||
state.isDrawing = 0
|
||||
pointCount = 0
|
||||
state.isdrawing=0
|
||||
pointcount=0
|
||||
else
|
||||
' Live preview rendering loop
|
||||
_dest layers(2).ihandle
|
||||
if pointCount > 0 then
|
||||
for p = 1 to pointCount - 1
|
||||
if pointcount>0 then
|
||||
for p=1 to pointcount-1
|
||||
thickline polypoints((p-1)*2),polypoints((p-1)*2+1),polypoints(p*2),polypoints(p*2+1),state.fcolor
|
||||
next p
|
||||
thickline polypoints((pointCount - 1) * 2), polypoints((pointCount - 1) * 2 + 1), x, y, state.fcolor
|
||||
thickline polypoints((pointcount-1)*2),polypoints((pointcount-1)*2+1),x,y,state.fcolor
|
||||
end if
|
||||
end if
|
||||
|
||||
|
|
@ -701,9 +701,9 @@ sub do.floodfill(x as long,y as long, col as long)
|
|||
if mouseclicked or rmouseclicked then
|
||||
_source layers(1).ihandle
|
||||
_dest layers(1).ihandle
|
||||
FloodFill x,y,col
|
||||
floodfill x,y,col
|
||||
addcommand"floodfill ("+tst(x)+","+tst(y)+","+hex$(col)+")"
|
||||
state.isDrawing = 0
|
||||
state.isdrawing=0
|
||||
_source osource
|
||||
_dest odest
|
||||
end if
|
||||
|
|
@ -718,14 +718,14 @@ sub do.eyedropper(x as long, y as long)
|
|||
if x>=0 and x<_width(layers(1).ihandle) and y>=0 and y<_height(layers(1).ihandle) then
|
||||
' Left click sets foreground color, Right click sets background color
|
||||
if _mousebutton(1) then
|
||||
state.fcolor = pickedColor
|
||||
state.fcolor=point(x,y)
|
||||
addcommand"fcolor ("+hex$(point(x,y))+")"
|
||||
elseif _mousebutton(2) then
|
||||
state.bcolor = pickedColor
|
||||
state.bcolor=point(x,y)
|
||||
addcommand"bcolor ("+hex$(point(x,y))+")"
|
||||
end if
|
||||
end if
|
||||
state.isDrawing = 0
|
||||
state.isdrawing=0
|
||||
_source osource
|
||||
end if
|
||||
end sub
|
||||
|
|
@ -821,7 +821,7 @@ function icon (index as long)
|
|||
if index>=0 and index<=19 then
|
||||
icon=icons(index)
|
||||
else
|
||||
icon = icons(0)
|
||||
icon=icons(9)
|
||||
end if
|
||||
end function
|
||||
|
||||
|
|
@ -889,19 +889,19 @@ 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
|
||||
CheckResize = 0
|
||||
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
|
||||
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
|
||||
_freeimage tempscreen
|
||||
checkresize=-1
|
||||
end if
|
||||
end function
|
||||
|
||||
|
|
@ -954,13 +954,13 @@ sub menu()
|
|||
if filename=""then exit sub
|
||||
select case lcase$(right$(filename,4))
|
||||
case ".png"
|
||||
save32bitPNG layers(1).ihandle, filename
|
||||
save32bitpng layers(1).ihandle,filename
|
||||
case ".bmp"
|
||||
save24bitBmp layers(1).ihandle, filename
|
||||
save24bitbmp layers(1).ihandle,filename
|
||||
case ".ppm"
|
||||
SaveBinaryPPM layers(1).ihandle, filename
|
||||
savebinaryppm layers(1).ihandle,filename
|
||||
case else
|
||||
save32bitPNG layers(1).ihandle, filename
|
||||
save32bitpng layers(1).ihandle,filename
|
||||
end select
|
||||
done=-1
|
||||
end if
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue