Animation: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(6 intermediate revisions by 5 users not shown)
Line 1,432:
return</syntaxhighlight>
 
=={{header|BASIC256BASIC}}==
==={{header|BASIC256}}===
<syntaxhighlight lang="basic256">str$="Hello, World! "
direction=0 #value of 0: to the right, 1: to the left.
Line 1,460 ⟶ 1,461:
goto main</syntaxhighlight>
 
==={{header|BBC BASIC}}===
{{works with|BBC BASIC for Windows}}
<syntaxhighlight lang="bbcbasic"> VDU 23,22,212;40;16,32,16,128
Line 2,102 ⟶ 2,103:
[def _() { leftward := !leftward; null }, anim.stop]
}</syntaxhighlight>
 
=={{header|EasyLang}}==
<syntaxhighlight lang=easylang>
s$ = "Hello world! "
textsize 16
lg = len s$
on timer
color 333
move 10 20
rect 80 20
color 999
move 12 24
text s$
if forw = 0
s$ = substr s$ lg 1 & substr s$ 1 (lg - 1)
else
s$ = substr s$ 2 (lg - 1) & substr s$ 1 1
.
timer 0.2
.
on mouse_down
if mouse_x > 10 and mouse_x < 90
if mouse_y > 20 and mouse_y < 40
forw = 1 - forw
.
.
.
timer 0
</syntaxhighlight>
 
 
=={{header|Elm}}==
Line 2,216 ⟶ 2,247:
[ text <| rotate message model.time ]
]
</syntaxhighlight>
 
=={{header|Emacs Lisp}}==
<syntaxhighlight lang="lisp">
(defun animation-start ()
(interactive)
(make-thread
(lambda ()
(let ()
(setq **animation-state** (make-hash-table))
(puthash 'offset 0 **animation-state**)
(puthash 'sleep-cnt 5 **animation-state**)
(puthash 'len 20 **animation-state**)
(puthash 'buffer (make-string (gethash 'len **animation-state**) ? )
**animation-state**)
(puthash 'text "Hello World!" **animation-state**)
(puthash 'forward 't **animation-state**)
(switch-to-buffer-other-window "**animation**")
(erase-buffer)
(insert "\n")
(insert-button
"Revert Direction"
'action (lambda (x)
(let ((forward (gethash 'forward **animation-state**)))
(puthash 'forward (not forward) **animation-state**)))
'follow-link 't)
(while 't
(let ((offset (gethash 'offset **animation-state**))
(len (gethash 'len **animation-state**))
(txt (gethash 'text **animation-state**))
(buff (gethash 'buffer **animation-state**))
(is-forward (gethash 'forward **animation-state**)))
(fillarray buff ? )
(seq-map-indexed (lambda (ch idx)
(aset buff (% (+ offset idx) len) ch))
txt)
(puthash 'buffer buff **animation-state**)
(if is-forward
(puthash 'offset (1+ offset) **animation-state**)
(puthash 'offset (% (+ len (1- offset)) len) **animation-state**))
;;(erase-buffer)
(beginning-of-buffer)
(delete-region (line-beginning-position) (line-end-position))
(insert buff)
;;(message buff)
)
(sleep-for 0 500)
)
)
)
"animation thread")
)
 
(animation-start)
</syntaxhighlight>
 
Line 2,420 ⟶ 2,509:
SLEEP 100, 1
LOOP</syntaxhighlight>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
include "NSLog.incl"
 
_window = 1
_label = 1
 
void local fn DoIt
window _window, @"Animation", (0,0,480,270)
subclass textlabel _label, @"Hello World! ", (140,112,210,45)
ControlSetFont( _label, fn FontLabelFontOfSize( 36 ) )
ViewSetProperty( _label, @"MoveRight", @(YES) )
timerbegin , 0.1, YES
CFStringRef string = fn ControlStringValue(_label)
CFStringRef chr
BOOL moveRight = fn NumberBoolValue(fn ViewProperty( _label, @"MoveRight" ))
if ( moveRight )
chr = right( string, 1 )
string = fn StringWithFormat( @"%@%@",chr,left(string,len(string)-1) )
else
chr = left( string, 1 )
string = fn StringWithFormat( @"%@%@",right(string,len(string)-1),chr )
end if
textlabel _label, string
timerend
end fn
 
void local fn DoDialog( ev as long, tag as long )
select ( ev )
case _viewMouseDown
select ( tag )
case _label
BOOL moveRight = fn NumberBoolValue(fn ViewProperty( _label, @"MoveRight" ))
if ( moveRight ) then moveRight == NO else moveRight = YES
ViewSetProperty( _label, @"MoveRight", @(moveRight) )
end select
end select
end fn
 
fn DoIt
 
on dialog fn DoDialog
 
HandleEvents
</syntaxhighlight>
 
=={{header|Gambas}}==
Line 3,284 ⟶ 3,421:
{{works with|Mini Micro}}
<syntaxhighlight lang="miniscript">clear
text.inverse = true
s = "Hello World! "
toggle = true
while not key.available
while true
text.row = 12
text.column = 15
print " " + s + " "
wait 0.1
if key.available then
s = s[-1] + s[:-1]
toggle = not toggle
key.clear
yield
end if
if toggle then
s = s[-1] + s[:-1]
else
s = s[1:] + s[0]
end if
end while</syntaxhighlight>
 
Alternate version that scrolls pixel by pixel rather than character by character.
<syntaxhighlight lang="miniscript">clear
txt = "Hello World! "
width = txt.len * 20 + 4
gfx.print txt,0,608,color.white, "large"
toggle = false
 
while true
img1 = gfx.getImage(toggle, 608, width - 1, 32)
img2 = gfx.getImage((not toggle) * (width - 1), 608, 1, 32)
gfx.drawImage img1, (not toggle), 608
gfx.drawImage img2, toggle * (width - 1), 608
if key.available then
toggle = not toggle
key.clear
end if
yield
end while
</syntaxhighlight>
text.inverse = false
key.clear</syntaxhighlight>
 
=={{header|Nim}}==
Line 4,744 ⟶ 4,908:
=={{header|Wren}}==
{{libheader|DOME}}
<syntaxhighlight lang="ecmascriptwren">import "graphics" for Canvas, Color
import "dome" for Window
import "input" for Mouse
9,482

edits