1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-02-24 01:22:27 +01:00
This commit is contained in:
Justin Lin 2020-03-12 20:47:22 +08:00
parent b192a8ff48
commit be96adb708
2 changed files with 0 additions and 44 deletions

View File

@ -1,13 +0,0 @@
use <experimental/px_polygon.scad>;
use <shape_starburst.scad>;
points = [
for(pt = shape_starburst(20, 10, 6))
[round(pt[0]), round(pt[1])]
];
for(p = px_polygon(points)) {
translate(p)
linear_extrude(1, scale = 0.5)
square(1, center = true);
}

View File

@ -1,31 +0,0 @@
use <in_shape.scad>;
use <util/sort.scad>;
use <util/dedup.scad>;
use <pixel/px_polyline.scad>;
function px_polygon(points) =
let(
contour = dedup(px_polyline(concat(points, [points[0]]))),
sortedXY = sort(sort(contour, by = "x"), by = "y"),
ys = [for(p = sortedXY) p[1]],
rows = [
for(y = [min(ys):max(ys)])
let(
idxes = search(y, sortedXY, num_returns_per_match = 0, index_col_num = 1)
)
[for(i = idxes) sortedXY[i]]
]
)
dedup(
concat(
sortedXY,
[
for(row = rows)
let(to = len(row) - 1, y = row[0][1])
if(to > 0 && (row[0][0] + 1 != row[to][0]))
for(i = [row[0][0] + 1:row[to][0] - 1])
let(p = [i, y])
if(in_shape(points, p)) p
]
)
);