Benutzung von elrotor.js
ElRotor ist eine Objektklasse, mit der man eine Gruppe absolut positionierbarer Seitenelemente zyklisch in beliebigen Bahnkurven über den Bildschirm wandern lassen kann.

Die Einbindung von timer.js in das HTML-Dokument ist zwingend notwendig.

Funktionen von ElRotor-Objekten
Objekt erzeugen
new ElRotor(timestep) kreiert ein neues ElRotor-Objekt und meldet es beim Timer an
timestep:
      0: inaktiv
      1: jeden Timer-Tick nutzen
      2: jeden zweiten Timer-Tick nutzen
      3: jeden dritten Timer-Tick nutzen
      #: jeden #-ten Timer-Tick nutzen
FunktionBedeutung
InitLine(count,stepx,stepy,startx,starty) Initialisiert den Rotor in Linienform
count: Anzahl der Schritte
stepx: Schrittweite in X-Richtung
stepy: Schrittweite in Y-Richtung
startx: Anfangs-X-Koordinate
starty: Anfangs-Y-Koordinate
InitCircle(count,radiusx,radiusy,middlex,middley) Initialisiert den Rotor in Ellipsen- oder Kreisform
count: Anzahl der Schritte
radiusx: Radius in X-Richtung
radiusy: Radius in Y-Richtung
middlex: Mittelpunkt-X-Koordinate
middley: Mittelpunkt-Y-Koordinate
AddPoint(pointleft,pointtop) Fügt einen Punkt in die Rotationskurve ein
pointleft: X-Koordinate
pointtop: Y-Koordinate
AddElement(elementname,numplus,elleft,eltop) Fügt ein Seitenelement in die Rotationsgemeinschaft ein
element: Element-Name
numplus: Phasenverschiebung
elleft: relative X-Verschiebung
eltop: relative Y-Verschiebung
SetEventHandler(eventhandler) Setzt die Funktion, die bei Start oder Stop des Vorganges aufgerufen werden soll
Bei Start bekommt die Eventhandler-Funktion dann die Zahl 1, bei Stop 0 übergeben.
Stop() Stoppt den Rotor
Step() Führt einen Einzelschritt aus
Continue() Führt die Rotation fort
RoTo(eltarget,ptarget) Veranlaßt die Rotation an eine bestimmte Position
eltarget: Nummer des Zielelements
ptarget: Nummer der Zielposition
Animate(modus) Startet die Animation des Rotors
modus:
      0: vorwärts
      1: rückwärts
SetTimeStep(timestep) Verändert die Timerschrittweite
timestep:
      0: inaktiv
      1: jeden Timer-Tick nutzen
      2: jeden zweiten Timer-Tick nutzen
      3: jeden dritten Timer-Tick nutzen
      #: jeden #-ten Timer-Tick nutzen


Quelltext von elrotor.js
/* (c) 2001 Ulrich Kritzner */

function ElRotor_Init_Line(count,stepx,stepy,startx,starty)
{
  var i;
  this.PCount=0;
  for (i=0;i<count;i++)
    this.AddPoint(startx+i*stepx,starty+i*stepy);
  this.Pos();
}

function ElRotor_Init_Circle(count,radiusx,radiusy,middlex,middley)
{
  var i;
  var fkt;
  this.PCount=0;
  for (i=0;i<count;i++)
  {
    fkt=Math.PI*2/count;
    this.AddPoint(Math.sin(i*fkt)*radiusx+middlex,-Math.cos(i*fkt)*radiusy+middley);
  }
  this.Pos();
}

function ElRotor_Pos()
{
  with (this)
  {
    var i;
    for (i=0;i<ElCount;i++)
    {
      Elements[i].left=Pointsx[(current+Numplus[i])%PCount]+Elleft[i];
      Elements[i].top=Pointsy[(current+Numplus[i])%PCount]+Eltop[i];
    }
  }
}

