From 5849718ed54619fb8cf26a29d1ac343970c63892 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Wed, 19 Feb 2020 12:49:50 +0800 Subject: [PATCH] change dir --- src/experimental/sf_square.scad | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/src/experimental/sf_square.scad b/src/experimental/sf_square.scad index 980d3c16..aab769db 100644 --- a/src/experimental/sf_square.scad +++ b/src/experimental/sf_square.scad @@ -6,44 +6,26 @@ use ; invert: inverts how the gray levels are translated into height values. */ module sf_square(levels, thickness, invert = false) { - columns = len(levels); - rows = len(levels[0]); - + rows = len(levels); + columns = len(levels[0]); + offset_z = invert ? thickness : 0; size = [columns - 1, rows - 1]; - surface1 = [ - for(r = [0:rows - 1]) - [ - for(c = [0:columns - 1]) - let(lv = invert ? 255 - levels[c][r] : levels[c][r]) - [c, r, lv / 255 * thickness] - ] - ]; - - surface2 = [ - for(r = [0:rows - 1]) - [ - for(c = [0:columns - 1]) - [c, r, 0] - ] - ]; - - offset_z = invert ? thickness : 0; sf_solidify( [ for(r = [0:rows - 1]) [ for(c = [0:columns - 1]) - let(lv = invert ? 255 - levels[c][r] : levels[c][r]) + let(lv = invert ? 255 - levels[rows - r - 1][c] : levels[rows - r - 1][c]) [c, r, lv / 255 * thickness + offset_z] ] ], - [ + [ for(r = [0:rows - 1]) [ for(c = [0:columns - 1]) [c, r, 0] ] - ] + ] ); } \ No newline at end of file