Vibrating rectangles: Difference between revisions
m
syntax highlighting fixup automation
(Added Processing implementation) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 10:
=={{header|Action!}}==
<
BYTE i,x1,y1,x2,y2
Line 45:
OD
CH=$FF
RETURN</
{{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]
<
OnExit, Exit
return
Line 118:
ExitApp
Return
;----------------------------------------------------------------</
=={{header|BASIC}}==
==={{header|BASIC256}}===
<
graphsize ancho, alto
Line 134:
pause 0.05
next sz
end while</
==={{header|FreeBASIC}}===
<
Screenres ancho, alto, 16
Windowtitle "Rosetta Code Vibrating rectangles"
Line 148:
Sleep 40
Next sz
Loop Until Inkey = Chr(27) 'ESC</
==={{header|True BASIC}}===
<
DO
Line 160:
NEXT i
LOOP
END</
=={{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">
/*Abhishek Ghosh, 15th September 2018*/
Line 197:
return 0;
}
</syntaxhighlight>
=={{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</
=={{header|Factor}}==
<
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 ;</
=={{header|Go}}==
Line 277:
$ eog vibrating2.gif
</pre>
<
import (
Line 360:
log.Fatal(err2)
}
}</
=={{header|J}}==
Line 459:
</html>
</pre>
<
const SIZE = 400, WAIT = .025;
class VibRects {
Line 518:
vibRects.start();
}
</syntaxhighlight>
=={{header|Julia}}==
<
const height, width, x0, y0 = 480, 640, 320, 240
Line 547:
sleep(0.25)
end
</syntaxhighlight>
=={{header|Nim}}==
{{libheader|gintro}}
Should work on any platform where Gtk is available. Tested on Linux.
<
import gintro/[gobject, gdk, gtk, gio, cairo]
Line 626:
let app = newApplication(Application, "Rosetta.vibrating_rectangles")
discard app.connect("activate", activate)
discard app.run()</
=={{header|Objeck}}==
Uses SLD2 libraries and 80's neon colors.
<
use Game.Framework;
Line 745:
REC_REFRESH := 15
}
</syntaxhighlight>
=={{header|Perl}}==
Line 751:
{{trans|Raku}}
<
binmode STDOUT, ":utf8";
use Time::HiRes qw(sleep);
Line 794:
print "\n";
}
}</
=={{header|Phix}}==
Line 800:
{{libheader|Phix/online}}
You can run this online [http://phix.x10.mx/p2js/vibrect.htm here].
<!--<
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\vibrect.exw
Line 874:
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</
=={{header|Processing}}==
<
//Aamrun, 3rd July 2022
Line 899:
delay(100);
}
</syntaxhighlight>
=={{header|Python}}==
<
from itertools import cycle
from time import sleep
Line 933:
rects(tl, colour)
sleep(0.5)
</syntaxhighlight>
{{out}}
Line 942:
Via big-bang.
<
(require 2htdp/image
Line 975:
(list-ref colors (mod (add1 m)))
(list-ref colors m))))
(list (empty-scene SIZE SIZE 'black))))])])</
=={{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"
my %r = :tl<┌>, :h<─>, :tr<┐>, :v<│>, :bl<└>, :br<┘>;
Line 1,032:
print "\n";
}
}</
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"
my $width = 1200;
Line 1,118:
}
( $r, $g, $b ).map: ((*+$m) * 255).Int
}</
=={{header|Ring}}==
<
# Project : Vibrating rectangles
Line 1,192:
win1.show()
return
</syntaxhighlight>
Output:
Line 1,199:
=={{header|Wren}}==
{{libheader|DOME}}
<
import "dome" for Window
Line 1,243:
}
var Game = VibratingRectangles.new(500, 500)</
=={{header|X86 Assembly}}==
<
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>
=={{header|XPL0}}==
Translation of EasyLang.
<
proc OnTimer;
Line 1,325:
OnTimer;
until KeyHit;
]</
=={{header|Yabasic}}==
<
open window Width, Height
Line 1,341:
wait 0.01
next
loop</
|