\startbuffer[a] path p; numeric bwidth, u, lastpoint; u :=1cm; p := fullcircle scaled .3u; lastpoint := 0; def draw_balls(text s) = draw (0,0) -- (0, u); for i=s: for j = 1 upto i: draw p shifted (lastpoint+.32*j*u,.3u); endfor; bwidth := .32i*u+.5u; draw (lastpoint,0) -- (lastpoint +bwidth,0) -- (lastpoint +bwidth,u); lastpoint := lastpoint+bwidth; endfor; enddef; draw_balls(3,5,0,2,1,7); \stopbuffer \starttext \processMPbuffer[a] \stoptext