Well, the image is distorted because the dimensions are wrong, but this is obvious. You specify the size of the image, and then spit out a list of pixels, but with an incorrect number of pixels per line.
In particular, note that the image wraps around almost exactly once. In other words, skew per line * height of the image = width of the image . Since the image is square, it means that you generate an extra pixel in the row - an old old mistake.
The obvious place to do this is when you generate the coordinates for repetition. Try a small set and see what it gives us:
> length $ argandPlane (-2.5) (-2) 1.5 2 10 10 121 > 10 ^ 2 100 > 11 ^ 2 121
So. I suspect the error is due to the fact that you are calculating the increment as the real distance, divided by the size of the pixel, which generates the correct number of intervals, but an extra point. Consider the interval from 0.0 to 1.0. Using your calculation with a width of 4, we get:
> let x0 = 0.0 > let x1 = 1.0 > let width = 4.0 > let dx = (x1 - x0) / width > dx 0.25 > let xs = [x0, x0 + dx .. x1] > xs [0.0, 0.25, 0.5, 0.75, 1.0] > length xs 5
So, to get the correct number of points, simply reduce the size by 1 when creating the coordinates.
CA McCann
source share