var mm = function(x,y,w,h){ //emit "M" emit( [[x,y+h], [x,y], [x+w/2,y+h], [x+w,y], [x+w,y+h]] ); } var tt = function(x,y,w,h){ // emit "T" emit( [[x,y],[x+w,y]] ); emit( [[x+w/2,y],[x+w/2,y+h]] ); } var mtm = function(w,h,t,l,space){ // emit "MTM" mm(l,t,w,h); tt(l+space+w,t,w,h); mm(l+space*2+w*2,t,w,h); } var w=30; var h=20; var t=10; var l=20; var space=5; // draw MTM four times for(var i=0; i<4; i++){ mtm(w,h,t*i*3+10,l,space); }