unroll loops in paint and mouse events