Animation: Difference between revisions

Content added Content deleted
(add task to aarch64 assembly raspberry pi)
m (syntax highlighting fixup automation)
Line 15: Line 15:
=={{header|AArch64 Assembly}}==
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits <br> or android 64 bits with application Termux }}
{{works with|as|Raspberry Pi 3B version Buster 64 bits <br> or android 64 bits with application Termux }}
<lang AArch64 Assembly>
<syntaxhighlight lang=AArch64 Assembly>
/* Programme assembleur ARM Raspberry ou Android */
/* Programme assembleur ARM Raspberry ou Android */
/* programme animletter64.s */
/* programme animletter64.s */
Line 546: Line 546:
/* for this file see task include a file in language AArch64 assembly */
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"
.include "../includeARM64.inc"
</syntaxhighlight>
</lang>


=={{header|Action!}}==
=={{header|Action!}}==
<lang Action!>PROC DrawWindow(BYTE x,y,len)
<syntaxhighlight lang=Action!>PROC DrawWindow(BYTE x,y,len)
BYTE i
BYTE i


Line 633: Line 633:


CRSINH=0 ;show cursor
CRSINH=0 ;show cursor
RETURN</lang>
RETURN</syntaxhighlight>
{{out}}
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Animation.png Screenshot from Atari 8-bit computer]
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Animation.png Screenshot from Atari 8-bit computer]


=={{header|ActionScript}}==
=={{header|ActionScript}}==
<lang ActionScript>//create the text box
<syntaxhighlight lang=ActionScript>//create the text box
var textBox:TextField = new TextField();
var textBox:TextField = new TextField();
addChild(textBox);
addChild(textBox);
Line 659: Line 659:
//event handler to register clicks
//event handler to register clicks
textBox.addEventListener(MouseEvent.MOUSE_DOWN, function(){goingRight = !goingRight;});
textBox.addEventListener(MouseEvent.MOUSE_DOWN, function(){goingRight = !goingRight;});
</syntaxhighlight>
</lang>


=={{header|Ada}}==
=={{header|Ada}}==
Line 666: Line 666:


animation.adb:
animation.adb:
<lang Ada>with Gtk.Main;
<syntaxhighlight lang=Ada>with Gtk.Main;
with Gtk.Handlers;
with Gtk.Handlers;
with Gtk.Label;
with Gtk.Label;
Line 757: Line 757:
Gtk.Window.Show_All (Widget => Main_Window);
Gtk.Window.Show_All (Widget => Main_Window);
Gtk.Main.Main;
Gtk.Main.Main;
end Animation;</lang>
end Animation;</syntaxhighlight>


=={{header|Applesoft BASIC}}==
=={{header|Applesoft BASIC}}==
<lang gwbasic> 10 LET T$ = "HELLO WORLD! ":P = 1:L = LEN (T$):T$ = T$ + T$
<syntaxhighlight lang=gwbasic> 10 LET T$ = "HELLO WORLD! ":P = 1:L = LEN (T$):T$ = T$ + T$
20 D = 1: VTAB INT (( PEEK (35) - PEEK (34)) / 2) + 1: FOR R = 1 TO 0 STEP 0
20 D = 1: VTAB INT (( PEEK (35) - PEEK (34)) / 2) + 1: FOR R = 1 TO 0 STEP 0
30 HTAB INT (( PEEK (33) - L) / 2) + 1: PRINT MID$ (T$,P,L);
30 HTAB INT (( PEEK (33) - L) / 2) + 1: PRINT MID$ (T$,P,L);
Line 766: Line 766:
50 IF P < 1 THEN P = L
50 IF P < 1 THEN P = L
60 R = PEEK (49152) < 128: FOR I = 1 TO 5:B = PEEK (49249) > 127: IF B < > BO THEN BO = B: IF B = 0 THEN D = - D
60 R = PEEK (49152) < 128: FOR I = 1 TO 5:B = PEEK (49249) > 127: IF B < > BO THEN BO = B: IF B = 0 THEN D = - D
70 NEXT I,R:R = PEEK (49168)</lang>
70 NEXT I,R:R = PEEK (49168)</syntaxhighlight>
=={{header|ARM Assembly}}==
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi <br> or android 32 bits with application Termux}}
{{works with|as|Raspberry Pi <br> or android 32 bits with application Termux}}
<lang ARM Assembly>
<syntaxhighlight lang=ARM Assembly>
/* ARM assembly Raspberry PI or android 32 bits with termux application */
/* ARM assembly Raspberry PI or android 32 bits with termux application */
/* program animLetter.s */
/* program animLetter.s */
Line 1,413: Line 1,413:
/***************************************************/
/***************************************************/
.include "../affichage.inc"
.include "../affichage.inc"
</syntaxhighlight>
</lang>
=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
<lang AutoHotkey>SetTimer, Animate ; Timer runs every 250 ms.
<syntaxhighlight lang=AutoHotkey>SetTimer, Animate ; Timer runs every 250 ms.
String := "Hello World "
String := "Hello World "
Gui, Add, Text, vS gRev, %String%
Gui, Add, Text, vS gRev, %String%
Line 1,429: Line 1,429:
Rev: ; Runs whenever user clicks on the text control
Rev: ; Runs whenever user clicks on the text control
Reverse := !Reverse
Reverse := !Reverse
return</lang>
return</syntaxhighlight>


=={{header|BASIC256}}==
=={{header|BASIC256}}==
<lang BASIC256>str$="Hello, World! "
<syntaxhighlight lang=BASIC256>str$="Hello, World! "
direction=0 #value of 0: to the right, 1: to the left.
direction=0 #value of 0: to the right, 1: to the left.
tlx=10 #Top left x
tlx=10 #Top left x
Line 1,457: Line 1,457:
end if
end if
clickclear
clickclear
goto main</lang>
goto main</syntaxhighlight>


=={{header|BBC BASIC}}==
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
{{works with|BBC BASIC for Windows}}
<lang bbcbasic> VDU 23,22,212;40;16,32,16,128
<syntaxhighlight lang=bbcbasic> VDU 23,22,212;40;16,32,16,128
txt$ = "Hello World! "
txt$ = "Hello World! "
direction% = TRUE
direction% = TRUE
Line 1,475: Line 1,475:
ENDIF
ENDIF
WAIT 20
WAIT 20
UNTIL FALSE</lang>
UNTIL FALSE</syntaxhighlight>


=={{header|C}}==
=={{header|C}}==
{{libheader|GTK}}
{{libheader|GTK}}
(NB: implicitly, through GTK, it uses also Pango library)
(NB: implicitly, through GTK, it uses also Pango library)
<lang c>#include <stdlib.h>
<syntaxhighlight lang=c>#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <gtk/gtk.h>
#include <gtk/gtk.h>
Line 1,551: Line 1,551:
gtk_main();
gtk_main();
return 0;
return 0;
}</lang>
}</syntaxhighlight>


=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==


<lang csharp>using System;
<syntaxhighlight lang=csharp>using System;
using System.Drawing;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms;
Line 1,610: Line 1,610:
}
}
}
}
}</lang>
}</syntaxhighlight>


