Click here to Skip to main content
13,043,898 members (52,386 online)
Click here to Skip to main content
Add your own
alternative version


63 bookmarked
Posted 11 Jun 2003

Wave or Lake effect control

, 11 Jun 2003
Rate this:
Please Sign up or sign in to vote.
Implementation of wave or lake effect in C#


The WaveControl control allows you to include the lake effect that has been available on web pages for the past 6 or 7 years, from groups like Anfy ( With a name like Lyquidity, and corny as it is, liquid motion effects are used in splash screens and in some marketing materials. We wanted to include the wave or lake effect to the repertoire but were unable to find a C# implementation so we decided to create one ourselves.

The control

WaveControl inherits from System.Windows.Forms.Control and so implements its own painting to animate the rippling water effect. The actions taken by the control are to:

  • Load an image
  • Create an inverted copy of the image
  • Create the frames for animation
  • Run the animation

The real work is done in the DrawLakeEffect() method. This method creates a frame of the animation at a time. There are plenty of notes in this method explaining what it does and how its done, so no explanation is included here (at least for now).

The animation is controlled by a timer and on each tick a frame is drawn onto the controls surface. Though the frame rate is fixed (you can change that), the user can control the number of frames generated and so the length of the animation. Other aspects of the animation that can be controlled include, the wave height, the number of ripples and the damping factor used.

A default image is displayed (mine), but an alternative image can be passed to the control. The control will size itself to the width of the image and 2 * the height.

VS.NET version

We use VS.NET 2003 for development work, so the .sln and .csproj files are in this format and cannot be opened in the earlier version of VS.NET. The good news is that no VS.NET 2003 specific features are used, so creating a project for the earlier will be straightforward. The one thing to bear in mind is that WaveControl.cs uses an unsafe {} block while generating the animation frames, so you will need to set this configuration property to true before the code will compile.

Things that could be done

The Anfy control includes randomization features to simulate wind and to give a more natural appearance and adding such effects would be good. The use of a timer works just fine, but encapsulating the painting in a thread would be better.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Bill Seddon
Web Developer
United Kingdom United Kingdom
Independent software development for clients including Microsoft. Design and development of modules for financial reporting and business intelligence.

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
aguisoft__20-Mar-10 22:53
memberaguisoft__20-Mar-10 22:53 
GeneralOverall nice control Pin
Catalin Murariu9-Feb-07 4:04
memberCatalin Murariu9-Feb-07 4:04 
GeneralMemory leak or not Pin
akorolev1020-Mar-04 6:13
memberakorolev1020-Mar-04 6:13 
GeneralRe: Memory leak or not Pin
Bill Seddon20-Mar-04 22:24
memberBill Seddon20-Mar-04 22:24 
GeneralEnhancement Pin
Ed Din ar Qadiyyeh31-Aug-03 19:28
memberEd Din ar Qadiyyeh31-Aug-03 19:28 
GeneralNice work but.. Pin
TheGlynn12-Jun-03 5:48
memberTheGlynn12-Jun-03 5:48 
GeneralRe: Nice work but.. Pin
Bill Seddon12-Jun-03 5:54
sussBill Seddon12-Jun-03 5:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170713.1 | Last Updated 12 Jun 2003
Article Copyright 2003 by Bill Seddon
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid