fix rectangle computation, and re-use alex' color computation