Animation: Difference between revisions

m
Automated syntax highlighting fixup (second round - minor fixes)
m (syntax highlighting fixup automation)
m (Automated syntax highlighting fixup (second round - minor fixes))
Line 1:
{{task|Temporal media}}
[[Category:GUI]]
[[Category:Animation]]
{{task|Temporal media}}
{{requires|Graphics}}
 
Line 15 ⟶ 16:
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits <br> or android 64 bits with application Termux }}
<syntaxhighlight lang=AArch64"aarch64 Assemblyassembly">
/* Programme assembleur ARM Raspberry ou Android */
/* programme animletter64.s */
Line 549 ⟶ 550:
 
=={{header|Action!}}==
<syntaxhighlight lang=Action"action!">PROC DrawWindow(BYTE x,y,len)
BYTE i
 
Line 638 ⟶ 639:
 
=={{header|ActionScript}}==
<syntaxhighlight lang=ActionScript"actionscript">//create the text box
var textBox:TextField = new TextField();
addChild(textBox);
Line 666 ⟶ 667:
 
animation.adb:
<syntaxhighlight lang=Ada"ada">with Gtk.Main;
with Gtk.Handlers;
with Gtk.Label;
Line 760 ⟶ 761:
 
=={{header|Applesoft BASIC}}==
<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
30 HTAB INT (( PEEK (33) - L) / 2) + 1: PRINT MID$ (T$,P,L);
Line 769 ⟶ 770:
=={{header|ARM Assembly}}==
{{works with|as|Raspberry Pi <br> or android 32 bits with application Termux}}
<syntaxhighlight lang=ARM"arm Assemblyassembly">
/* ARM assembly Raspberry PI or android 32 bits with termux application */
/* program animLetter.s */
Line 1,415 ⟶ 1,416:
</syntaxhighlight>
=={{header|AutoHotkey}}==
<syntaxhighlight lang=AutoHotkey"autohotkey">SetTimer, Animate ; Timer runs every 250 ms.
String := "Hello World "
Gui, Add, Text, vS gRev, %String%
Line 1,432 ⟶ 1,433:
 
