Rippling Images

Make animated GIFs that simulate the effect of a reflection distorted in water.

Use natural language to request a picture of something:

Hint: try a common type of animal, or a famous person.

SHOW/HIDE DETAILS

There are lots of ways to get pictures in the Wolfram Language.

On the desktop, you can take a picture with your computers camera using CurrentImage.

You can use the Wolfram Knowledgebase (the same one that powers Wolfram|Alpha) to ask for a picture of something. Hold down the key and press = to get a natural language input field (LinguisticAssistant):

In[1]:=
X
Out[1]=

You can also drag images from most websites and drop them directly into the code. If you want to refer to it later you can always give it a name like image:

In[2]:=
X
Out[2]=

HIDE DETAILS
In[1]:=
X
Out[1]=

Run the code to distort the image. Try different numbers to get different effects:

SHOW/HIDE DETAILS

Geometric image transformations distort images. The distortion is given by a pure function, indicated by # and &:

A sine function (Sin) gives a rippling effect, like a reflection in water:

In[1]:=
X

HIDE DETAILS
In[1]:=
X
Out[1]=

Create an interface to make the distortion interactive. Drag the slider to make the image ripple:

SHOW/HIDE DETAILS

Here is an expression for a transformed image:

In[1]:=
X
Out[1]=

To make the expression interactive, wrap it with Manipulate, replace the value 1 with the variable r, and specify that r ranges from 0 to 25, with an initial value of 0 and label ripple:

In[2]:=
X

HIDE DETAILS
In[1]:=
X
Out[1]=

Add controls for the strength and frequency of the ripple. Adjust the controls to find a good ripple effect:

SHOW/HIDE DETAILS

Add a strength control by replacing .02 with the variable s, and let s range from 0 to .1 with an initial value of .02 and label strength. Appearance->Labeled puts a label on the slider so you can see its value:

In[1]:=
X

Add a frequency control in the same way.

HIDE DETAILS
In[1]:=
X
Out[1]=

Make a list of animation frames. Change .03 and 20 to the values of strength and frequency you found in the previous step:

SHOW/HIDE DETAILS

To make an animated GIF, you need a list of the GIFs frames. Use Table to make the list.

This Table expression makes a list of the values of r as it goes from 0 to 6 in steps of .5:

In[1]:=
X
Out[1]=

Here is a similar Table expression that gives a list of distorted images where the ripple goes from 0 to 6 in steps of Pi/6:

In[2]:=
X
Out[2]=

HIDE DETAILS
In[1]:=
X
Out[1]=

Share ItPut the animation in the Wolfram Cloud, where everyone can see it:

SHOW/HIDE DETAILS

Deploy the Manipulate to the Wolfram Cloud where anyone with a browser can use it:

In[1]:=
X
Out[1]=

Click the link in the output to visit the site.

Share the link by right-clicking it and choosing Copy Address. Paste the link into an email, tweet, or other message.

HIDE DETAILS
In[1]:=
X
Out[1]=