Compare commits

..

No commits in common. "b978f2e8cfecf70f756ad48a014f5c12c6a59b7f" and "6435128e224a54d6cd952a58447ae6df9478c23f" have entirely different histories.

2 changed files with 10 additions and 30 deletions

View file

@ -42,21 +42,13 @@ sub filledPolygon (Points() as long, col as long)
next y next y
end sub end sub
sub thickpixel(x,y,col as long)
if state.brushsize=1 then
pset(x,y),col
else
line(x-0.5 * state.brushsize,y-0.5 * state.brushsize)-(x+0.5 * state.brushsize,y+0.5 * state.brushsize),col,bf
end if
end sub
sub thickline(x1,y1,x2,y2, col as long) sub thickline(x1,y1,x2,y2, col as long)
if state.brushsize=1 then if state.brushsize=1 then
line(x1,y1)-(x2,y2),col line(x1,y1)-(x2,y2),col
else else
dim tempimg as long dim tempimg as long
dim od as long dim od as long
tempimg=_newimage(1,1,32) tempimg=_newimage(10,10,32)
od =_dest od =_dest
_dest tempimg _dest tempimg
pset(0,0),col pset(0,0),col

View file

@ -6,8 +6,8 @@ type statetype
offsetY as long offsetY as long
zoom as single zoom as single
brushsize as integer brushsize as integer
startX as long startX as integer
startY as long startY as integer
isDrawing as integer isDrawing as integer
end type end type
@ -43,9 +43,9 @@ layers(2).ihandle=_newimage(320,320,32)
layers(3).ihandle=_newimage(320,320,32) layers(3).ihandle=_newimage(320,320,32)
_dest layers(0).ihandle _dest layers(0).ihandle
addcommand "canvas ("+str$(_width)+","+str$(_height)+")"
line (0,0)-(_width-1,_height-1),_rgb32(255),bf line (0,0)-(_width-1,_height-1),_rgb32(255),bf
_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
@ -129,10 +129,8 @@ canvas
select case keyin select case keyin
case "+" case "+"
state.brushsize=state.brushsize+1 state.brushsize=state.brushsize+1
addcommand "brushsize ("+str$(state.brushsize)+")"
case "-" case "-"
if state.brushsize>1 then state.brushsize=state.brushsize-1 if state.brushsize>1 then state.brushsize=state.brushsize-1
addcommand "brushsize ("+str$(state.brushsize)+")"
case chr$(19) ' ctrl+s case chr$(19) ' ctrl+s
'TODO: save logic 'TODO: save logic
case chr$(27)' esc case chr$(27)' esc
@ -305,8 +303,8 @@ 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 integer
dim canY as long dim canY as integer
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)
@ -372,13 +370,8 @@ sub canvas
select case state.tool select case state.tool
case 1 ' Pencil case 1 ' Pencil
_dest layers(1).ihandle _dest layers(1).ihandle
if canX=state.startX and canY=state.startY then thickline state.startX, state.startY, canX, canY, drawCol
thickpixel canX,canY,drawCol addcommand "line ("+str$(state.startX)+","+ str$(state.startY)+","+str$(canX)+","+str$(canY)+","+hex$(drawCol)+")"
addcommand "pixel ("+str$(canX)+","+str$(canY)+","+hex$(drawCol)+")"
else
thickline state.startX, state.startY, canX, canY, drawCol
addcommand "line ("+str$(state.startX)+","+str$(state.startY)+","+str$(canX)+","+str$(canY)+","+hex$(drawCol)+")"
end if
state.startX = canX: state.startY = canY state.startX = canX: state.startY = canY
case 2 ' Straight Line case 2 ' Straight Line
thickline state.startX, state.startY, canX, canY, drawCol thickline state.startX, state.startY, canX, canY, drawCol
@ -440,13 +433,8 @@ sub canvas
'_putimage , layers(2).ihandle, layers(1).ihandle '_putimage , layers(2).ihandle, layers(1).ihandle
select case state.tool select case state.tool
case 2 ' Line case 2 ' Line
if canX=state.startX and canY=state.startY then thickline state.startX, state.startY, canX, canY, drawCol
thickpixel canX,canY,drawCol addcommand "line ("+str$(state.startX)+","+str$(state.startY)+","+str$(canX)+","+str$(canY)+","+hex$(drawCol)+")"
addcommand "pixel ("+str$(canX)+","+str$(canY)+","+hex$(drawCol)+")"
else
thickline state.startX, state.startY, canX, canY, drawCol
addcommand "line ("+str$(state.startX)+","+str$(state.startY)+","+str$(canX)+","+str$(canY)+","+hex$(drawCol)+")"
end if
case 3 ' Circle case 3 ' Circle
r = int(sqr((canX - state.startX)^2 + (canY - state.startY)^2)) r = int(sqr((canX - state.startX)^2 + (canY - state.startY)^2))
thickcircle state.startX, state.startY, r + 1, drawCol thickcircle state.startX, state.startY, r + 1, drawCol