1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-14 02:34:12 +02:00
This commit is contained in:
Justin Lin
2020-01-26 20:31:20 +08:00
parent a49b27ecb1
commit be08328c32
2 changed files with 23 additions and 20 deletions

View File

@@ -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
];

View File

@@ -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 <pixel/_impl/_px_from_impl.scad>;
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
];
function px_from(binaries, center = false, invert = false) = _px_from_impl(binaries, center, invert);