copied code for drawing brush widget