Better image-gradient-based brush handling