=={{header|C++}}==
=={{header|C++}}==
{{libheader|Qt}}
{{libheader|Qt}}
Contents of animationwidget.cpp:
Contents of animationwidget.cpp:
<lang cpp>#include "animationwidget.h"
<syntaxhighlight lang=cpp>#include "animationwidget.h"


#include <QLabel>
#include <QLabel>
Line 1,641: Line 1,641:
void AnimationWidget::mousePressEvent(QMouseEvent*) {
void AnimationWidget::mousePressEvent(QMouseEvent*) {
right_ = !right_;
right_ = !right_;
}</lang>
}</syntaxhighlight>


Contents of animationwidget.h:
Contents of animationwidget.h:
<lang cpp>#ifndef ANIMATIONWIDGET_H
<syntaxhighlight lang=cpp>#ifndef ANIMATIONWIDGET_H
#define ANIMATIONWIDGET_H
#define ANIMATIONWIDGET_H


Line 1,659: Line 1,659:
};
};


#endif // ANIMATIONWIDGET_H</lang>
#endif // ANIMATIONWIDGET_H</syntaxhighlight>


Contents of main.cpp:
Contents of main.cpp:
<lang cpp>#include "animationwidget.h"
<syntaxhighlight lang=cpp>#include "animationwidget.h"


#include <QApplication>
#include <QApplication>
Line 1,671: Line 1,671:
w.show();
w.show();
return a.exec();
return a.exec();
}</lang>
}</syntaxhighlight>


=={{header|Ceylon}}==
=={{header|Ceylon}}==
module.ceylon
module.ceylon
<lang ceylon>native("jvm")
<syntaxhighlight lang=ceylon>native("jvm")
module animation "1.0.0" {
module animation "1.0.0" {
import java.desktop "8";
import java.desktop "8";
}
}
</syntaxhighlight>
</lang>
run.ceylon
run.ceylon
<lang ceylon>import javax.swing {
<syntaxhighlight lang=ceylon>import javax.swing {
JFrame,
JFrame,
JLabel,
JLabel,
Line 1,723: Line 1,723:
frame.pack();
frame.pack();
frame.visible = true;
frame.visible = true;
}</lang>
}</syntaxhighlight>


=={{header|Clojure}}==
=={{header|Clojure}}==
Clojure is a JVM language so this example uses Swing, and illustrates Clojure's platform integration.
Clojure is a JVM language so this example uses Swing, and illustrates Clojure's platform integration.
<lang clojure>(import '[javax.swing JFrame JLabel])
<syntaxhighlight lang=clojure>(import '[javax.swing JFrame JLabel])
(import '[java.awt.event MouseAdapter])
(import '[java.awt.event MouseAdapter])


Line 1,759: Line 1,759:
(.setVisible true))
(.setVisible true))
(future-call animator) ;simple way to run animator on a separate thread</lang>
(future-call animator) ;simple way to run animator on a separate thread</syntaxhighlight>


=={{header|Commodore BASIC}}==
=={{header|Commodore BASIC}}==
There is no window management in the stock version of BASIC V2 on the Commodore 64 or VIC 20. This example below is generic enough to use on all Commodore variants. Note: Asterisks (*) may be replaced with Commodore graphics characters for a more decorative "window".
There is no window management in the stock version of BASIC V2 on the Commodore 64 or VIC 20. This example below is generic enough to use on all Commodore variants. Note: Asterisks (*) may be replaced with Commodore graphics characters for a more decorative "window".
<lang commodorebasicv2>
<syntaxhighlight lang=commodorebasicv2>
1 rem rosetta code
1 rem rosetta code
2 rem task: animation
2 rem task: animation
Line 1,786: Line 1,786:
1000 t$=right$(t$,len(t$)-1)+left$(t$,1):return
1000 t$=right$(t$,len(t$)-1)+left$(t$,1):return
1010 t$=right$(t$,1)+left$(t$,len(t$)-1):return
1010 t$=right$(t$,1)+left$(t$,len(t$)-1):return
</syntaxhighlight>
</lang>


=={{header|Common Lisp}}==
=={{header|Common Lisp}}==
The ltk package provides a lisp interface to Tk for creating graphical interfaces. Assuming ''ltk'' has been installed somewhere the following will work as per the Tcl example.
The ltk package provides a lisp interface to Tk for creating graphical interfaces. Assuming ''ltk'' has been installed somewhere the following will work as per the Tcl example.
{{libheader|Tk}}
{{libheader|Tk}}
<lang lisp>(use-package :ltk)
<syntaxhighlight lang=lisp>(use-package :ltk)
(defparameter *message* "Hello World! ")
(defparameter *message* "Hello World! ")
Line 1,823: Line 1,823:
(ltk:mainloop))))
(ltk:mainloop))))
(basic-animation)</lang>
(basic-animation)</syntaxhighlight>


=={{header|D}}==
=={{header|D}}==
Line 1,830: Line 1,830:
{{libheader|SDL_ttf}}
{{libheader|SDL_ttf}}
{{libheader|tools}}
{{libheader|tools}}
<lang d>module test26;
<syntaxhighlight lang=d>module test26;


import qd, SDL_ttf, tools.time;
import qd, SDL_ttf, tools.time;
Line 1,853: Line 1,853:
) dir = !dir;
) dir = !dir;
}
}
}</lang>
}</syntaxhighlight>


=={{header|Dart}}==
=={{header|Dart}}==
Line 1,859: Line 1,859:
{{libheader|Flutter}}
{{libheader|Flutter}}
view it on dartpad!
view it on dartpad!
<lang javascript>import 'package:flutter/material.dart';
<syntaxhighlight lang=javascript>import 'package:flutter/material.dart';
import 'dart:async' show Timer;
import 'dart:async' show Timer;


Line 1,937: Line 1,937:
}
}
</syntaxhighlight>
</lang>




===HTML DOM===
===HTML DOM===
{{libheader|Html Dom}}
{{libheader|Html Dom}}
<lang javascript>import 'dart:html';
<syntaxhighlight lang=javascript>import 'dart:html';
import 'dart:async';
import 'dart:async';


Line 1,968: Line 1,968:
}
}
}
}
</syntaxhighlight>
</lang>
=={{header|Delphi}}==
=={{header|Delphi}}==
{{libheader| Winapi.Windows}}
{{libheader| Winapi.Windows}}
Line 1,977: Line 1,977:
{{libheader| Vcl.StdCtrls}}
{{libheader| Vcl.StdCtrls}}
{{libheader| Vcl.ExtCtrls}}
{{libheader| Vcl.ExtCtrls}}
<lang Delphi>
<syntaxhighlight lang=Delphi>
unit Main;
unit Main;


Line 2,020: Line 2,020:
Caption := Shift(Caption, Reverse);
Caption := Shift(Caption, Reverse);
end;
end;
end.</lang>
end.</syntaxhighlight>
Form resource:
Form resource:
<lang Delphi>
<syntaxhighlight lang=Delphi>
object Form1: TForm1
object Form1: TForm1
ClientHeight = 132
ClientHeight = 132
Line 2,038: Line 2,038:
end
end
end
end
</syntaxhighlight>
</lang>
=={{header|E}}==
=={{header|E}}==


