• Remix
  • Share
  • New Entry

on 24 Oct 2022
  • 6
  • 26
  • 0
  • 1
  • 243
% Gingerbread person cookie
%
% Here's some code that creates the compressed data string.
% Start by "drawing" 1/2 of a blob-person in 0 and 1s
% q=uint8([0 0 0 0 0 0 0 1
% 0 0 0 0 0 0 1 1
% 0 0 0 0 0 0 1 1
% 0 0 0 0 0 0 0 1
% 0 0 0 1 1 0 0 1
% 0 0 0 0 1 1 1 1
% 0 0 0 0 0 1 1 1
% 0 0 0 0 0 0 1 1
% 0 0 0 0 0 0 1 1
% 0 0 0 0 0 0 1 1
% 0 0 0 0 0 0 1 1
% 0 0 0 0 0 1 1 0
% 0 0 0 1 1 1 0 0
% 0 0 0 0 1 0 0 0
% ]);
%
% This converts the psuedo-binary into a small number of uint8 type numbers
% bs=bin2dec(reshape(dec2bin(q),[],8))';
% OR, if your numbers fit, convert into characters
% bs=char(bs+'a')
% Capture your output digits here.
% bs=[1 3 3 1 25 15 7 3 3 3 3 6 28 8];
% Or capture your even shorter output as characters here, but be sure to subtract 'a'
% Not all matrices will convert correctly, esp if you have 11111111 in your image. Leave
% first column in above matrix as 0 to be safe.
bs='bddbzphddddg}i'-'a';
% Convert back into the original binary-like matrix
t=dec2bin(bs,8);
g=reshape(bin2dec(t(:)),[],8);
% Mirror matrix g in columns to complete blob-person
% Convert into x,y coords using 'find', add 0
[y,x]=find([g,fliplr(g)]);
v=[x,y-3];
v(:,3)=0;
% Do the 'blob' thing to draw blob-person.
S=isosurface(blinnblob(50+5*v,128,128,128),.3);
patch(S,FaceC='#a56c3c',EdgeC='n')
lighting g
material([.6
.9
.3 ])
axis equal ij off
camlight
Remix Tree