mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-29 01:11:30 +02:00
allow different size
This commit is contained in:
@@ -1,25 +1,28 @@
|
|||||||
function _bitmap_row(r_count, row_bits, dimension, range, center, invert) =
|
function _bitmap_row(r_count, row_bits, width, height, center, invert) =
|
||||||
let(
|
let(
|
||||||
half_d = dimension / 2,
|
half_w = width / 2,
|
||||||
offset_p = center ? 0 : half_d,
|
half_h = height / 2,
|
||||||
|
offset_x = center ? 0 : half_w,
|
||||||
|
offset_y = center ? 0 : half_h,
|
||||||
bit = invert ? 0 : 1
|
bit = invert ? 0 : 1
|
||||||
)
|
)
|
||||||
[for(i = range) if(row_bits[i] == bit) [i - half_d + offset_p, r_count + offset_p]];
|
[for(i = 0; i < width; i = i + 1) if(row_bits[i] == bit) [i - half_w + offset_x, r_count + offset_y]];
|
||||||
|
|
||||||
function bitmap(raw_data, center = false, invert = false) =
|
function bitmap(raw_data, size, center = false, invert = false) =
|
||||||
let(
|
let(
|
||||||
dimension = sqrt(len(raw_data)),
|
squar = sqrt(len(raw_data)),
|
||||||
to = dimension - 1,
|
siz = is_undef(size) ? [squar, squar] : size,
|
||||||
range = [0:to],
|
width = siz[0],
|
||||||
|
height = siz[1],
|
||||||
rows = [
|
rows = [
|
||||||
for(row = to; row > -1; row = row - 1)
|
for(row = height - 1; row > -1; row = row - 1)
|
||||||
[for(column = range)
|
[for(column = 0; column < width; column = column + 1)
|
||||||
raw_data[row * dimension + column]]
|
raw_data[row * width + column]]
|
||||||
],
|
],
|
||||||
offset_i = dimension / 2
|
offset_i = height / 2
|
||||||
)
|
)
|
||||||
[
|
[
|
||||||
for(i = range)
|
for(i = 0; i < width; i = i + 1)
|
||||||
let(row = _bitmap_row(i - offset_i, rows[i], dimension, range, center, invert))
|
let(row = _bitmap_row(i - offset_i, rows[i], width, height, center, invert))
|
||||||
if(row != []) each row
|
if(row != []) each row
|
||||||
];
|
];
|
Reference in New Issue
Block a user