{{works with|E-on-Java}} (Java Swing; tested on Mac OS X 10.5.7)
{{works with|E-on-Java}} (Java Swing; tested on Mac OS X 10.5.7)


<lang e># State
<syntaxhighlight lang=e># State
var text := "Hello World! "
var text := "Hello World! "
var leftward := false
var leftward := false
Line 2,080: Line 2,080:
# Start everything
# Start everything
w.show()
w.show()
anim.start()</lang>
anim.start()</syntaxhighlight>


Text-only version (no Java dependency; no clicking, use reverse() and stop() to control):
Text-only version (no Java dependency; no clicking, use reverse() and stop() to control):


<lang e>def [reverse, stop] := {
<syntaxhighlight lang=e>def [reverse, stop] := {
var text := "Hello World! "
var text := "Hello World! "
var leftward := false
var leftward := false
Line 2,100: Line 2,100:
anim.start()
anim.start()
[def _() { leftward := !leftward; null }, anim.stop]
[def _() { leftward := !leftward; null }, anim.stop]
}</lang>
}</syntaxhighlight>


=={{header|Elm}}==
=={{header|Elm}}==
<lang elm>module Main exposing (..)
<syntaxhighlight lang=elm>module Main exposing (..)


import Browser
import Browser
Line 2,215: Line 2,215:
[ text <| rotate message model.time ]
[ text <| rotate message model.time ]
]
]
</syntaxhighlight>
</lang>


=={{header|F Sharp|F#}}==
=={{header|F Sharp|F#}}==
{{libheader|Windows Presentation Foundation}}
{{libheader|Windows Presentation Foundation}}
<lang fsharp>open System.Windows
<syntaxhighlight lang=fsharp>open System.Windows


let str = "Hello world! "
let str = "Hello world! "
Line 2,233: Line 2,233:
button.Content <- str.[i..] + str.[..i-1]
button.Content <- str.[i..] + str.[..i-1]
Media.CompositionTarget.Rendering.Add update
Media.CompositionTarget.Rendering.Add update
(Application()).Run(Window(Content=button)) |> ignore</lang>
(Application()).Run(Window(Content=button)) |> ignore</syntaxhighlight>


=={{header|Factor}}==
=={{header|Factor}}==
<lang Factor>USING: accessors timers calendar kernel models sequences ui
<syntaxhighlight lang=Factor>USING: accessors timers calendar kernel models sequences ui
ui.gadgets ui.gadgets.labels ui.gestures ;
ui.gadgets ui.gadgets.labels ui.gestures ;
FROM: models => change-model ;
FROM: models => change-model ;
Line 2,265: Line 2,265:
[ sentence <model> <animated-label> "Rosetta" open-window ] with-ui ;
[ sentence <model> <animated-label> "Rosetta" open-window ] with-ui ;
MAIN: main</lang>
MAIN: main</syntaxhighlight>


=={{header|Fantom}}==
=={{header|Fantom}}==


<lang fantom>
<syntaxhighlight lang=fantom>
using concurrent
using concurrent
using fwt
using fwt
Line 2,345: Line 2,345:
}
}
}
}
</syntaxhighlight>
</lang>


=={{header|FBSL}}==
=={{header|FBSL}}==


<lang qbasic>#INCLUDE <Include\Windows.inc>
<syntaxhighlight lang=qbasic>#INCLUDE <Include\Windows.inc>


FBSLSETTEXT(ME, "Hello world! ")
FBSLSETTEXT(ME, "Hello world! ")
Line 2,378: Line 2,378:
END IF
END IF
FBSLSETTEXT(ME, caption)
FBSLSETTEXT(ME, caption)
END SUB</lang>
END SUB</syntaxhighlight>


=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==
Line 2,386: Line 2,386:
To exit, push the window's closing cross. (255 + 107 is the combination that is passed to INKEY$ by that button.)
To exit, push the window's closing cross. (255 + 107 is the combination that is passed to INKEY$ by that button.)


<lang freebasic>DIM C AS STRING = "Hello World! ", SIZE AS USHORT = LEN(C)
<syntaxhighlight lang=freebasic>DIM C AS STRING = "Hello World! ", SIZE AS USHORT = LEN(C)
DIM DIRECTION AS BYTE = 0
DIM DIRECTION AS BYTE = 0
DIM AS INTEGER X, Y, BTNS
DIM AS INTEGER X, Y, BTNS
Line 2,418: Line 2,418:


SLEEP 100, 1
SLEEP 100, 1
LOOP</lang>
LOOP</syntaxhighlight>


=={{header|Gambas}}==
=={{header|Gambas}}==
<lang gambas>'This code will create the necessary controls on a GUI Form
<syntaxhighlight lang=gambas>'This code will create the necessary controls on a GUI Form


hLabel As Label 'Label needed to display the 'Hello World! " message
hLabel As Label 'Label needed to display the 'Hello World! " message
Line 2,486: Line 2,486:
hLabel.text = sString 'Display the result
hLabel.text = sString 'Display the result


End</lang>
End</syntaxhighlight>
'''[http://www.cogier.com/gambas/Animation.png Click here for image of running code]'''
'''[http://www.cogier.com/gambas/Animation.png Click here for image of running code]'''


=={{header|Go}}==
=={{header|Go}}==
<lang go>package main
<syntaxhighlight lang=go>package main


import (
import (
Line 2,547: Line 2,547:
}
}
}
}
}</lang>
}</syntaxhighlight>


=={{header|Haskell}}==
=={{header|Haskell}}==
Using simple graphics {{libheader|HGL}} from [http://hackage.haskell.org/packages/hackage.html HackageDB]
Using simple graphics {{libheader|HGL}} from [http://hackage.haskell.org/packages/hackage.html HackageDB]
<lang haskell>import Graphics.HGL.Units (Time, Point, Size, )
<syntaxhighlight lang=haskell>import Graphics.HGL.Units (Time, Point, Size, )
import Graphics.HGL.Draw.Monad (Graphic, )
import Graphics.HGL.Draw.Monad (Graphic, )
import Graphics.HGL.Draw.Text
import Graphics.HGL.Draw.Text
Line 2,576: Line 2,576:
loop t' d
loop t' d
loop "Hello world ! " 1 )</lang>
loop "Hello world ! " 1 )</syntaxhighlight>
Run within interpreter GHCi:
Run within interpreter GHCi:
<lang haskell>*Main> runAnim</lang>
<syntaxhighlight lang=haskell>*Main> runAnim</syntaxhighlight>


=={{header|HicEst}}==
=={{header|HicEst}}==
<lang hicest>CHARACTER string="Hello World! "
<syntaxhighlight lang=hicest>CHARACTER string="Hello World! "


WINDOW(WINdowhandle=wh, Height=1, X=1, TItle="left/right click to rotate left/right, Y-click-position sets milliseconds period")
WINDOW(WINdowhandle=wh, Height=1, X=1, TItle="left/right click to rotate left/right, Y-click-position sets milliseconds period")
Line 2,598: Line 2,598:
SUBROUTINE Mouse_callback()
SUBROUTINE Mouse_callback()
direction = button_type ! 4 == left button up, 8 == right button up
direction = button_type ! 4 == left button up, 8 == right button up
END </lang>
END </syntaxhighlight>


