Skip to content

Commit 65a0685

Browse files
committed
FEAT: MOLD on image using flat result if image is small enough (less than 10 pixels)
Implements: #13
1 parent c8510f1 commit 65a0685

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/core/t-image.c

+4
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,10 @@ INLINE REBCNT ARGB_To_BGR(REBCNT i)
477477
Append_Byte(mold->series, '}');
478478
return;
479479
}
480+
481+
// use `flat` result for images with less than 10 pixels (looks better in console)
482+
if (size < 10) indented = FALSE;
483+
480484
data = (REBCNT *)VAL_IMAGE_DATA(value);
481485
up = Prep_Uni_Series(mold, indented ? ((size * 6) + ((size - 1) / 10) + 1) : (size * 6));
482486

src/tests/units/mold-test.r3

+5-1
Original file line numberDiff line numberDiff line change
@@ -291,12 +291,16 @@ Rebol [
291291
--assert "make image! [10x0 #{}]" = mold make image! 10x0
292292
--assert "make image! [0x10 #{}]" = mold make image! 0x10
293293

294+
--test-- "mold small image"
295+
;@@ https://github.com/Oldes/Rebol3/issues/13
296+
--assert (mold make image! 2x2) = {make image! [2x2 #{FFFFFFFFFFFFFFFFFFFFFFFF}]}
297+
294298
--test-- "mold/flat image!"
295299
;@@ https://github.com/rebol/rebol-issues/issues/2389
296300
--assert (mold/flat make image! 8x1) = {make image! [8x1 #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}]}
297301
--assert (mold/flat make image! 8x2) = {make image! [8x2 #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}]}
298302
--assert (mold/flat make image! [1x1 0.0.0.66]) = {make image! [1x1 #{000000} #{42}]}
299-
303+
300304
--test-- "mold/flat/all image!"
301305
--assert (mold/all/flat make image! 8x1) = {#[image! 8x1 #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}]}
302306
--assert (mold/all/flat next make image! 8x1) = {#[image! 8x1 #{FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF} 2]}

0 commit comments

Comments
 (0)