function ElRotor_TimerFunc()
{
  with (this)
  {
    switch (modus)
    {
      case 0:
        current=(current+1)%PCount;
        this.Pos();
	break;
      case 1:
        current=(current+PCount-1)%PCount;
        this.Pos();
        break;
    }
    if (((current+Numplus[eltarget])%PCount)==ptarget)
    {
      this.eltarget=-1;
      this.ptarget=-1;
      this.timestep=0;
      if (this.EventHandler)
        this.EventHandler(0);
    }
  }
}

function ElRotor_Add_Point(pointleft,pointtop)
{
  with (this)
  {
    Pointsx[PCount]=pointleft;
    Pointsy[PCount]=pointtop;
    PCount++;
  }
}

function ElRotor_Add_Element(elementname,numplus,elleft,eltop)
{
  with (this)
  {
    Elleft[ElCount]=elleft;
    Eltop[ElCount]=eltop;
    if (window.document.all)
      Elements[ElCount]=eval("window.document.all."+elementname+".style");
    else
      if (typeof(window.document.getElementById)=="function")
        Elements[ElCount]=window.document.getElementById(elementname).style;
      else
        Elements[ElCount]=eval("window.document."+elementname);
    Numplus[ElCount]=numplus;
    ElCount++;
  }
}

function ElRotor_Set_Event_Handler(eventhandler)
{
  this.EventHandler=eventhandler;
}

function ElRotor_Stop()
{
  var oldrun=this.timestep;
  this.timestep=0;
  if (oldrun)
    if (this.EventHandler)
      this.EventHandler(0);
}

function ElRotor_Step()
{
  if (this.timestep==0)
    this.TimerFunc();
}

function ElRotor_Continue()
{
  this.Stop();
  this.timestep=this.time_step;
  if (this.EventHandler)
    this.EventHandler(1);
  u_timer_continue();
}

function ElRotor_RoTo(eltarget,ptarget)
{
  this.Stop();
  if ((eltarget>=0)&&(ptarget>=0))
  {
    this.eltarget=eltarget%this.ElCount;
    this.ptarget=ptarget%this.PCount;
  }
  else
  {
    this.eltarget=-1;
    this.ptarget=-1;
  }
  this.timestep=this.time_step;
  if (this.EventHandler)
    this.EventHandler(1);
  u_timer_continue();
}

function ElRotor_Animate(modus)
{
  this.Stop();
  this.timestep=this.time_step;
  this.modus=modus;
  if (this.timestep>0)
  {
    if (this.EventHandler)
      this.EventHandler(1);
    u_timer_continue();
  }
}

function ElRotor_Set_TimeStep(timestep)
{
  this.time_step=timestep;
  this.timestep=timestep;
  if (this.timestep>0)
  {
    if (this.EventHandler)
      this.EventHandler(1);
    u_timer_continue();
  }
}

function ElRotor(timestep)
{
  this.RoTo=ElRotor_RoTo;
  this.InitLine=ElRotor_Init_Line;
  this.InitCircle=ElRotor_Init_Circle;
  this.SetTimeStep=ElRotor_Set_TimeStep;
  this.Stop=ElRotor_Stop;
  this.Step=ElRotor_Step;
  this.Continue=ElRotor_Continue;
  this.Animate=ElRotor_Animate;
  this.TimerFunc=ElRotor_TimerFunc;
  this.Pos=ElRotor_Pos;
  this.AddElement=ElRotor_Add_Element;
  this.AddPoint=ElRotor_Add_Point;
  this.SetEventHandler=ElRotor_Set_Event_Handler;
  this.time_step=timestep;
  this.eltarget=-1;
  this.ptarget=-1;
  this.modus=0;
  this.PCount=0;
  this.ElCount=0;
  this.Pointsx=new Array();
  this.Pointsy=new Array();
  this.Elleft=new Array();
  this.Eltop=new Array();
  this.Elements=new Array();
  this.Numplus=new Array();
  this.current=0;
  this.timestep=0;
  this.timeval=0;
  u_timer_add_object(this);
}