=={{header|Icon}} and {{header|Unicon}}==
=={{header|Icon}} and {{header|Unicon}}==
The following code uses features exclusive to Unicon.
The following code uses features exclusive to Unicon.


<lang Unicon>import gui
<syntaxhighlight lang=Unicon>import gui
$include "guih.icn"
$include "guih.icn"


Line 2,647: Line 2,647:
w.show_modal ()
w.show_modal ()
end
end
</syntaxhighlight>
</lang>


The following code uses features exclusive to Icon.
The following code uses features exclusive to Icon.
<lang Icon>
<syntaxhighlight lang=Icon>
link graphics
link graphics


Line 2,672: Line 2,672:
}
}
end
end
</syntaxhighlight>
</lang>


=={{header|J}}==
=={{header|J}}==
{{works with|J8}}
{{works with|J8}}
<lang j>coinsert'jgl2' [ require'gl2'
<syntaxhighlight lang=j>coinsert'jgl2' [ require'gl2'
MESSAGE =: 'Hello World! '
MESSAGE =: 'Hello World! '
Line 2,701: Line 2,701:
)
)
anim_run ''</lang>
anim_run ''</syntaxhighlight>


{{works with|J6}}
{{works with|J6}}
<lang j>coinsert'jgl2' [ require'gl2'
<syntaxhighlight lang=j>coinsert'jgl2' [ require'gl2'


MESSAGE =: 'Hello World! '
MESSAGE =: 'Hello World! '
Line 2,729: Line 2,729:
)
)


anim_run ''</lang>
anim_run ''</syntaxhighlight>


=={{header|Java}}==
=={{header|Java}}==
{{libheader|Swing}}
{{libheader|Swing}}
<lang java>import java.awt.event.MouseAdapter;
<syntaxhighlight lang=java>import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowAdapter;
Line 2,793: Line 2,793:
return String.valueOf(rotated);
return String.valueOf(rotated);
}
}
}</lang>
}</syntaxhighlight>


=={{header|JavaScript}} + {{header|HTML}}==
=={{header|JavaScript}} + {{header|HTML}}==
<lang javascript><html> <head>
<syntaxhighlight lang=javascript><html> <head>
<title>RC: Basic Animation</title>
<title>RC: Basic Animation</title>
<script type="text/javascript">
<script type="text/javascript">
Line 2,819: Line 2,819:
</head> <body onload="animate('target')">
</head> <body onload="animate('target')">
<pre id="target">Hello World! </pre>
<pre id="target">Hello World! </pre>
</body> </html></lang>
</body> </html></syntaxhighlight>


=={{header|JavaScript}} + {{header|SVG}}==
=={{header|JavaScript}} + {{header|SVG}}==
<lang javascript><svg xmlns="http://www.w3.org/2000/svg"
<syntaxhighlight lang=javascript><svg xmlns="http://www.w3.org/2000/svg"
width="100" height="40">
width="100" height="40">
<script type="text/javascript">
<script type="text/javascript">
Line 2,844: Line 2,844:
<rect width="100" height="40" fill="yellow"/>
<rect width="100" height="40" fill="yellow"/>
<text x="2" y="20" onload="animate(this);">Hello World! </text>
<text x="2" y="20" onload="animate(this);">Hello World! </text>
</svg></lang>
</svg></syntaxhighlight>


=={{header|Julia}}==
=={{header|Julia}}==
{{libheader|Julia/Tk}}
{{libheader|Julia/Tk}}
<lang Julia>
<syntaxhighlight lang=Julia>
using Tk
using Tk


Line 2,884: Line 2,884:


windowanim(frameinterval)
windowanim(frameinterval)
</syntaxhighlight>
</lang>
{{libheader|Julia/Gtk}}
{{libheader|Julia/Gtk}}
<lang julia>
<syntaxhighlight lang=julia>
using Gtk.ShortNames
using Gtk.ShortNames
Line 2,922: Line 2,922:


textanimation(frameinterval)
textanimation(frameinterval)
</syntaxhighlight>
</lang>


=={{header|Kotlin}}==
=={{header|Kotlin}}==
{{trans|Java}}
{{trans|Java}}
<lang scala>// version 1.1.0
<syntaxhighlight lang=scala>// version 1.1.0


import java.awt.Dimension
import java.awt.Dimension
Line 2,980: Line 2,980:
}
}
Timer(false).schedule(task, 0, 500)
Timer(false).schedule(task, 0, 500)
}</lang>
}</syntaxhighlight>


=={{header|LabVIEW}}==
=={{header|LabVIEW}}==
Line 2,987: Line 2,987:


=={{header|Liberty BASIC}}==
=={{header|Liberty BASIC}}==
<lang lb> txt$ = "Hello World! "
<syntaxhighlight lang=lb> txt$ = "Hello World! "
txtLength = len(txt$)
txtLength = len(txt$)
direction=1
direction=1
Line 3,020: Line 3,020:
timer 0
timer 0
close #demo
close #demo
end</lang>
end</syntaxhighlight>


=={{header|Logo}}==
=={{header|Logo}}==
{{works with|UCB Logo}}
{{works with|UCB Logo}}
<lang logo>to rotate.left :thing
<syntaxhighlight lang=logo>to rotate.left :thing
output lput first :thing butfirst :thing
output lput first :thing butfirst :thing
end
end
Line 3,043: Line 3,043:


hideturtle
hideturtle
until [key?] [step.animation]</lang>
until [key?] [step.animation]</syntaxhighlight>




=={{header|Lua}}==
=={{header|Lua}}==
{{works with|LÖVE}}
{{works with|LÖVE}}
<lang Lua>function love.load()
<syntaxhighlight lang=Lua>function love.load()
text = "Hello World! "
text = "Hello World! "
length = string.len(text)
length = string.len(text)
Line 3,096: Line 3,096:
function love.mousepressed( x, y, button, istouch, presses )
function love.mousepressed( x, y, button, istouch, presses )
right_direction = not right_direction
right_direction = not right_direction
end</lang>
end</syntaxhighlight>


=={{header|M2000 Interpreter}}==
=={{header|M2000 Interpreter}}==
Line 3,102: Line 3,102:
Any Button can use a blink, a timer which return a changed value, true or false, but here we didn't use it (so we didn't Read from event's stack of values. We can place Stack statement to view this stack in console).
Any Button can use a blink, a timer which return a changed value, true or false, but here we didn't use it (so we didn't Read from event's stack of values. We can place Stack statement to view this stack in console).


