refactor drawing routines to component-based algorithms