Index: bloat.sh =================================================================== --- bloat.sh (revision 19442) +++ bloat.sh (revision 19443) @@ -22,7 +22,7 @@ } # offset-shift an edge using the neighbour edges -function edge_shift(POLY, bloat, n0 ,x0,y0,xp,yp,x1,y1,xn,yn, dx,dy,l,nx,ny ,ax,ay,al,a1l,a1x,a1y) +function edge_shift(POLY, NX, NY, bloat, n0 ,x0,y0,xp,yp,x1,y1,xn,yn, dx,dy,l,nx,ny ,ax,ay,al,a1l,a1x,a1y) { x0 = POLY[n0, "x"] y0 = POLY[n0, "y"] @@ -33,14 +33,8 @@ xp = POLY[pwrap(POLY, n0-1), "x"] yp = POLY[pwrap(POLY, n0-1), "y"] - # targe edge normal - dx = x1 - x0 - dy = y1 - y0 - l = sqrt(dx*dx + dy*dy) - dx /= l - dy /= l - nx = -dy - ny = dx + nx = NX[n0] + ny = NY[n0] # previous edge offset ax = x0 - xp @@ -77,13 +71,29 @@ } # offset shift the target edge or all edges -function poly_bloat(POLY, bloat, n) +function poly_bloat(POLY, bloat, n,NX,NY,x0,y0,x1,y1,dx,dy,l) { + for(n = 0; n < POLY["len"]; n++) { + x0 = POLY[n, "x"] + y0 = POLY[n, "y"] + x1 = POLY[pwrap(POLY, n+1), "x"] + y1 = POLY[pwrap(POLY, n+1), "y"] + + # targe edge normal + dx = x1 - x0 + dy = y1 - y0 + l = sqrt(dx*dx + dy*dy) + dx /= l + dy /= l + NX[n] = -dy + NY[n] = dx + } + if (target_edge == "") for(n = 0; n < POLY["len"]; n++) - edge_shift(POLY, bloat, n) + edge_shift(POLY, NX, NY, bloat, n) else - edge_shift(POLY, bloat, target_edge) + edge_shift(POLY, NX, NY, bloat, target_edge) } ### loader