<lang M2000 Interpreter>
<syntaxhighlight lang=M2000 Interpreter>
Module UseBlink {
Module UseBlink {
Def boolean direction=True
Def boolean direction=True
Line 3,130: Line 3,130:
UseBlink
UseBlink


</syntaxhighlight>
</lang>
===Using Every Statement===
===Using Every Statement===
We can use console as window too. Although we don't have events for this window, we can read mouse button. Also we use split screen so first line (line 0) has the title, and all other lines are cleared before we print on it, every 200ms
We can use console as window too. Although we don't have events for this window, we can read mouse button. Also we use split screen so first line (line 0) has the title, and all other lines are cleared before we print on it, every 200ms


<lang M2000 Interpreter>
<syntaxhighlight lang=M2000 Interpreter>
Module UseEvery {
Module UseEvery {
Window 16, 6000,4000;
Window 16, 6000,4000;
Line 3,151: Line 3,151:
}
}
UseEvery
UseEvery
</syntaxhighlight>
</lang>


===Using Thread===
===Using Thread===
Line 3,158: Line 3,158:
When a thread created saves the current layer, to use it in each iteration.
When a thread created saves the current layer, to use it in each iteration.


<lang M2000 Interpreter>
<syntaxhighlight lang=M2000 Interpreter>
Module UseThread {
Module UseThread {
Def boolean direction=True
Def boolean direction=True
Line 3,182: Line 3,182:
}
}
UseThread
UseThread
</syntaxhighlight>
</lang>


=={{header|Maple}}==
=={{header|Maple}}==
First, create a textbox, and by right-clicking it, and selecting component properties, change its name to "Text". Then, create 2 buttons, changing the caption on one to "Reverse", and the other to "Forward". In the edit click action of each respective button, you will put:
First, create a textbox, and by right-clicking it, and selecting component properties, change its name to "Text". Then, create 2 buttons, changing the caption on one to "Reverse", and the other to "Forward". In the edit click action of each respective button, you will put:
<lang Maple>
<syntaxhighlight lang=Maple>
ScrollText(GP("Text",value),"Forward",65);
ScrollText(GP("Text",value),"Forward",65);
</lang>
</syntaxhighlight>
and:
and:
<lang Maple>
<syntaxhighlight lang=Maple>
ScrollText(GP("Text",value),"Reverse",65);
ScrollText(GP("Text",value),"Reverse",65);
</syntaxhighlight>
</lang>
Then in the startup actions, accessed by clicking the 2 gears, add this:
Then in the startup actions, accessed by clicking the 2 gears, add this:
<lang Maple>
<syntaxhighlight lang=Maple>
macro(SP=DocumentTools:-SetProperty, GP=DocumentTools:-GetProperty);
macro(SP=DocumentTools:-SetProperty, GP=DocumentTools:-GetProperty);
SP("Text",value,"Hello World! ");
SP("Text",value,"Hello World! ");
Line 3,213: Line 3,213:
end do:
end do:
end proc:
end proc:
</syntaxhighlight>
</lang>


=={{header|Mathematica}} / {{header|Wolfram Language}}==
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<lang Mathematica>mystring = "Hello World! ";
<syntaxhighlight lang=Mathematica>mystring = "Hello World! ";
Scroll[str_, dir_] := StringJoin @@ RotateLeft[str // Characters, dir];
Scroll[str_, dir_] := StringJoin @@ RotateLeft[str // Characters, dir];
GiveString[dir_] := (mystring = Scroll[mystring, dir]);
GiveString[dir_] := (mystring = Scroll[mystring, dir]);
Line 3,225: Line 3,225:
Refresh[GiveString[direction], UpdateInterval -> 1/8]],
Refresh[GiveString[direction], UpdateInterval -> 1/8]],
TrackedSymbols -> {}], {"MouseClicked" :> (direction *= -1)}]]
TrackedSymbols -> {}], {"MouseClicked" :> (direction *= -1)}]]
}];</lang>
}];</syntaxhighlight>


=={{header|MAXScript}}==
=={{header|MAXScript}}==
Creates a window with a rotating label and 2 buttons to change the direction.
Creates a window with a rotating label and 2 buttons to change the direction.


<lang MAXScript>
<syntaxhighlight lang=MAXScript>
try destroydialog animGUI catch ()
try destroydialog animGUI catch ()


Line 3,278: Line 3,278:


createdialog animGUI
createdialog animGUI
</syntaxhighlight>
</lang>


=={{header|MiniScript}}==
=={{header|MiniScript}}==
{{works with|Mini Micro}}
{{works with|Mini Micro}}
<lang MiniScript>clear
<syntaxhighlight lang=MiniScript>clear
text.inverse = true
text.inverse = true
s = "Hello World! "
s = "Hello World! "
Line 3,293: Line 3,293:
end while
end while
text.inverse = false
text.inverse = false
key.clear</lang>
key.clear</syntaxhighlight>


=={{header|Nim}}==
=={{header|Nim}}==
{{libheader|gintro}}
{{libheader|gintro}}
<lang Nim>import gintro/[glib, gobject, gdk, gtk, gio]
<syntaxhighlight lang=Nim>import gintro/[glib, gobject, gdk, gtk, gio]


type
type
Line 3,357: Line 3,357:
let app = newApplication(Application, "Rosetta.animation")
let app = newApplication(Application, "Rosetta.animation")
discard app.connect("activate", activate)
discard app.connect("activate", activate)
discard app.run()</lang>
discard app.run()</syntaxhighlight>


=={{header|Oz}}==
=={{header|Oz}}==
<lang oz>functor
<syntaxhighlight lang=oz>functor
import
import
Application
Application
Line 3,419: Line 3,419:
{Start}
{Start}
end</lang>
end</syntaxhighlight>


=={{header|Pascal}}==
=={{header|Pascal}}==
===LCL (Lazarus)===
===LCL (Lazarus)===
<lang Pascal>program HelloWorldAnimatedGUI;
<syntaxhighlight lang=Pascal>program HelloWorldAnimatedGUI;


uses {$IFDEF UNIX} {$IFDEF UseCThreads}
uses {$IFDEF UNIX} {$IFDEF UseCThreads}
Line 3,499: Line 3,499:
Application.CreateForm(TFrmHelloWorldAnim, FrmHelloWorldAnim);
Application.CreateForm(TFrmHelloWorldAnim, FrmHelloWorldAnim);
Application.Run;
Application.Run;
end.</lang>
end.</syntaxhighlight>
Example can be compiled by FreePascal/Lazarus.
Example can be compiled by FreePascal/Lazarus.
Did all in one file, normally you have the project-file, the form-unit- and the form-resource-file.
Did all in one file, normally you have the project-file, the form-unit- and the form-resource-file.


=={{header|Perl}}==
=={{header|Perl}}==
<lang perl>use Tk;
<syntaxhighlight lang=perl>use Tk;
use Time::HiRes qw(sleep);
use Time::HiRes qw(sleep);


Line 3,530: Line 3,530:
$mw->update();
$mw->update();
}
}
}</lang>
}</syntaxhighlight>


=={{header|Phix}}==
=={{header|Phix}}==
{{libheader|Phix/pGUI}}
{{libheader|Phix/pGUI}}
Clicking on the label changes the animation direction.
Clicking on the label changes the animation direction.
<!--<lang Phix>(phixonline)-->
<!--<syntaxhighlight lang=Phix>(phixonline)-->
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Animation.exw</span>
<span style="color: #000080;font-style:italic;">-- demo\rosetta\Animation.exw</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
Line 3,572: Line 3,572:
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</lang>-->
<!--</syntaxhighlight>-->


