diff --git a/src/pixel/_impl/_px_from_impl.scad b/src/pixel/_impl/_px_from_impl.scad new file mode 100644 index 00000000..f0cd564e --- /dev/null +++ b/src/pixel/_impl/_px_from_impl.scad @@ -0,0 +1,21 @@ +function _px_from_row(r_count, row_bits, width, height, center, invert) = + let( + half_w = width / 2, + half_h = height / 2, + offset_x = center ? 0 : half_w, + offset_y = center ? -half_h : 0, + bit = invert ? 0 : 1 + ) + [for(i = 0; i < width; i = i + 1) if(row_bits[i] == bit) [i - half_w + offset_x, r_count + offset_y]]; + +function _px_from_impl(binaries, center, invert) = + let( + width = len(binaries[0]), + height = len(binaries), + offset_i = height / 2 + ) + [ + for(i = height - 1; i > -1; i = i - 1) + let(row = _px_from_row(height - i - 1, binaries[i], width, height, center, invert)) + if(row != []) each row + ]; \ No newline at end of file diff --git a/src/pixel/px_from.scad b/src/pixel/px_from.scad index 50dc2a01..6b193744 100644 --- a/src/pixel/px_from.scad +++ b/src/pixel/px_from.scad @@ -8,24 +8,6 @@ * **/ -function _px_from_row(r_count, row_bits, width, height, center, invert) = - let( - half_w = width / 2, - half_h = height / 2, - offset_x = center ? 0 : half_w, - offset_y = center ? -half_h : 0, - bit = invert ? 0 : 1 - ) - [for(i = 0; i < width; i = i + 1) if(row_bits[i] == bit) [i - half_w + offset_x, r_count + offset_y]]; +use ; -function px_from(binaries, center = false, invert = false) = - let( - width = len(binaries[0]), - height = len(binaries), - offset_i = height / 2 - ) - [ - for(i = height - 1; i > -1; i = i - 1) - let(row = _px_from_row(height - i - 1, binaries[i], width, height, center, invert)) - if(row != []) each row - ]; \ No newline at end of file +function px_from(binaries, center = false, invert = false) = _px_from_impl(binaries, center, invert); \ No newline at end of file