Paste: pnglitch
Author: | atax1a |
Mode: | factor |
Date: | Tue, 7 Feb 2023 15:47:26 |
Plain Text |
USING: accessors byte-arrays combinators.random fry grouping images
images.normalization images.png io.encodings.binary io.files kernel locals math
math.vectors random sequences sequences.deep sequences.rotated
tools.continuations ;
IN: pnglitch
CONSTANT: bpp 4
<PRIVATE
: pixelate ( bitmap -- bitmap' )
B{ } flatten-as bpp <groups> ; inline
PRIVATE>
: <normal-image> ( -- image )
<image>
RGBA >>component-order
ubyte-components >>component-type ;
: imbue ( bitmap dim -- image )
<normal-image> -rot
[ B{ } flatten-as >>bitmap ]
[ >>dim ] bi* ;
: consume ( path -- normalized-image )
binary <file-reader>
load-png
loading-png>image normalize-image ;
:: explode* ( image offset -- bitmap dim )
image bitmap>>
offset [ <rotated> ] unless-zero
pixelate
image image-dim ;
: explode ( image -- bitmap dim )
0 explode* ; inline
: row-clump ( bitmap dim -- bitmap' dim )
[ first <circular-clumps> ] keep ;
: row-group ( bitmap dim -- bitmap' dim )
[ first <groups> ] keep ;
: jitterbug ( bitmap dim -- bitmap dim )
[ pixelate ] dip
row-group
[ first 4 / >integer
'[ _ random <rotated> ] map ] keep ;
New Annotation