2026-05-26 13:26:36 +02:00
|
|
|
$console
|
|
|
|
|
_screenhide
|
2026-05-27 11:03:51 +02:00
|
|
|
if command$="" then _echo "🫥 please specify image file to process": system 1
|
2026-05-26 13:26:36 +02:00
|
|
|
_screenshow
|
|
|
|
|
|
|
|
|
|
type point2d
|
|
|
|
|
x as long
|
|
|
|
|
y as long
|
|
|
|
|
end type
|
|
|
|
|
|
|
|
|
|
type statetype
|
|
|
|
|
change as _byte
|
|
|
|
|
levels as _unsigned _byte
|
|
|
|
|
threshold as _unsigned _byte
|
|
|
|
|
mode as _byte
|
|
|
|
|
handle as long
|
|
|
|
|
orgimg as long
|
|
|
|
|
overlay as long
|
|
|
|
|
end type
|
|
|
|
|
|
|
|
|
|
dim shared state as statetype
|
|
|
|
|
dim file as string
|
|
|
|
|
dim shared done as _byte
|
|
|
|
|
dim shared mouseclicked as _byte
|
|
|
|
|
dim shared mbd as _byte
|
2026-05-26 13:11:50 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
' Global polygon trace registers declared as dynamic
|
2026-05-26 13:26:36 +02:00
|
|
|
redim shared contour(4999) as point2d
|
|
|
|
|
dim shared totalpoints as long
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
if _fileexists(command$) then file = command$
|
|
|
|
|
state.orgimg = _loadimage(file, 32)
|
|
|
|
|
state.handle = _copyimage(state.orgimg)
|
|
|
|
|
state.overlay = _newimage(_width(state.orgimg), _height(state.orgimg), 32)
|
|
|
|
|
state.levels = 10
|
|
|
|
|
state.threshold = 127
|
2026-05-26 13:11:50 +02:00
|
|
|
updateimage
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
screen _newimage(_width(state.orgimg) + 200, _height(state.orgimg) + 200, 32)
|
2026-05-26 13:26:36 +02:00
|
|
|
|
|
|
|
|
do until done
|
|
|
|
|
cls
|
2026-05-27 11:03:51 +02:00
|
|
|
while _mouseinput: wend
|
|
|
|
|
mouseclicked = not _mousebutton(1) and mbd
|
|
|
|
|
mbd = _mousebutton(1)
|
2026-05-26 13:11:50 +02:00
|
|
|
|
2026-05-26 13:26:36 +02:00
|
|
|
if state.change then
|
2026-05-26 13:11:50 +02:00
|
|
|
updateimage
|
2026-05-27 11:03:51 +02:00
|
|
|
state.change = 0
|
2026-05-26 13:26:36 +02:00
|
|
|
end if
|
|
|
|
|
|
2026-05-26 13:11:50 +02:00
|
|
|
' Render quantized base image
|
2026-05-27 11:03:51 +02:00
|
|
|
_putimage (0, 0), state.handle
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-26 13:11:50 +02:00
|
|
|
' Render the vector transparent overlay shapes on top
|
2026-05-27 11:03:51 +02:00
|
|
|
_putimage (0, 0), state.overlay
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-26 13:11:50 +02:00
|
|
|
' Process interactive trace when clicking inside image viewport
|
2026-05-26 13:26:36 +02:00
|
|
|
if mouseclicked then
|
2026-05-27 11:03:51 +02:00
|
|
|
dim clickx as long, clicky as long
|
|
|
|
|
clickx = _mousex
|
|
|
|
|
clicky = _mousey
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-26 13:11:50 +02:00
|
|
|
' Verify click coordinates are safely within the source image canvas bounding box
|
2026-05-27 11:03:51 +02:00
|
|
|
if clickx >= 0 and clickx < _width(state.orgimg) and clicky >= 0 and clicky < _height(state.orgimg) then
|
2026-05-26 13:26:36 +02:00
|
|
|
dim targetcolor as _unsigned long
|
|
|
|
|
|
2026-05-26 13:11:50 +02:00
|
|
|
' Fetch look-up color index from the generated active handle
|
2026-05-26 13:26:36 +02:00
|
|
|
_source state.handle
|
2026-05-27 11:03:51 +02:00
|
|
|
targetcolor = point(clickx, clicky)
|
|
|
|
|
_source 0
|
|
|
|
|
|
|
|
|
|
' FIX 1: Clear out the old polygon completely by resetting the transparent overlay canvas
|
|
|
|
|
dim prevdest as long
|
|
|
|
|
prevdest = _dest
|
|
|
|
|
_dest state.overlay
|
|
|
|
|
cls ,_rgb32(0,0,0,0) ' Wipes the canvas clean
|
|
|
|
|
_dest prevdest
|
|
|
|
|
|
|
|
|
|
' FIX 2: Reset the dynamic buffer array to its clean baseline size right here in the main module
|
|
|
|
|
redim shared contour(4999) as point2d
|
|
|
|
|
totalpoints = 0
|
|
|
|
|
|
|
|
|
|
' Pass the shared dynamic array directly into the tracing routine
|
|
|
|
|
tracecontour contour(), targetcolor, clickx, clicky
|
|
|
|
|
|
|
|
|
|
if totalpoints >= 3 and totalpoints < (_width(state.orgimg) * _height(state.orgimg)) then
|
|
|
|
|
redim _preserve contour(totalpoints - 1) as point2d
|
|
|
|
|
|
|
|
|
|
' Pass the dynamic array directly into the simplification routine
|
|
|
|
|
simplifypolygon contour()
|
|
|
|
|
|
|
|
|
|
if totalpoints >= 3 then
|
|
|
|
|
' Build flat 1D coordinate matrix map array (X1, Y1, X2, Y2...)
|
|
|
|
|
redim polypoints(0 to (totalpoints * 2) - 1) as long
|
|
|
|
|
dim i as long
|
|
|
|
|
dim clipstr as string
|
|
|
|
|
|
|
|
|
|
clipstr = "fpolygon("
|
|
|
|
|
for i = 0 to totalpoints - 1
|
|
|
|
|
polypoints(i * 2) = contour(i).x
|
|
|
|
|
polypoints(i * 2 + 1) = contour(i).y
|
|
|
|
|
|
|
|
|
|
clipstr = clipstr + ltrim$(str$(contour(i).x)) + "," + ltrim$(str$(contour(i).y))
|
|
|
|
|
if i < totalpoints - 1 then clipstr = clipstr + ","
|
|
|
|
|
next i
|
|
|
|
|
clipstr = clipstr + ")"
|
|
|
|
|
|
|
|
|
|
' Send string array payload safely to system clipboard hardware
|
|
|
|
|
_clipboard$ = clipstr
|
|
|
|
|
|
|
|
|
|
' Render transparent vector overlay on overlay handler sheet
|
|
|
|
|
dim olddest as long
|
|
|
|
|
olddest = _dest
|
|
|
|
|
_dest state.overlay
|
|
|
|
|
|
|
|
|
|
' Render with a semi-transparent green color (Alpha = 100)
|
|
|
|
|
filledpolygon polypoints(), _rgba32(0, 255, 0, 100)
|
|
|
|
|
|
|
|
|
|
_dest olddest
|
2026-05-26 13:26:36 +02:00
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
ol = state.levels
|
|
|
|
|
ot = state.threshold
|
2026-05-26 13:11:50 +02:00
|
|
|
interface
|
2026-05-27 11:03:51 +02:00
|
|
|
if ol <> state.levels then state.change = -1
|
|
|
|
|
if ot <> state.threshold then state.change = -1
|
2026-05-26 13:26:36 +02:00
|
|
|
|
|
|
|
|
_limit 30
|
|
|
|
|
_display
|
|
|
|
|
loop
|
|
|
|
|
system
|
2026-05-26 13:11:50 +02:00
|
|
|
'$include: '../include/ui.bm'
|
|
|
|
|
|
2026-05-26 13:26:36 +02:00
|
|
|
sub interface
|
2026-05-27 11:03:51 +02:00
|
|
|
if button(10, _height - 34, 60, 23, "exit") then done = -1
|
2026-05-26 13:26:36 +02:00
|
|
|
color highlightcolor
|
2026-05-27 11:03:51 +02:00
|
|
|
_printstring (10, _height(state.handle) + 10), "levels"
|
|
|
|
|
state.levels = slider(10, _height(state.handle) + 28, 100, state.levels * 10) / 10
|
2026-05-26 13:26:36 +02:00
|
|
|
color highlightcolor
|
2026-05-27 11:03:51 +02:00
|
|
|
_printstring (118, _height(state.handle) + 28), str$(state.levels)
|
|
|
|
|
_printstring (10, _height(state.handle) + 40), "threshold"
|
|
|
|
|
state.threshold = slider(10, _height(state.handle) + 58, 100, state.threshold / 255 * 100) / 100 * 255
|
2026-05-26 13:26:36 +02:00
|
|
|
color highlightcolor
|
2026-05-27 11:03:51 +02:00
|
|
|
_printstring (118, _height(state.handle) + 58), str$(state.threshold)
|
2026-05-26 13:26:36 +02:00
|
|
|
end sub
|
|
|
|
|
|
|
|
|
|
sub updateimage
|
|
|
|
|
dim odest as long
|
|
|
|
|
dim osource as long
|
2026-05-27 11:03:51 +02:00
|
|
|
odest = _dest
|
|
|
|
|
osource = _source
|
2026-05-26 13:26:36 +02:00
|
|
|
_source state.orgimg
|
|
|
|
|
_dest state.handle
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
dim x as long, y as long, l as integer
|
2026-05-26 13:26:36 +02:00
|
|
|
dim numsteps as integer
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
if state.levels < 2 then state.levels = 2
|
|
|
|
|
numsteps = state.levels - 1
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
for y = 0 to _height - 1
|
|
|
|
|
for x = 0 to _width - 1
|
|
|
|
|
l = luma(point(x, y))
|
2026-05-26 13:26:36 +02:00
|
|
|
|
|
|
|
|
dim adjustedl as single
|
2026-05-27 11:03:51 +02:00
|
|
|
if state.threshold = 0 or state.threshold = 255 then
|
|
|
|
|
adjustedl = l
|
|
|
|
|
elseif l <= state.threshold then
|
|
|
|
|
adjustedl = (l / state.threshold) * 127.5
|
2026-05-26 13:26:36 +02:00
|
|
|
else
|
2026-05-27 11:03:51 +02:00
|
|
|
adjustedl = 127.5 + ((l - state.threshold) / (255 - state.threshold)) * 127.5
|
2026-05-26 13:26:36 +02:00
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
dim currentstep as integer
|
2026-05-27 11:03:51 +02:00
|
|
|
currentstep = int((adjustedl / 256) * state.levels)
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
if currentstep < 0 then currentstep = 0
|
|
|
|
|
if currentstep > numsteps then currentstep = numsteps
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
l = int(currentstep * (255 / numsteps))
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
pset (x, y), _rgb32(l)
|
2026-05-26 13:26:36 +02:00
|
|
|
next x
|
|
|
|
|
next y
|
|
|
|
|
|
|
|
|
|
_source osource
|
|
|
|
|
_dest odest
|
|
|
|
|
end sub
|
|
|
|
|
|
|
|
|
|
function luma (col as _unsigned long)
|
2026-05-27 11:03:51 +02:00
|
|
|
luma = 0.21 * _red(col) + 0.72 * _green(col) + 0.07 * _blue(col)
|
2026-05-26 13:26:36 +02:00
|
|
|
end function
|
2026-05-26 13:11:50 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
sub filledpolygon (points() as long, col as long)
|
|
|
|
|
dim i as integer, j as integer
|
|
|
|
|
dim x1 as single, y1 as single, x2 as single, y2 as single
|
2026-05-26 13:26:36 +02:00
|
|
|
dim intersectx as single
|
|
|
|
|
dim numpoints as integer
|
2026-05-27 11:03:51 +02:00
|
|
|
numpoints = (ubound(points) + 1) \ 2
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
dim intersections(4999) as single
|
2026-05-26 13:26:36 +02:00
|
|
|
dim numintersections as integer
|
|
|
|
|
dim y as long
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
for y = 0 to _height - 1
|
|
|
|
|
numintersections = 0
|
|
|
|
|
for i = 0 to numpoints - 1
|
|
|
|
|
x1 = points(i * 2)
|
|
|
|
|
y1 = points(i * 2 + 1)
|
|
|
|
|
x2 = points(((i + 1) mod numpoints) * 2)
|
|
|
|
|
y2 = points(((i + 1) mod numpoints) * 2 + 1)
|
|
|
|
|
|
|
|
|
|
if ((y1 > y and y2 <= y) or (y2 > y and y1 <= y)) then
|
|
|
|
|
if y2 - y1 <> 0 then
|
|
|
|
|
intersectx = x1 + (y - y1) * (x2 - x1) / (y2 - y1)
|
|
|
|
|
if numintersections <= ubound(intersections) then
|
|
|
|
|
intersections(numintersections) = intersectx
|
|
|
|
|
numintersections = numintersections + 1
|
2026-05-26 13:26:36 +02:00
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
next i
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
for i = 0 to numintersections - 1
|
|
|
|
|
for j = i + 1 to numintersections - 1
|
|
|
|
|
if intersections(i) > intersections(j) then
|
|
|
|
|
swap intersections(i), intersections(j)
|
2026-05-26 13:26:36 +02:00
|
|
|
end if
|
|
|
|
|
next j
|
|
|
|
|
next i
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
for i = 0 to numintersections - 1 step 2
|
|
|
|
|
if i + 1 < numintersections then
|
|
|
|
|
line (intersections(i), y)-(intersections(i + 1), y), col
|
2026-05-26 13:26:36 +02:00
|
|
|
end if
|
|
|
|
|
next i
|
|
|
|
|
next y
|
|
|
|
|
end sub
|
2026-05-26 13:11:50 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
' FIX 3: Adjusted signature to cleanly receive the dynamic array as a parameter
|
|
|
|
|
sub tracecontour (poly() as point2d, targcolor as _unsigned long, mx as long, my as long)
|
|
|
|
|
dim startx as long, starty as long
|
2026-05-26 13:26:36 +02:00
|
|
|
dim foundstart as _byte
|
|
|
|
|
|
|
|
|
|
dim oldsource as long
|
2026-05-27 11:03:51 +02:00
|
|
|
oldsource = _source
|
2026-05-26 13:26:36 +02:00
|
|
|
_source state.handle
|
|
|
|
|
|
|
|
|
|
dim y&
|
2026-05-27 11:03:51 +02:00
|
|
|
for y& = my to 0 step -1
|
|
|
|
|
if point(mx, y&) <> targcolor then
|
|
|
|
|
startx = mx
|
|
|
|
|
starty = y& + 1
|
|
|
|
|
foundstart = -1
|
2026-05-26 13:26:36 +02:00
|
|
|
exit for
|
|
|
|
|
end if
|
|
|
|
|
next y&
|
|
|
|
|
|
|
|
|
|
if not foundstart then
|
2026-05-27 11:03:51 +02:00
|
|
|
startx = mx: starty = my
|
2026-05-26 13:26:36 +02:00
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
dim dx(0 to 7) as integer
|
|
|
|
|
dim dy(0 to 7) as integer
|
2026-05-27 11:03:51 +02:00
|
|
|
dx(0) = -1: dx(1) = 0: dx(2) = 1: dx(3) = 1: dx(4) = 1: dx(5) = 0: dx(6) = -1: dx(7) = -1
|
|
|
|
|
dy(0) = -1: dy(1) = -1: dy(2) = -1: dy(3) = 0: dy(4) = 1: dy(5) = 1: dy(6) = 1: dy(7) = 0
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
dim currentx as long, currenty as long
|
|
|
|
|
dim backtrackdir as integer, checkdir as integer
|
2026-05-26 13:26:36 +02:00
|
|
|
dim startbacktrackdir as integer
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
currentx = startx
|
|
|
|
|
currenty = starty
|
|
|
|
|
totalpoints = 0
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
backtrackdir = 1
|
|
|
|
|
startbacktrackdir = 1
|
2026-05-26 13:26:36 +02:00
|
|
|
|
|
|
|
|
dim firststep as _byte
|
2026-05-27 11:03:51 +02:00
|
|
|
firststep = -1
|
2026-05-26 13:26:36 +02:00
|
|
|
|
|
|
|
|
dim maxallowedpoints as long
|
2026-05-27 11:03:51 +02:00
|
|
|
maxallowedpoints = _width(state.handle) * _height(state.handle)
|
2026-05-26 13:26:36 +02:00
|
|
|
|
|
|
|
|
do
|
2026-05-27 11:03:51 +02:00
|
|
|
poly(totalpoints).x = currentx
|
|
|
|
|
poly(totalpoints).y = currenty
|
|
|
|
|
totalpoints = totalpoints + 1
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
if totalpoints >= maxallowedpoints then
|
|
|
|
|
totalpoints = 0
|
2026-05-26 13:26:36 +02:00
|
|
|
exit do
|
|
|
|
|
end if
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
if totalpoints >= ubound(poly) then
|
|
|
|
|
' Safely scales the array parameter reference across scopes
|
|
|
|
|
redim _preserve poly(ubound(poly) + 1000) as point2d
|
2026-05-26 13:26:36 +02:00
|
|
|
end if
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
checkdir = (backtrackdir + 1) mod 8
|
2026-05-26 13:26:36 +02:00
|
|
|
dim steps as integer
|
2026-05-27 11:03:51 +02:00
|
|
|
steps = 0
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
do while steps < 8
|
|
|
|
|
dim nx as long, ny as long
|
|
|
|
|
nx = currentx + dx(checkdir)
|
|
|
|
|
ny = currenty + dy(checkdir)
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
if nx >= 0 and nx < _width(state.handle) and ny >= 0 and ny < _height(state.handle) then
|
|
|
|
|
if point(nx, ny) = targcolor then
|
|
|
|
|
backtrackdir = (checkdir + 4) mod 8
|
|
|
|
|
currentx = nx
|
|
|
|
|
currenty = ny
|
2026-05-26 13:26:36 +02:00
|
|
|
|
|
|
|
|
if firststep then
|
2026-05-27 11:03:51 +02:00
|
|
|
startbacktrackdir = backtrackdir
|
|
|
|
|
firststep = 0
|
2026-05-26 13:26:36 +02:00
|
|
|
end if
|
|
|
|
|
exit do
|
|
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
checkdir = (checkdir + 1) mod 8
|
|
|
|
|
steps = steps + 1
|
2026-05-26 13:26:36 +02:00
|
|
|
loop
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
if steps = 8 then exit do
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
loop until (currentx = startx and currenty = starty and backtrackdir = startbacktrackdir)
|
2026-05-26 13:26:36 +02:00
|
|
|
_source oldsource
|
|
|
|
|
end sub
|
2026-05-26 13:11:50 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
' FIX 4: Adjusted signature to cleanly receive the dynamic array as a parameter
|
|
|
|
|
sub simplifypolygon (poly() as point2d)
|
2026-05-26 13:26:36 +02:00
|
|
|
dim numpoints as long
|
2026-05-27 11:03:51 +02:00
|
|
|
numpoints = totalpoints
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
if numpoints > 2 then
|
|
|
|
|
if poly(numpoints - 1).x = poly(0).x and poly(numpoints - 1).y = poly(0).y then
|
|
|
|
|
numpoints = numpoints - 1
|
2026-05-26 13:26:36 +02:00
|
|
|
end if
|
|
|
|
|
end if
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
if numpoints < 3 then exit sub
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
dim temp(0 to numpoints - 1) as point2d
|
2026-05-26 13:26:36 +02:00
|
|
|
dim keepcount as long
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
temp(0) = poly(0)
|
|
|
|
|
keepcount = 1
|
2026-05-26 13:26:36 +02:00
|
|
|
|
|
|
|
|
dim i as long
|
2026-05-27 11:03:51 +02:00
|
|
|
for i = 1 to numpoints - 1
|
|
|
|
|
dim previdx as long: previdx = i - 1
|
|
|
|
|
dim nextidx as long: nextidx = i + 1
|
|
|
|
|
if nextidx > numpoints - 1 then nextidx = 0
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
dim dx1 as single: dx1 = poly(i).x - poly(previdx).x
|
|
|
|
|
dim dy1 as single: dy1 = poly(i).y - poly(previdx).y
|
|
|
|
|
dim dx2 as single: dx2 = poly(nextidx).x - poly(i).x
|
|
|
|
|
dim dy2 as single: dy2 = poly(nextidx).y - poly(i).y
|
2026-05-26 13:26:36 +02:00
|
|
|
|
|
|
|
|
dim crossproduct as single
|
2026-05-27 11:03:51 +02:00
|
|
|
crossproduct = (dx1 * dy2) - (dy1 * dx2)
|
2026-05-26 13:26:36 +02:00
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
if abs(crossproduct) > 0.05 then
|
|
|
|
|
temp(keepcount) = poly(i)
|
|
|
|
|
keepcount = keepcount + 1
|
2026-05-26 13:26:36 +02:00
|
|
|
end if
|
|
|
|
|
next i
|
|
|
|
|
|
2026-05-27 11:03:51 +02:00
|
|
|
if keepcount >= 3 then
|
|
|
|
|
redim poly(keepcount - 1) as point2d
|
|
|
|
|
for i = 0 to keepcount - 1
|
|
|
|
|
poly(i) = temp(i)
|
2026-05-26 13:26:36 +02:00
|
|
|
next i
|
2026-05-27 11:03:51 +02:00
|
|
|
totalpoints = keepcount
|
2026-05-26 13:26:36 +02:00
|
|
|
else
|
2026-05-27 11:03:51 +02:00
|
|
|
redim poly(numpoints - 1) as point2d
|
|
|
|
|
for i = 0 to numpoints - 1
|
|
|
|
|
poly(i) = temp(i)
|
2026-05-26 13:26:36 +02:00
|
|
|
next i
|
2026-05-27 11:03:51 +02:00
|
|
|
totalpoints = numpoints
|
2026-05-26 13:26:36 +02:00
|
|
|
end if
|
|
|
|
|
end sub
|