=={{header|BASIC256}}==
<syntaxhighlight lang=BASIC256"basic256">str$="Hello, World! "
direction=0 #value of 0: to the right, 1: to the left.
tlx=10 #Top left x
Line 1,461 ⟶ 1,462:
=={{header|BBC BASIC}}==
{{works with|BBC BASIC for Windows}}
<syntaxhighlight lang="bbcbasic"> VDU 23,22,212;40;16,32,16,128
txt$ = "Hello World! "
direction% = TRUE
Line 1,480 ⟶ 1,481:
{{libheader|GTK}}
(NB: implicitly, through GTK, it uses also Pango library)
<syntaxhighlight lang="c">#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
Line 1,555 ⟶ 1,556:
=={{header|C sharp|C#}}==
 
<syntaxhighlight lang="csharp">using System;
using System.Drawing;
using System.Windows.Forms;
Line 1,615 ⟶ 1,616:
{{libheader|Qt}}
Contents of animationwidget.cpp:
<syntaxhighlight lang="cpp">#include "animationwidget.h"
 
#include <QLabel>
Line 1,644 ⟶ 1,645:
 
Contents of animationwidget.h:
<syntaxhighlight lang="cpp">#ifndef ANIMATIONWIDGET_H
#define ANIMATIONWIDGET_H
 
Line 1,662 ⟶ 1,663:
 
Contents of main.cpp:
<syntaxhighlight lang="cpp">#include "animationwidget.h"
 
#include <QApplication>
Line 1,675 ⟶ 1,676:
=={{header|Ceylon}}==
module.ceylon
<syntaxhighlight lang="ceylon">native("jvm")
module animation "1.0.0" {
import java.desktop "8";
Line 1,681 ⟶ 1,682:
</syntaxhighlight>
run.ceylon
<syntaxhighlight lang="ceylon">import javax.swing {
JFrame,
JLabel,
Line 1,727 ⟶ 1,728:
=={{header|Clojure}}==
Clojure is a JVM language so this example uses Swing, and illustrates Clojure's platform integration.
<syntaxhighlight lang="clojure">(import '[javax.swing JFrame JLabel])
(import '[java.awt.event MouseAdapter])
 
Line 1,763 ⟶ 1,764:
=={{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".
<syntaxhighlight lang="commodorebasicv2">
1 rem rosetta code
2 rem task: animation
Line 1,791 ⟶ 1,792:
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}}
<syntaxhighlight lang="lisp">(use-package :ltk)
(defparameter *message* "Hello World! ")
Line 1,830 ⟶ 1,831:
{{libheader|SDL_ttf}}
{{libheader|tools}}
<syntaxhighlight lang="d">module test26;
 
import qd, SDL_ttf, tools.time;
Line 1,859 ⟶ 1,860:
{{libheader|Flutter}}
view it on dartpad!
<syntaxhighlight lang="javascript">import 'package:flutter/material.dart';
import 'dart:async' show Timer;
 
Line 1,942 ⟶ 1,943:
===HTML DOM===
{{libheader|Html Dom}}
<syntaxhighlight lang="javascript">import 'dart:html';
import 'dart:async';
 
Line 1,977 ⟶ 1,978:
{{libheader| Vcl.StdCtrls}}
{{libheader| Vcl.ExtCtrls}}
<syntaxhighlight lang=Delphi"delphi">
unit Main;
 
Line 2,022 ⟶ 2,023:
end.</syntaxhighlight>
Form resource:
<syntaxhighlight lang=Delphi"delphi">
object Form1: TForm1
ClientHeight = 132
Line 2,043 ⟶ 2,044:
{{works with|E-on-Java}} (Java Swing; tested on Mac OS X 10.5.7)
 
<syntaxhighlight lang="e"># State
var text := "Hello World! "
var leftward := false
Line 2,084 ⟶ 2,085:
Text-only version (no Java dependency; no clicking, use reverse() and stop() to control):
 
<syntaxhighlight lang="e">def [reverse, stop] := {
var text := "Hello World! "
var leftward := false
Line 2,103 ⟶ 2,104:
 
=={{header|Elm}}==
<syntaxhighlight lang="elm">module Main exposing (..)
 
import Browser
Line 2,219 ⟶ 2,220:
=={{header|F Sharp|F#}}==
{{libheader|Windows Presentation Foundation}}
<syntaxhighlight lang="fsharp">open System.Windows
 
let str = "Hello world! "
Line 2,236 ⟶ 2,237:
 
=={{header|Factor}}==
<syntaxhighlight lang=Factor"factor">USING: accessors timers calendar kernel models sequences ui
ui.gadgets ui.gadgets.labels ui.gestures ;
FROM: models => change-model ;
Line 2,269 ⟶ 2,270:
=={{header|Fantom}}==
 
<syntaxhighlight lang="fantom">
using concurrent
using fwt
Line 2,349 ⟶ 2,350:
=={{header|FBSL}}==
 
<syntaxhighlight lang="qbasic">#INCLUDE <Include\Windows.inc>
 
FBSLSETTEXT(ME, "Hello world! ")
Line 2,386 ⟶ 2,387:
To exit, push the window's closing cross. (255 + 107 is the combination that is passed to INKEY$ by that button.)
 
<syntaxhighlight lang="freebasic">DIM C AS STRING = "Hello World! ", SIZE AS USHORT = LEN(C)
DIM DIRECTION AS BYTE = 0
DIM AS INTEGER X, Y, BTNS
Line 2,421 ⟶ 2,422:
 
=={{header|Gambas}}==
<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
Line 2,490 ⟶ 2,491:
 
=={{header|Go}}==
<syntaxhighlight lang="go">package main
 
import (
Line 2,551 ⟶ 2,552:
=={{header|Haskell}}==
Using simple graphics {{libheader|HGL}} from [http://hackage.haskell.org/packages/hackage.html HackageDB]
<syntaxhighlight lang="haskell">import Graphics.HGL.Units (Time, Point, Size, )
import Graphics.HGL.Draw.Monad (Graphic, )
import Graphics.HGL.Draw.Text
Line 2,578 ⟶ 2,579:
loop "Hello world ! " 1 )</syntaxhighlight>
Run within interpreter GHCi:
<syntaxhighlight lang="haskell">*Main> runAnim</syntaxhighlight>
 
=={{header|HicEst}}==
<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")
Line 2,603 ⟶ 2,604:
The following code uses features exclusive to Unicon.
 
<syntaxhighlight lang=Unicon"unicon">import gui
$include "guih.icn"
 
Line 2,650 ⟶ 2,651:
 
The following code uses features exclusive to Icon.
<syntaxhighlight lang=Icon"icon">
link graphics
 
Line 2,676 ⟶ 2,677:
=={{header|J}}==
{{works with|J8}}
<syntaxhighlight lang="j">coinsert'jgl2' [ require'gl2'
MESSAGE =: 'Hello World! '
Line 2,704 ⟶ 2,705:
 
{{works with|J6}}
<syntaxhighlight lang="j">coinsert'jgl2' [ require'gl2'
 
MESSAGE =: 'Hello World! '
Line 2,733 ⟶ 2,734:
=={{header|Java}}==
{{libheader|Swing}}
<syntaxhighlight lang="java">import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
Line 2,796 ⟶ 2,797:
 
=={{header|JavaScript}} + {{header|HTML}}==
<syntaxhighlight lang="javascript"><html> <head>
<title>RC: Basic Animation</title>
<script type="text/javascript">
Line 2,822 ⟶ 2,823:
 
=={{header|JavaScript}} + {{header|SVG}}==
<syntaxhighlight lang="javascript"><svg xmlns="http://www.w3.org/2000/svg"
width="100" height="40">
<script type="text/javascript">
Line 2,848 ⟶ 2,849:
=={{header|Julia}}==
{{libheader|Julia/Tk}}
<syntaxhighlight lang=Julia"julia">
using Tk
 
Line 2,886 ⟶ 2,887:
</syntaxhighlight>
{{libheader|Julia/Gtk}}
<syntaxhighlight lang="julia">
using Gtk.ShortNames
Line 2,926 ⟶ 2,927:
=={{header|Kotlin}}==
{{trans|Java}}
<syntaxhighlight lang="scala">// version 1.1.0
 
import java.awt.Dimension
Line 2,987 ⟶ 2,988:
 
=={{header|Liberty BASIC}}==
<syntaxhighlight lang="lb"> txt$ = "Hello World! "
txtLength = len(txt$)
direction=1
Line 3,024 ⟶ 3,025:
=={{header|Logo}}==
{{works with|UCB Logo}}
<syntaxhighlight lang="logo">to rotate.left :thing
output lput first :thing butfirst :thing
end
Line 3,048 ⟶ 3,049:
=={{header|Lua}}==
{{works with|LÖVE}}
<syntaxhighlight lang=Lua"lua">function love.load()
text = "Hello World! "
length = string.len(text)
Line 3,102 ⟶ 3,103:
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).
 
<syntaxhighlight lang=M2000"m2000 Interpreterinterpreter">
Module UseBlink {
Def boolean direction=True
Line 3,134 ⟶ 3,135:
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
 
<syntaxhighlight lang=M2000"m2000 Interpreterinterpreter">
Module UseEvery {
Window 16, 6000,4000;
Line 3,158 ⟶ 3,159:
When a thread created saves the current layer, to use it in each iteration.
 
<syntaxhighlight lang=M2000"m2000 Interpreterinterpreter">
Module UseThread {
Def boolean direction=True
Line 3,186 ⟶ 3,187:
=={{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:
<syntaxhighlight lang=Maple"maple">
ScrollText(GP("Text",value),"Forward",65);
</syntaxhighlight>
and:
<syntaxhighlight lang=Maple"maple">
ScrollText(GP("Text",value),"Reverse",65);
</syntaxhighlight>
Then in the startup actions, accessed by clicking the 2 gears, add this:
<syntaxhighlight lang=Maple"maple">
macro(SP=DocumentTools:-SetProperty, GP=DocumentTools:-GetProperty);
SP("Text",value,"Hello World! ");
Line 3,216 ⟶ 3,217:
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<syntaxhighlight lang=Mathematica"mathematica">mystring = "Hello World! ";
Scroll[str_, dir_] := StringJoin @@ RotateLeft[str // Characters, dir];
GiveString[dir_] := (mystring = Scroll[mystring, dir]);
Line 3,230 ⟶ 3,231:
Creates a window with a rotating label and 2 buttons to change the direction.
 
<syntaxhighlight lang=MAXScript"maxscript">
try destroydialog animGUI catch ()
 
Line 3,282 ⟶ 3,283:
=={{header|MiniScript}}==
{{works with|Mini Micro}}
<syntaxhighlight lang=MiniScript"miniscript">clear
text.inverse = true
s = "Hello World! "
Line 3,297 ⟶ 3,298:
=={{header|Nim}}==
{{libheader|gintro}}
<syntaxhighlight lang=Nim"nim">import gintro/[glib, gobject, gdk, gtk, gio]
 
type
Line 3,360 ⟶ 3,361:
 
=={{header|Oz}}==
<syntaxhighlight lang="oz">functor
import
Application
Line 3,423 ⟶ 3,424:
=={{header|Pascal}}==
===LCL (Lazarus)===
<syntaxhighlight lang=Pascal"pascal">program HelloWorldAnimatedGUI;
 
uses {$IFDEF UNIX} {$IFDEF UseCThreads}
Line 3,504 ⟶ 3,505:
 
=={{header|Perl}}==
<syntaxhighlight lang="perl">use Tk;
use Time::HiRes qw(sleep);
 
Line 3,535 ⟶ 3,536:
{{libheader|Phix/pGUI}}
Clicking on the label changes the animation direction.
<!--<syntaxhighlight lang=Phix"phix">(phixonline)-->
<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>
Line 3,577 ⟶ 3,578:
===Plain text===
A plain text version. The following script works in an XTerm window.
<syntaxhighlight lang=PicoLisp"picolisp">#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
 
(prin "^[[?9h") # Mouse reporting on
Line 3,597 ⟶ 3,598:
The scrolling text is displayed in a button. Clicking on the button
reverses the scroll direction.
<syntaxhighlight lang=PicoLisp"picolisp">#!/usr/bin/picolisp /usr/lib/picolisp/lib.l
 
(load "@ext.l" "@lib/http.l" "@lib/xhtml.l" "@lib/form.l")
Line 3,618 ⟶ 3,619:
===Java/Swing===
This solution works on ErsatzLisp, the Java version of PicoLisp.
<syntaxhighlight lang=PicoLisp"picolisp">#!ersatz/pil
 
(setq
Line 3,642 ⟶ 3,643:
 
=={{header|Processing}}==
<syntaxhighlight lang="processing">String txt = "Hello, world! ";
boolean dir = true;
 
Line 3,673 ⟶ 3,674:
When the user clicks on the (windowed) text, it should reverse its direction.
 
<syntaxhighlight lang="python">txt = "Hello, world! "
left = True
 
Line 3,698 ⟶ 3,699:
=={{header|Prolog}}==
SWI-Prolog has a grapghic interface XPCE.
<syntaxhighlight lang=Prolog"prolog">:- use_module(library(pce)).
 
animation :-
Line 3,775 ⟶ 3,776:
 
=={{header|PureBasic}}==
<syntaxhighlight lang=PureBasic"purebasic">OpenWindow(0,0,0,500,100,"Hello World!",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
 
text$ = "Hello World! "
Line 3,809 ⟶ 3,810:
===Using PyQt===
{{libheader|PyQt5}}
<syntaxhighlight lang="python">#!/usr/bin/env python3
import sys
 
Line 3,855 ⟶ 3,856:
===Using pygame===
{{libheader|pygame}}
<syntaxhighlight lang="python">import pygame, sys
from pygame.locals import *
pygame.init()
Line 3,911 ⟶ 3,912:
pygame.display.flip()</syntaxhighlight>
===Using Tkinter===
<syntaxhighlight lang="python">import Tkinter as tki
 
def scroll_text(s, how_many):
Line 3,945 ⟶ 3,946:
{{libheader|QB.QLB / QBX.QLB}}
 
<syntaxhighlight lang="qbasic">
'here accordingly to the version, QB or QBX
REM $INCLUDE: 'QBX.BI'
Line 3,994 ⟶ 3,995:
 
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">
rotate_string <- function(x, forwards)
{
Line 4,038 ⟶ 4,039:
=={{header|Racket}}==
 
<syntaxhighlight lang="racket">
#lang racket/gui
 
Line 4,083 ⟶ 4,084:
 
This is a more functional approach - there is no explicit mutation, everything is handled through event callbacks.
<syntaxhighlight lang="racket">
#lang racket
(require racket/match)
Line 4,132 ⟶ 4,133:
{{works with|Rakudo|2019.03}}
 
<syntaxhighlight lang=perl6"raku" line>use GTK::Simple;
use GTK::Simple::App;
 
Line 4,151 ⟶ 4,152:
 
=={{header|REBOL}}==
<syntaxhighlight lang=REBOL"rebol">REBOL [
Title: "Basic Animation"
URL: http://rosettacode.org/wiki/Basic_Animation
Line 4,195 ⟶ 4,196:
]</syntaxhighlight>
=={{header|Red}}==
<syntaxhighlight lang=Red"red">Red ["Animation"]
 
rev: false
Line 4,203 ⟶ 4,204:
=={{header|REXX}}==
This REXX version <u>only</u> works with REXX/Personal or REXX/PC.
<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
if \!pcRexx then do
Line 4,227 ⟶ 4,228:
 
=={{header|Ring}}==
<syntaxhighlight lang="ring">
# Project : Animation
 
Line 4,307 ⟶ 4,308:
{{trans|Tcl}}
{{libheader|Ruby/Tk}}
<syntaxhighlight lang="ruby">require 'tk'
$str = TkVariable.new("Hello World! ")
$dir = :right
Line 4,336 ⟶ 4,337:
 
{{libheader|Shoes}}
<syntaxhighlight lang="ruby">Shoes.app do
@direction = 1
@label = para "Hello World! ", :family => 'monospace'
Line 4,350 ⟶ 4,351:
=={{header|Rust}}==
==={{libheader|GTK}}===
<syntaxhighlight lang="rust">#[cfg(feature = "gtk")]
mod graphical {
extern crate gtk;
Line 4,413 ⟶ 4,414:
=={{header|Scala}}==
{{works with|Scala|2.8}}
<syntaxhighlight lang="scala">import scala.actors.Actor.{actor, loop, reactWithin, exit}
import scala.actors.TIMEOUT
import scala.swing.{SimpleSwingApplication, MainFrame, Label}
Line 4,456 ⟶ 4,457:
 
=={{header|smart BASIC}}==
<syntaxhighlight lang="smart BASICbasic">'Animation, by rbytes and Dutchman
word$="Hello World! "
'use button window with text
Line 4,489 ⟶ 4,490:
=={{header|Standard ML}}==
Works with PolyML interpreter. Add loop for compilation.
<syntaxhighlight lang=Standard"standard MLml">open XWindows ;
open Motif ;
Line 4,540 ⟶ 4,541:
 
=={{header|Suneido}}==
<syntaxhighlight lang=Suneido"suneido">Window(Controller
{
Xmin: 50
Line 4,583 ⟶ 4,584:
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.
 
<syntaxhighlight lang="xml"><svg xmlns="http://www.w3.org/2000/svg" width="100" height="30">
<g id="all">
<rect width="100%" height="100%" fill="yellow"/>
Line 4,605 ⟶ 4,606:
=={{header|Tcl}}==
{{libheader|Tk}}
<syntaxhighlight lang="tcl">package require Tk
set s "Hello World! "
set dir 0
Line 4,689 ⟶ 4,690:
=={{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.
<syntaxhighlight lang="vedit">Buf_Switch(Buf_Free)
Win_Create(Buf_Num, 1, 1, 2, 14)
Ins_Text("Hello World! ")
Line 4,709 ⟶ 4,710:
This example shows code that is hidden by the IDE. (Form creation is done graphically within the IDE, not at runtime.)
 
<syntaxhighlight lang="vb">VERSION 5.00
Begin VB.Form Form1
Begin VB.Timer Timer1
Line 4,743 ⟶ 4,744:
=={{header|Wren}}==
{{libheader|DOME}}
<syntaxhighlight lang="ecmascript">import "graphics" for Canvas, Color
import "dome" for Window
import "input" for Mouse
Line 4,787 ⟶ 4,788:
 
=={{header|XPL0}}==
<syntaxhighlight lang=XPL0"xpl0">include c:\cxpl\codes;
int CpuReg, Dir, I, J;
char Str;
Line 4,812 ⟶ 4,813:
 
=={{header|Yabasic}}==
<syntaxhighlight lang=Yabasic"yabasic">clear screen
open window 400, 150
backcolor 0, 0, 0
Line 4,838 ⟶ 4,839:
{{trans|BBC BASIC}}
Replaces the detection of mouse click by pressing a key (Spectrum does not detect this device by default).
<syntaxhighlight lang="zxbasic">10 LET t$="Hello world! ": LET lt=LEN t$
20 LET direction=1
30 PRINT AT 0,0;t$
Line 4,845 ⟶ 4,846:
60 IF INKEY$<>"" THEN LET direction=NOT direction
70 PAUSE 5: GO TO 30</syntaxhighlight>
 
 
{{omit from|ACL2}}
Line 4,855 ⟶ 4,857:
{{omit from|PHP}}
{{omit from|SQL PL|It does not handle GUI}}
 
[[Category:Animation]]
10,327

edits