Hypnosis

A hypnotic effect I once saw on the web. Originally it was done by Mario Klingemann as a java applet. I recoded this simple effect and added some smooth gradient to it.

Screenshots

Technique

The effect was coded in C++ using Microsoft Express Edition 2005. It uses PixelToaster, a portable framebuffer graphics library, for rendering.

Source

/******************************************************
/*** Hypnosis FX
/***
/*** original java version by Mario Klingemann
/*** converted to pixeltoaser and added a gradient fx
/***
/*** benny!weltenkonstrukteur.de in 2oo6
/******************************************************/

#include "PixelToaster.h"
#include 

using namespace PixelToaster;

class Hypnosis : public Listener
{
public:

	Hypnosis()
	{
		quit = false;
	}

    int run()
    {
		// open display
        const int width = 400;
        const int height = 200;

		const float PI = 3.14159265;

		vector pixels( width * height );

		int w2=width/2;
		int h2=height/2;
		int w1=width-1;
		int h1=height-1;
		float maxdist=sqrt((float)(h2*h2+w2*w2));
		float dx,dy,angle,dist = 0.0f;
		int d,p = 0;
		float c = 600.0f;
		float w = 0;

		if ( !display.open( "Hypnosis. (Move your mouse)", width, height ) )
			return 1;

		// register listener
        display.listener( this );

		// keep updating the display until the user quits
        while ( !quit )
        {
			clear ( pixels );

			c+=(dxMouseY-h2)/32.0;
			w=4.0+(dxMouseX/5.0);	

			for (int y=0;y & pixels )
	{
		for ( unsigned int index = 0; index < pixels.size(); ++index )
		{
			pixels[index].r = 0.0f;
			pixels[index].g = 0.0f;
			pixels[index].b = 0.0f;
		}
	}
};


int main()
{
    Hypnosis hypnosis;
    hypnosis.run();
}

Download

Windows executable, approx. 36kb.