=={{header|PicoLisp}}==
=={{header|PicoLisp}}==
===Plain text===
===Plain text===
A plain text version. The following script works in an XTerm window.
A plain text version. The following script works in an XTerm window.
<lang PicoLisp>#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
<syntaxhighlight lang=PicoLisp>#!/usr/bin/picolisp /usr/lib/picolisp/lib.l


(prin "^[[?9h") # Mouse reporting on
(prin "^[[?9h") # Mouse reporting on
Line 3,590: Line 3,590:
(setq Dir (if (= 1 Dir) 12 1)) )
(setq Dir (if (= 1 Dir) 12 1)) )
(key) (key) )
(key) (key) )
(do (length Text) (prin "^H")) )</lang>
(do (length Text) (prin "^H")) )</syntaxhighlight>
===HTML/JavaScript===
===HTML/JavaScript===
The standard PicoLisp GUI is HTTP based. Connect your browser to
The standard PicoLisp GUI is HTTP based. Connect your browser to
Line 3,597: Line 3,597:
The scrolling text is displayed in a button. Clicking on the button
The scrolling text is displayed in a button. Clicking on the button
reverses the scroll direction.
reverses the scroll direction.
<lang PicoLisp>#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
<syntaxhighlight lang=PicoLisp>#!/usr/bin/picolisp /usr/lib/picolisp/lib.l


(load "@ext.l" "@lib/http.l" "@lib/xhtml.l" "@lib/form.l")
(load "@ext.l" "@lib/http.l" "@lib/xhtml.l" "@lib/form.l")
Line 3,614: Line 3,614:


(server 8080 "!start")
(server 8080 "!start")
(wait)</lang>
(wait)</syntaxhighlight>


===Java/Swing===
===Java/Swing===
This solution works on ErsatzLisp, the Java version of PicoLisp.
This solution works on ErsatzLisp, the Java version of PicoLisp.
<lang PicoLisp>#!ersatz/pil
<syntaxhighlight lang=PicoLisp>#!ersatz/pil


(setq
(setq
Line 3,639: Line 3,639:
(loop
(loop
(wait 200)
(wait 200)
(java Label 'setText (pack (do Dir (rot Text)))) )</lang>
(java Label 'setText (pack (do Dir (rot Text)))) )</syntaxhighlight>


=={{header|Processing}}==
=={{header|Processing}}==
<lang processing>String txt = "Hello, world! ";
<syntaxhighlight lang=processing>String txt = "Hello, world! ";
boolean dir = true;
boolean dir = true;


Line 3,667: Line 3,667:
}
}
return String.valueOf(rotated);
return String.valueOf(rotated);
}</lang>
}</syntaxhighlight>


==={{header|Processing Python mode}}===
==={{header|Processing Python mode}}===
Line 3,673: Line 3,673:
When the user clicks on the (windowed) text, it should reverse its direction.
When the user clicks on the (windowed) text, it should reverse its direction.


<lang python>txt = "Hello, world! "
<syntaxhighlight lang=python>txt = "Hello, world! "
left = True
left = True


Line 3,694: Line 3,694:
rotated = text[startIdx:] + text[:startIdx]
rotated = text[startIdx:] + text[:startIdx]
return rotated
return rotated
</syntaxhighlight>
</lang>


=={{header|Prolog}}==
=={{header|Prolog}}==
SWI-Prolog has a grapghic interface XPCE.
SWI-Prolog has a grapghic interface XPCE.
<lang Prolog>:- use_module(library(pce)).
<syntaxhighlight lang=Prolog>:- use_module(library(pce)).


animation :-
animation :-
Line 3,772: Line 3,772:
get(S, delete_prefix, Str, V),
get(S, delete_prefix, Str, V),
get(V, append, Str, S1).
get(V, append, Str, S1).
</syntaxhighlight>
</lang>


=={{header|PureBasic}}==
=={{header|PureBasic}}==
<lang PureBasic>OpenWindow(0,0,0,500,100,"Hello World!",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
<syntaxhighlight lang=PureBasic>OpenWindow(0,0,0,500,100,"Hello World!",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)


text$ = "Hello World! "
text$ = "Hello World! "
Line 3,804: Line 3,804:
tick = ElapsedMilliseconds()
tick = ElapsedMilliseconds()
EndIf
EndIf
ForEver</lang>
ForEver</syntaxhighlight>


=={{header|Python}}==
=={{header|Python}}==
===Using PyQt===
===Using PyQt===
{{libheader|PyQt5}}
{{libheader|PyQt5}}
<lang python>#!/usr/bin/env python3
<syntaxhighlight lang=python>#!/usr/bin/env python3
import sys
import sys


Line 3,852: Line 3,852:
- w.rect().center())
- w.rect().center())
w.show()
w.show()
sys.exit(app.exec())</lang>
sys.exit(app.exec())</syntaxhighlight>
===Using pygame===
===Using pygame===
{{libheader|pygame}}
{{libheader|pygame}}
<lang python>import pygame, sys
<syntaxhighlight lang=python>import pygame, sys
from pygame.locals import *
from pygame.locals import *
pygame.init()
pygame.init()
Line 3,909: Line 3,909:
while True:
while True:
input(pygame.event.wait())
input(pygame.event.wait())
pygame.display.flip()</lang>
pygame.display.flip()</syntaxhighlight>
===Using Tkinter===
===Using Tkinter===
<lang python>import Tkinter as tki
<syntaxhighlight lang=python>import Tkinter as tki


def scroll_text(s, how_many):
def scroll_text(s, how_many):
Line 3,934: Line 3,934:
tk.title('Python Animation')
tk.title('Python Animation')
tki.mainloop()
tki.mainloop()
</syntaxhighlight>
</lang>


=={{header|Quick BASIC}}==
=={{header|Quick BASIC}}==
Line 3,945: Line 3,945:
{{libheader|QB.QLB / QBX.QLB}}
{{libheader|QB.QLB / QBX.QLB}}


<lang qbasic>
<syntaxhighlight lang=qbasic>
'here accordingly to the version, QB or QBX
'here accordingly to the version, QB or QBX
REM $INCLUDE: 'QBX.BI'
REM $INCLUDE: 'QBX.BI'
Line 3,988: Line 3,988:
IF TIMER < I THEN I = I - 86400 'midnight checking
IF TIMER < I THEN I = I - 86400 'midnight checking
LOOP
LOOP
LOOP</lang>
LOOP</syntaxhighlight>


=={{header|R}}==
=={{header|R}}==
Line 3,994: Line 3,994:


The basic principle is:create a window with a label in it, then add a handler to the label for rotating the string, and another for changing direction on a click. Use of the tag function allows you to store the text flow direction as an attribute of the label.
The basic principle is:create a window with a label in it, then add a handler to the label for rotating the string, and another for changing direction on a click. Use of the tag function allows you to store the text flow direction as an attribute of the label.
<syntaxhighlight lang=r>
<lang r>
rotate_string <- function(x, forwards)
rotate_string <- function(x, forwards)
{
{
Line 4,034: Line 4,034:
handle_rotate_label(lab)
handle_rotate_label(lab)
handle_change_direction_on_click(lab)
handle_change_direction_on_click(lab)
</syntaxhighlight>
</lang>


=={{header|Racket}}==
=={{header|Racket}}==


<lang racket>
<syntaxhighlight lang=racket>
#lang racket/gui
#lang racket/gui


Line 4,079: Line 4,079:


(send frame show #t)
(send frame show #t)
</syntaxhighlight>
</lang>




This is a more functional approach - there is no explicit mutation, everything is handled through event callbacks.
This is a more functional approach - there is no explicit mutation, everything is handled through event callbacks.
<lang racket>
<syntaxhighlight lang=racket>
#lang racket
#lang racket
(require racket/match)
(require racket/match)
Line 4,126: Line 4,126:
[on-tick update]
[on-tick update]
[on-mouse handle-mouse])
[on-mouse handle-mouse])
</syntaxhighlight>
</lang>


=={{header|Raku}}==
=={{header|Raku}}==
Line 4,132: Line 4,132:
{{works with|Rakudo|2019.03}}
{{works with|Rakudo|2019.03}}


<lang perl6>use GTK::Simple;
<syntaxhighlight lang=perl6>use GTK::Simple;
use GTK::Simple::App;
use GTK::Simple::App;


Line 4,148: Line 4,148:
$app.set-content($vbox);
$app.set-content($vbox);


$app.run;</lang>
$app.run;</syntaxhighlight>


=={{header|REBOL}}==
=={{header|REBOL}}==
<lang REBOL>REBOL [
<syntaxhighlight lang=REBOL>REBOL [
Title: "Basic Animation"
Title: "Basic Animation"
URL: http://rosettacode.org/wiki/Basic_Animation
URL: http://rosettacode.org/wiki/Basic_Animation
Line 4,193: Line 4,193:
]
]
]
]
]</lang>
]</syntaxhighlight>
=={{header|Red}}==
=={{header|Red}}==
<lang Red>Red ["Animation"]
<syntaxhighlight lang=Red>Red ["Animation"]


