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