`x` here isn't a coordinate, it's a counter. This is can be confusing especially since you're using `rx` and `ry` below. Maybe rename as `k`?