While it's fun to produce completely new images, it is often nice or necessary to modify existing ones. We will use this image as our input image:
The function origValXY looks up a pixel in the input image given its cartesian coordinates and returns its color. Hence, the expression
origValXY(x,y)
simply copies the input image, which is not very exciting. A very simple effect is to flip the image horizontally. This can be achieved by changing the sign of the x coordinate, i.e. making negative coordinates positive and vice versa:
origValXY(-x,y)
Try it out for yourself. Also, try to predict what would happen if you changed the sign of the y coordinate instead, then try it out and see if you were right.
Now, let's shake the waves with our image. The function sin will come in handy for our purposes. This is what its graph looks like (by the way, this graph was produced by a MathMap, using an expression by Hans Lundmark):
As you can see, the value of sin oscillates between -1 and 1. The length of its oscillation period (the distance it needs to make a whole "cycle") is 2*pi. The value of pi, as is well known, is about 3.14159.
We will now try to shift whole pixel columns up and down, depending on their x coordinates. The shift pattern will resemble the graph of the sin function, only that we will use a period of 60 pixels, and we will shift at most 10 pixels up or down:
origValXY(x,y+10*sin(x*(2*pi)/60))
The resulting image looks like this:
Next topic: The Polar Coordinate System