From c7c145f0b19a95f8ab1a5ef9aee6dbb721b5391c Mon Sep 17 00:00:00 2001 From: visionmercer <62051836+visionmercer@users.noreply.github.com> Date: Mon, 11 May 2026 10:29:29 +0200 Subject: [PATCH 1/2] pencil tool (thickpixel) --- include/tools.bm | 10 +++++++++- pixler.bas | 28 ++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/include/tools.bm b/include/tools.bm index ba16767..cc937e3 100644 --- a/include/tools.bm +++ b/include/tools.bm @@ -42,13 +42,21 @@ sub filledPolygon (Points() as long, col as long) next y 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) if state.brushsize=1 then line(x1,y1)-(x2,y2),col else dim tempimg as long dim od as long - tempimg=_newimage(10,10,32) + tempimg=_newimage(1,1,32) od =_dest _dest tempimg pset(0,0),col diff --git a/pixler.bas b/pixler.bas index 34111e6..b33ada9 100644 --- a/pixler.bas +++ b/pixler.bas @@ -6,8 +6,8 @@ type statetype offsetY as long zoom as single brushsize as integer - startX as integer - startY as integer + startX as long + startY as long isDrawing as integer end type @@ -303,8 +303,8 @@ sub canvas dim r as integer ' 3. Calculate Canvas Coordinates - dim canX as integer - dim canY as integer + dim canX as long + dim canY as long canX = int((_mousex - state.offsetX) / state.zoom) canY = int((_mousey - state.offsetY) / state.zoom) @@ -370,8 +370,15 @@ sub canvas select case state.tool case 1 ' Pencil _dest layers(1).ihandle - thickline state.startX, state.startY, canX, canY, drawCol - addcommand "line ("+str$(state.startX)+","+ str$(state.startY)+","+str$(canX)+","+str$(canY)+","+hex$(drawCol)+")" + if canX=state.startX and canY=state.startY then + thickpixel canX,canY,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 + 'thickline state.startX, state.startY, canX, canY, drawCol + 'addcommand "line ("+str$(state.startX)+","+ str$(state.startY)+","+str$(canX)+","+str$(canY)+","+hex$(drawCol)+")" state.startX = canX: state.startY = canY case 2 ' Straight Line thickline state.startX, state.startY, canX, canY, drawCol @@ -433,8 +440,13 @@ sub canvas '_putimage , layers(2).ihandle, layers(1).ihandle select case state.tool case 2 ' Line - thickline state.startX, state.startY, canX, canY, drawCol - addcommand "line ("+str$(state.startX)+","+str$(state.startY)+","+str$(canX)+","+str$(canY)+","+hex$(drawCol)+")" + if canX=state.startX and canY=state.startY then + thickpixel canX,canY,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 r = int(sqr((canX - state.startX)^2 + (canY - state.startY)^2)) thickcircle state.startX, state.startY, r + 1, drawCol From b978f2e8cfecf70f756ad48a014f5c12c6a59b7f Mon Sep 17 00:00:00 2001 From: visionmercer <62051836+visionmercer@users.noreply.github.com> Date: Mon, 11 May 2026 10:40:49 +0200 Subject: [PATCH 2/2] Brush size and canvas --- pixler.bas | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pixler.bas b/pixler.bas index b33ada9..0068775 100644 --- a/pixler.bas +++ b/pixler.bas @@ -43,9 +43,9 @@ layers(2).ihandle=_newimage(320,320,32) layers(3).ihandle=_newimage(320,320,32) _dest layers(0).ihandle +addcommand "canvas ("+str$(_width)+","+str$(_height)+")" line (0,0)-(_width-1,_height-1),_rgb32(255),bf _dest 0 - state.tool = 1 state.zoom = 1.0 state.offsetX = 70 + 20 @@ -129,8 +129,10 @@ canvas select case keyin case "+" state.brushsize=state.brushsize+1 + addcommand "brushsize ("+str$(state.brushsize)+")" case "-" if state.brushsize>1 then state.brushsize=state.brushsize-1 + addcommand "brushsize ("+str$(state.brushsize)+")" case chr$(19) ' ctrl+s 'TODO: save logic case chr$(27)' esc @@ -377,8 +379,6 @@ sub canvas thickline state.startX, state.startY, canX, canY, drawCol addcommand "line ("+str$(state.startX)+","+str$(state.startY)+","+str$(canX)+","+str$(canY)+","+hex$(drawCol)+")" end if - 'thickline state.startX, state.startY, canX, canY, drawCol - 'addcommand "line ("+str$(state.startX)+","+ str$(state.startY)+","+str$(canX)+","+str$(canY)+","+hex$(drawCol)+")" state.startX = canX: state.startY = canY case 2 ' Straight Line thickline state.startX, state.startY, canX, canY, drawCol