Powershell: 270b (arbitrary width/height) / 307b (screen dimensions)
For a rainbow spanning most of the screen, the following leaks like a sieve, but seems to work (for 307 bytes):
$d=@{};Add-Type -A System.Drawing -Pas|foreach{$d[$_.Name]=$_};$g=$d.Graphics::FromHwnd(0);$v=$g.VisibleClipBounds;$y=$h=$v.Height;$h/=9;$c=0;@(65281,11861886,16776961,16744448,256,23296,65536)|foreach{$g.DrawArc((New-Object $d["Pen"]($d.Color::FromArgb(-$_),$h)),-$h,$y-$h*$c++-$h,$v.Width+2*$h,$h,0,-180)}
Ungolfed
$d=@{};
Add-Type -A System.Drawing -Pas | foreach { $d[$_.Name]=$_ }; # import .NET naespace "System.Drawing" and copy its members into the $d array
$g = $d.Graphics::FromHwnd(0); # build a Graphics object for the screen
$v = $g.VisibleClipBounds; # determine the screen size
$y = $h = $v.Height; # init start point for arcs and band height
$h /= 9; # allow space for 7 bands + clear above and below
$c=0 # counter
@(65281,11861886,16776961,16744448,256,23296,65536) | foreach { # ARGB color values for bands (no clever calculation here, just Color.Red.ToARGB(), Color.Orange.ToARGB(), etc...)
$g.DrawArc(
(New-Object $d["Pen"](
$d.Color::FromArgb(-$_), # build a pen from the current color, using width = band-height
$h
)),
-$h, # x-pos for start of arc (pushed slightly offscreen to avoid weird wide-pen effect)
$y-$h*$c++-$h, # y-pos for start of arc (moves up each time because of counter increment)
$v.Width+2*$h, # width of arc (pushed offscreen to avoid weird wide-pen effect)
$h, # height of arc always the same
0,-180 # arc sweep clockwise between 0 and 180 degrees from x-axis)
)
}
Of course, if you don't factor the screen size or the wide-pen effect, and just go with any arbitary width/height, you can lose the VisibleClipBounds
stuff for approx 270 bytes, but your "animation" speed will be affected by the number of pixels it has to draw:
$d=@{};Add-Type -A System.Drawing -Pas|foreach{$d[$_.Name]=$_};$g=$d.Graphics::FromHwnd(0);$y=$h=300;$h/=9;$c=0;@(65281,11861886,16776961,16744448,256,23296,65536)|foreach{$g.DrawArc((New-Object $d["Pen"]($d.Color::FromArgb(-$_),$h)),0,$y-$h*$c++-$h,400+2*$h,$h,0,-180)}
Results
Window-redraw makes it particularly difficult to get a screencap of the full-screen one in action, but the arbitrary-sized one (with the wide-pen awkwardness) looks like:
Edit: OK, I've managed to get a fullscreen cap, but not before some of my screen redrew:
3[tag:code-golf] and [tag:popularity-contest] are mutually exclusive. Seeing as you want "least bytes win", remove the [tag:popularity-contest] – mniip – 2014-02-08T13:33:01.777
@mniip done editing! – None – 2014-02-08T13:41:45.357
I’ve edited the question a bit in an attempt to improve it. Please anyone let me know if there’s anything else I can do to keep it from being downvoted or closed. – Timwi – 2014-02-08T20:47:23.783
@Timwi I removed my downvote for the time being, good job fixing it up. I think it's still not very specific about what makes an okay rainbow though, which seems bad for a code-golf task (I think I would've preferred popularity-contest, but it's a tad late for that I guess). – FireFly – 2014-02-08T21:11:06.003