rev: false
rev: false
roule: does [e: back tail s: t/text either rev [move e s] [move s e]]
roule: does [e: back tail s: t/text either rev [move e s] [move s e]]
view [t: text "Hello world! " rate 5 [rev: not rev] on-time [roule]]</lang>
view [t: text "Hello world! " rate 5 [rev: not rev] on-time [roule]]</syntaxhighlight>


=={{header|REXX}}==
=={{header|REXX}}==
This REXX version <u>only</u> works with REXX/Personal or REXX/PC.
This REXX version <u>only</u> works with REXX/Personal or REXX/PC.
<lang rexx>/*REXX prg displays a text string (in one direction), and reverses when a key is pressed*/
<syntaxhighlight lang=rexx>/*REXX prg displays a text string (in one direction), and reverses when a key is pressed*/
parse upper version !ver !vernum .; !pcRexx= 'REXX/PERSONAL'==!ver | 'REXX/PC'==!ver
parse upper version !ver !vernum .; !pcRexx= 'REXX/PERSONAL'==!ver | 'REXX/PC'==!ver
if \!pcRexx then do
if \!pcRexx then do
Line 4,224: Line 4,224:
else $= right($, 1)substr($, 1, length($) - 1) /* ··· the other·*/
else $= right($, 1)substr($, 1, length($) - 1) /* ··· the other·*/
end /*until*/
end /*until*/
halt: /*stick a fork in it, we're all done. */</lang><br><br>
halt: /*stick a fork in it, we're all done. */</syntaxhighlight><br><br>


=={{header|Ring}}==
=={{header|Ring}}==
<lang ring>
<syntaxhighlight lang=ring>
# Project : Animation
# Project : Animation


Line 4,268: Line 4,268:
next
next
see nl
see nl
</syntaxhighlight>
</lang>
Output:
Output:
<pre>
<pre>
Line 4,307: Line 4,307:
{{trans|Tcl}}
{{trans|Tcl}}
{{libheader|Ruby/Tk}}
{{libheader|Ruby/Tk}}
<lang ruby>require 'tk'
<syntaxhighlight lang=ruby>require 'tk'
$str = TkVariable.new("Hello World! ")
$str = TkVariable.new("Hello World! ")
$dir = :right
$dir = :right
Line 4,333: Line 4,333:
animate
animate
Tk.mainloop</lang>
Tk.mainloop</syntaxhighlight>


{{libheader|Shoes}}
{{libheader|Shoes}}
<lang ruby>Shoes.app do
<syntaxhighlight lang=ruby>Shoes.app do
@direction = 1
@direction = 1
@label = para "Hello World! ", :family => 'monospace'
@label = para "Hello World! ", :family => 'monospace'
Line 4,346: Line 4,346:
@label.text = @direction > 0 ? t[-1] + t[0..-2] : t[1..-1] + t[0]
@label.text = @direction > 0 ? t[-1] + t[0..-2] : t[1..-1] + t[0]
end
end
end</lang>
end</syntaxhighlight>


=={{header|Rust}}==
=={{header|Rust}}==
==={{libheader|GTK}}===
==={{libheader|GTK}}===
<lang rust>#[cfg(feature = "gtk")]
<syntaxhighlight lang=rust>#[cfg(feature = "gtk")]
mod graphical {
mod graphical {
extern crate gtk;
extern crate gtk;
Line 4,409: Line 4,409:


#[cfg(not(feature = "gtk"))]
#[cfg(not(feature = "gtk"))]
fn main() {}</lang>
fn main() {}</syntaxhighlight>


=={{header|Scala}}==
=={{header|Scala}}==
{{works with|Scala|2.8}}
{{works with|Scala|2.8}}
<lang scala>import scala.actors.Actor.{actor, loop, reactWithin, exit}
<syntaxhighlight lang=scala>import scala.actors.Actor.{actor, loop, reactWithin, exit}
import scala.actors.TIMEOUT
import scala.actors.TIMEOUT
import scala.swing.{SimpleSwingApplication, MainFrame, Label}
import scala.swing.{SimpleSwingApplication, MainFrame, Label}
Line 4,444: Line 4,444:
case _ : MouseClicked => rotator ! Revert
case _ : MouseClicked => rotator ! Revert
}
}
}</lang>
}</syntaxhighlight>


=={{header|Scratch}}==
=={{header|Scratch}}==
Line 4,456: Line 4,456:


=={{header|smart BASIC}}==
=={{header|smart BASIC}}==
<lang smart BASIC>'Animation, by rbytes and Dutchman
<syntaxhighlight lang=smart BASIC>'Animation, by rbytes and Dutchman
word$="Hello World! "
word$="Hello World! "
'use button window with text
'use button window with text
Line 4,489: Line 4,489:
=={{header|Standard ML}}==
=={{header|Standard ML}}==
Works with PolyML interpreter. Add loop for compilation.
Works with PolyML interpreter. Add loop for compilation.
<lang Standard ML>open XWindows ;
<syntaxhighlight lang=Standard ML>open XWindows ;
open Motif ;
open Motif ;
Line 4,534: Line 4,534:
)
)
end;</lang>
end;</syntaxhighlight>


