Vibrating rectangles: Difference between revisions

m
syntax highlighting fixup automation
(Added Processing implementation)
m (syntax highlighting fixup automation)
Line 10:
 
=={{header|Action!}}==
<langsyntaxhighlight Actionlang="action!">PROC DrawRectangles()
BYTE i,x1,y1,x2,y2
Line 45:
OD
CH=$FF
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Vibrating_rectangles.png Screenshot from Atari 8-bit computer]
Line 51:
=={{header|AutoHotkey}}==
Requires [https://www.autohotkey.com/boards/viewtopic.php?t=6517 Gdip Library]
<langsyntaxhighlight AutoHotkeylang="autohotkey">Vibrating_rectangles()
OnExit, Exit
return
Line 118:
ExitApp
Return
;----------------------------------------------------------------</langsyntaxhighlight>
 
 
=={{header|BASIC}}==
==={{header|BASIC256}}===
<langsyntaxhighlight lang="freebasic">ancho = 200 : alto = ancho
 
graphsize ancho, alto
Line 134:
pause 0.05
next sz
end while</langsyntaxhighlight>
 
==={{header|FreeBASIC}}===
<langsyntaxhighlight lang="freebasic">Const ancho = 400, alto = ancho
Screenres ancho, alto, 16
Windowtitle "Rosetta Code Vibrating rectangles"
Line 148:
Sleep 40
Next sz
Loop Until Inkey = Chr(27) 'ESC</langsyntaxhighlight>
 
==={{header|True BASIC}}===
<langsyntaxhighlight QBasiclang="qbasic">SET WINDOW -90, 90, -90, 90
 
DO
Line 160:
NEXT i
LOOP
END</langsyntaxhighlight>
 
 
=={{header|C}}==
Dimensions of the rectangles, their number and the animation delay can be configured. Requires the [http://www.cs.colorado.edu/~main/bgi/cs1300/ WinBGIm] library.
<syntaxhighlight lang="c">
<lang C>
/*Abhishek Ghosh, 15th September 2018*/
 
Line 197:
return 0;
}
</syntaxhighlight>
</lang>
 
=={{header|EasyLang}}==
Line 203:
[https://easylang.online/apps/_vibrating-rectangles.html Run it]
 
<syntaxhighlight lang="text">on timer
sz -= 2
if sz < 0
Line 216:
timer 0.2
.
timer 0.2</langsyntaxhighlight>
 
=={{header|Factor}}==
<langsyntaxhighlight lang="factor">USING: accessors calendar colors.constants combinators kernel
locals math math.vectors opengl timers ui ui.gadgets
ui.gadgets.worlds ui.pens.solid ui.render ;
Line 265:
{ window-controls
{ normal-title-bar close-button minimize-button } }
} <vibrating-gadget> >>gadgets ;</langsyntaxhighlight>
 
=={{header|Go}}==
Line 277:
$ eog vibrating2.gif
</pre>
<langsyntaxhighlight lang="go">package main
 
import (
Line 360:
log.Fatal(err2)
}
}</langsyntaxhighlight>
 
=={{header|J}}==
Line 459:
</html>
</pre>
<langsyntaxhighlight lang="javascript">
const SIZE = 400, WAIT = .025;
class VibRects {
Line 518:
vibRects.start();
}
</syntaxhighlight>
</lang>
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">using Gtk, Graphics, Colors
const height, width, x0, y0 = 480, 640, 320, 240
Line 547:
sleep(0.25)
end
</syntaxhighlight>
</lang>
 
=={{header|Nim}}==
{{libheader|gintro}}
Should work on any platform where Gtk is available. Tested on Linux.
<langsyntaxhighlight Nimlang="nim">import sugar
 
import gintro/[gobject, gdk, gtk, gio, cairo]
Line 626:
let app = newApplication(Application, "Rosetta.vibrating_rectangles")
discard app.connect("activate", activate)
discard app.run()</langsyntaxhighlight>
 
