optomized canvas fun to pause all calculations if window is too small