I wrote my first Q program, an implementation in Q of the RosettaCode task ‘Draw the death star’: http://rosettacode.org/wiki/Death\_Star#Q Looking forward to any suggestions how to improve this …
Very cool! I’ve never played around with bitmaps before but it’s a good exercise.
As for suggestions, it’s best to avoid using “do” or “while” loops and instead use a more vectorised approach. There’s also some neater built-in ways to replicate your f2i4 function.
Below is a more vectorised solution to the circle graph using the same genheader (and mirroring your function names)
f2i4:{“h”$(0x0 vs x)7 6 5 4}; /with q3.4 could use {256 vs x} instead
fcn:{raze(0x00ff00;0x0000ff)(z*z)>sum a*a:flip[til[y]cross til x]-.5*y,x};
writebmp:{z 1: genheader[y;x],fcn[x;y;175]};
writebmp[400;300;`demo5.bmp]
Terry