Archive for the ‘random’ Category
data matrix
I’ve tried "Data Matrix" technology today with my cellphone and i-nigma reader. It works.
EPSCrop doesn’t work everywhere
If previous Makefile doesn’t work for you, there’s another way of doing this:
%.png: %.1
gs -sFONTPATH=. -sFONTMAP=font.map -dSAFER -dBATCH \
-dNOPAUSE -sDEVICE=ppmraw -dTextAlphaBits=4 \
-r600 -sOutputFile=- -q $< -c showpage -c quit | \
pnmcrop | pnmmargin -white 10 | pnmtopng > $@
mogrify -resize 480x480! -antialias $@
where I copied cmr10.pfb into the working directory and
laptop% cat font.map /cmr10 (cmr10.pfb) ; laptop%
synthetic handmade drawings
I’ve started to create little drawings explaining concepts. I chose MetaPost to experiment with. First of all I needed a Makefile:
FILES=test1 ms test2
all: ${FILES:%=%.png}
%.1: %.mp
mpost $<
%.png: %.1
gs -sFONTPATH=. -dSAFER -dBATCH \
-dNOPAUSE -sDEVICE=png16 -dEPSCrop \
-r600 -dTextAlphaBits=4 -sOutputFile=$@ $<
mogrify -resize 480x480! -antialias $@
clean:
rm -rf ${FILES:%=%.log} ${FILES:%=%.mpx} ${FILES:%=%.png}
The output things were boring and I decided to spice them a little. I randomized the paths drawn.
primarydef dev perturbed pt =
pt+(dev/2-(uniformdeviate dev),
dev/2-(uniformdeviate dev))
enddef;
primarydef dev pperturbed pat =
dev perturbed (point 0 of pat) ..
controls (postcontrol 0 of pat) and
for i=1 upto (length pat) - 1:
hide (pair offset; offset := dev perturbed (0,0);)
(offset + (precontrol i of pat)) ..
offset + (point i of pat) ..
controls (offset + (postcontrol i of pat)) and
endfor
(precontrol (length pat) of pat) ..
dev perturbed (point (length pat) of pat)
enddef;
With these monsters you can do the followings (please find the corresponding code below each picture).

u=cm;
for i=1 upto 10:
draw (.02u*i) pperturbed (fullcircle scaled (u*i));
endfor

u=cm;
for i=1 upto 10:
draw (.05u*i) pperturbed (unitsquare scaled (u*i) shifted (-.5u*i,-.5u*i));
endfor
Combined images look like handmade ones, which is fun : ))

draw .3in pperturbed (fullcircle scaled 4in); draw .5in pperturbed (unitsquare scaled 2in shifted (-in,-in));
