Jump to content

Animation: Difference between revisions

Add Processing
(→‎{{header|Perl 6}}: Add a Perl 6 example)
(Add Processing)
Line 1,890:
(wait 200)
(java Label 'setText (pack (do Dir (rot Text)))) )</lang>
 
 
=={{header|Processing}}==
<lang processing>String txt = "Hello, world! ";
boolean dir = true;
 
void draw(){
background(128);
text(txt, 10, height/2);
if(frameCount%10==0){
if(dir) {
txt = rotate(txt, 1);
} else {
txt = rotate(txt, txt.length()-1);
}
}
}
 
void mouseReleased(){
dir = !dir;
}
 
String rotate(String text, int startIdx) {
char[] rotated = new char[text.length()];
for (int i = 0; i < text.length(); i++) {
rotated[i] = text.charAt((i + startIdx) % text.length());
}
return String.valueOf(rotated);
}</lang>
 
 
=={{header|Prolog}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.