call
call
Line 4,540: Line 4,540:


=={{header|Suneido}}==
=={{header|Suneido}}==
<lang Suneido>Window(Controller
<syntaxhighlight lang=Suneido>Window(Controller
{
{
Xmin: 50
Xmin: 50
Line 4,575: Line 4,575:
super.Destroy()
super.Destroy()
}
}
})</lang>
})</syntaxhighlight>


=={{header|SVG}}==
=={{header|SVG}}==
Line 4,583: Line 4,583:
This animation is defined as a smooth movement rather than by moving whole characters, because that is more natural in SVG (without scripting); by characters would require 13 different text elements displayed in sequence.
This animation is defined as a smooth movement rather than by moving whole characters, because that is more natural in SVG (without scripting); by characters would require 13 different text elements displayed in sequence.


<lang xml><svg xmlns="http://www.w3.org/2000/svg" width="100" height="30">
<syntaxhighlight lang=xml><svg xmlns="http://www.w3.org/2000/svg" width="100" height="30">
<g id="all">
<g id="all">
<rect width="100%" height="100%" fill="yellow"/>
<rect width="100%" height="100%" fill="yellow"/>
Line 4,599: Line 4,599:
</g>
</g>
</g>
</g>
</svg></lang>
</svg></syntaxhighlight>


(Does not work in Safari 4.0.2 because it apparently does not implement toggled animations correctly ([http://www.w3.org/TR/2001/REC-smil-animation-20010904/#RestartAttribute see spec]). Dreadful workaround: set the two animations to <code>id="a" begin="0s;all.click" end="all.mousedown"</code> and <code>begin="a.end" end="all.click"</code>, respectively.)
(Does not work in Safari 4.0.2 because it apparently does not implement toggled animations correctly ([http://www.w3.org/TR/2001/REC-smil-animation-20010904/#RestartAttribute see spec]). Dreadful workaround: set the two animations to <code>id="a" begin="0s;all.click" end="all.mousedown"</code> and <code>begin="a.end" end="all.click"</code>, respectively.)
Line 4,605: Line 4,605:
=={{header|Tcl}}==
=={{header|Tcl}}==
{{libheader|Tk}}
{{libheader|Tk}}
<lang tcl>package require Tk
<syntaxhighlight lang=tcl>package require Tk
set s "Hello World! "
set s "Hello World! "
set dir 0
set dir 0
Line 4,624: Line 4,624:
bind .l <Button-1> {set dir [expr {!$dir}]}
bind .l <Button-1> {set dir [expr {!$dir}]}
# Start the animation
# Start the animation
animate</lang>
animate</syntaxhighlight>


=={{header|TI-89 BASIC}}==
=={{header|TI-89 BASIC}}==
Line 4,689: Line 4,689:
=={{header|Vedit macro language}}==
=={{header|Vedit macro language}}==
It is not possible to detect mouse clicks while a macro is running. Therefore, the direction is controlled with Caps Lock key.
It is not possible to detect mouse clicks while a macro is running. Therefore, the direction is controlled with Caps Lock key.
<lang vedit>Buf_Switch(Buf_Free)
<syntaxhighlight lang=vedit>Buf_Switch(Buf_Free)
Win_Create(Buf_Num, 1, 1, 2, 14)
Win_Create(Buf_Num, 1, 1, 2, 14)
Ins_Text("Hello World! ")
Ins_Text("Hello World! ")
Line 4,703: Line 4,703:
Update()
Update()
Sleep(2)
Sleep(2)
}</lang>
}</syntaxhighlight>


=={{header|Visual Basic}}==
=={{header|Visual Basic}}==
Line 4,709: Line 4,709:
This example shows code that is hidden by the IDE. (Form creation is done graphically within the IDE, not at runtime.)
This example shows code that is hidden by the IDE. (Form creation is done graphically within the IDE, not at runtime.)


<lang vb>VERSION 5.00
<syntaxhighlight lang=vb>VERSION 5.00
Begin VB.Form Form1
Begin VB.Form Form1
Begin VB.Timer Timer1
Begin VB.Timer Timer1
Line 4,739: Line 4,739:
End If
End If
Label1.Caption = x
Label1.Caption = x
End Sub</lang>
End Sub</syntaxhighlight>


=={{header|Wren}}==
=={{header|Wren}}==
{{libheader|DOME}}
{{libheader|DOME}}
<lang ecmascript>import "graphics" for Canvas, Color
<syntaxhighlight lang=ecmascript>import "graphics" for Canvas, Color
import "dome" for Window
import "dome" for Window
import "input" for Mouse
import "input" for Mouse
Line 4,784: Line 4,784:
}
}


var Game = Animation.new()</lang>
var Game = Animation.new()</syntaxhighlight>


=={{header|XPL0}}==
=={{header|XPL0}}==
<lang XPL0>include c:\cxpl\codes;
<syntaxhighlight lang=XPL0>include c:\cxpl\codes;
int CpuReg, Dir, I, J;
int CpuReg, Dir, I, J;
char Str;
char Str;
Line 4,809: Line 4,809:
if CpuReg(1) then Dir:= -Dir;
if CpuReg(1) then Dir:= -Dir;
until KeyHit; \any keystroke terminates program
until KeyHit; \any keystroke terminates program
]</lang>
]</syntaxhighlight>


=={{header|Yabasic}}==
=={{header|Yabasic}}==
<lang Yabasic>clear screen
<syntaxhighlight lang=Yabasic>clear screen
open window 400, 150
open window 400, 150
backcolor 0, 0, 0
backcolor 0, 0, 0
Line 4,833: Line 4,833:
texto$ = right$(texto$, 1) + left$(texto$, l-1)
texto$ = right$(texto$, 1) + left$(texto$, l-1)
end if
end if
loop</lang>
loop</syntaxhighlight>


=={{header|ZX Spectrum Basic}}==
=={{header|ZX Spectrum Basic}}==
{{trans|BBC BASIC}}
{{trans|BBC BASIC}}
Replaces the detection of mouse click by pressing a key (Spectrum does not detect this device by default).
Replaces the detection of mouse click by pressing a key (Spectrum does not detect this device by default).
<lang zxbasic>10 LET t$="Hello world! ": LET lt=LEN t$
<syntaxhighlight lang=zxbasic>10 LET t$="Hello world! ": LET lt=LEN t$
20 LET direction=1
20 LET direction=1
30 PRINT AT 0,0;t$
30 PRINT AT 0,0;t$
Line 4,844: Line 4,844:
50 LET t$=t$(lt)+t$( TO lt-1)
50 LET t$=t$(lt)+t$( TO lt-1)
60 IF INKEY$<>"" THEN LET direction=NOT direction
60 IF INKEY$<>"" THEN LET direction=NOT direction
70 PAUSE 5: GO TO 30</lang>
70 PAUSE 5: GO TO 30</syntaxhighlight>


{{omit from|ACL2}}
{{omit from|ACL2}}