The challenge is simple: Draw a rainbow in as few bytes as possible

The specs for the rainbow are as follows:

  • The figure must be exactly 400 pixels wide and 200 pixels high (optionally 401x201 if you want a single center pixel)
  • The red ring should touch all borders of the figure (outer radius = 200 pixels)
  • All rings shall have the same width (10 pixels)
    • The violet ring shall have an inner radius of 130 pixels
  • The bow should be the upper half of a perfect circle
  • The background shall be white (transparent is also accepted)
  • The figure shall not have borders, (exception is made if the border can't be suppressed)
  • Builtin rainbow making functions are not allowed!

The following colors are to be used in the rainbow:


This is code golf, so the shortest code in bytes win!



Related, but different!

  • 26
    \$\begingroup\$ Builtin rainbow making functions are not allowed As I'm sure Mathematica has one \$\endgroup\$
    – Luis Mendo
    Mar 11, 2016 at 23:05
  • \$\begingroup\$ How imperfect may the rainbow be? From not anti-aliased to tearing? Consider the images in this answer \$\endgroup\$
    – aross
    Mar 15, 2016 at 15:53
  • \$\begingroup\$ @aross: it should look like the sample rainbow (some pixels may vary due to inaccurate calculations). The two last rainbows are too "messy", while the first one looks ok. I don't have a perfect rule, so use you best judgement :-) \$\endgroup\$ Mar 15, 2016 at 16:12
  • \$\begingroup\$ @StewieGriffin Reason I'm asking is because apparently PHP graphics is pretty buggy, while the solution is correct in theory. Well, the second one is, the third one would be with anti-aliasing (which also doesn't work well) \$\endgroup\$
    – aross
    Mar 15, 2016 at 16:16
  • \$\begingroup\$ Are vector graphics not allowed? edit: never mind—I see that there's already a TikZ answer, so I gather they are. \$\endgroup\$ Apr 23, 2017 at 16:52

31 Answers 31


LibreLogo, 129 bytes


x=307 ps 7 fc [3]for i in [[5],0xff7f00,[11],65280,255,4915330,9371903][ x-=14 pc i circle x ]ps 0 pc [3]rt 180 fd 152 square 300


enter image description here


x = 307                                                          ; Circle Width = 307 pt
ps 7                                                             ; Pen Size = 7 pt
fc [3]                                                           ; Fill Color = #ffffff
for i in [[5], 0xff7f00, [11], 65280, 255, 4915330, 9371903] [   ; For each Rainbow Color
    x -= 14                                                      ; Circle Width -= 14 pt
    pc i                                                         ; Pen Color = Rainbow Color
    circle x                                                     ; Draw Circle (Circle Width)
ps 0                                                             ; Pen Size = 0
pc [3]                                                           ; Pen Color = #ffffff
rt 180                                                           ; Right 180°
fd 152                                                           ; Forward 152 pt
square 300                                                       ; Draw Square (300 pt)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.