=={{header|Objeck}}==
Uses SLD2 libraries and 80's neon colors.
<langsyntaxhighlight lang="objeck">use Game.SDL2;
use Game.Framework;
 
Line 745:
REC_REFRESH := 15
}
</syntaxhighlight>
</lang>
 
=={{header|Perl}}==
Line 751:
{{trans|Raku}}
 
<langsyntaxhighlight lang="perl">use utf8;
binmode STDOUT, ":utf8";
use Time::HiRes qw(sleep);
Line 794:
print "\n";
}
}</langsyntaxhighlight>
 
=={{header|Phix}}==
Line 800:
{{libheader|Phix/online}}
You can run this online [http://phix.x10.mx/p2js/vibrect.htm here].
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\vibrect.exw
Line 874:
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</langsyntaxhighlight>-->
 
=={{header|Processing}}==
<langsyntaxhighlight lang="java">
//Aamrun, 3rd July 2022
 
Line 899:
delay(100);
}
</syntaxhighlight>
</lang>
 
=={{header|Python}}==
<langsyntaxhighlight lang="python">import turtle
from itertools import cycle
from time import sleep
Line 933:
rects(tl, colour)
sleep(0.5)
</syntaxhighlight>
</lang>
 
{{out}}
Line 942:
Via big-bang.
 
<langsyntaxhighlight lang="racket">#lang racket
 
(require 2htdp/image
Line 975:
(list-ref colors (mod (add1 m)))
(list-ref colors m))))
(list (empty-scene SIZE SIZE 'black))))])])</langsyntaxhighlight>
 
=={{header|Raku}}==
Line 988:
Draws a series of concentric rectangles then rotates through the color palette. Every three seconds, chooses new random palette colors and reverses rotation direction.
 
<syntaxhighlight lang="raku" perl6line># box drawing characters
my %r = :tl<┌>, :h<─>, :tr<┐>, :v<│>, :bl<└>, :br<┘>;
 
Line 1,032:
print "\n";
}
}</langsyntaxhighlight>
See: [https://github.com/thundergnat/rc/blob/master/img/vibrating-rectangles-perl6.gif Vibrating rectangles] (.gif image)
 
Line 1,038:
Fully animated SDL2 graphics lib version. Will adjust rendered rectangles to fill resized windows. Hit the space bar to toggle palette rotation direction.
 
<syntaxhighlight lang="raku" perl6line>use SDL2::Raw;
 
my $width = 1200;
Line 1,118:
}
( $r, $g, $b ).map: ((*+$m) * 255).Int
}</langsyntaxhighlight>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
# Project : Vibrating rectangles
 
Line 1,192:
win1.show()
return
</syntaxhighlight>
</lang>
Output:
 
Line 1,199:
=={{header|Wren}}==
{{libheader|DOME}}
<langsyntaxhighlight lang="ecmascript">import "graphics" for Canvas, Color
import "dome" for Window
 
Line 1,243:
}
 
var Game = VibratingRectangles.new(500, 500)</langsyntaxhighlight>
 
=={{header|X86 Assembly}}==
<langsyntaxhighlight lang="asm"> 1 ;Tanslation of XPL0 and EasyLang. A 75-byte program.
2 ;Assemble with: tasm, tlink /t
3 0000 .model tiny
Line 1,301:
54 0143 FEBF FFFE 013F 0000 dir dw -320-1, -1-1, 320-1, 1-1 ;directions: up, right, down, left
55 end start
</syntaxhighlight>
</lang>
 
=={{header|XPL0}}==
Translation of EasyLang.
<langsyntaxhighlight XPL0lang="xpl0">int Sz, Color;
 
proc OnTimer;
Line 1,325:
OnTimer;
until KeyHit;
]</langsyntaxhighlight>
 
 
=={{header|Yabasic}}==
<langsyntaxhighlight Yabasiclang="yabasic">Width = 300 : Height = 300
 
open window Width, Height
Line 1,341:
wait 0.01
next
loop</langsyntaxhighlight>
10,333

edits