10-07-2026, 12:51 AM
Hi everyone, a bit late to this one but I enjoyed the challenge, so here is my take on a rainbow.
Instead of outlines, it fills seven concentric circles from the outside in (red first, violet last), then covers the centre with the sky colour and the bottom half with a hill, so only the arcs remain. Changing the variable "band" changes the thickness of each colour.
A nice variation: put the loop in a Sub and call it with a smaller radius and lighter colours (e.g. using GraphicsWindow.GetColorFromRGB) to add a faint second rainbow above the first, with the colour order reversed as in a real double rainbow.
Instead of outlines, it fills seven concentric circles from the outside in (red first, violet last), then covers the centre with the sky colour and the bottom half with a hill, so only the arcs remain. Changing the variable "band" changes the thickness of each colour.
Code:
' Challenge 14 - Rainbow
GraphicsWindow.Title = "Rainbow"
GraphicsWindow.Width = 640
GraphicsWindow.Height = 380
sky = "LightSkyBlue"
GraphicsWindow.BackgroundColor = sky
GraphicsWindow.PenWidth = 0
colors = "1=Red;2=Orange;3=Yellow;4=Green;5=Blue;6=Indigo;7=Violet;"
cx = 320
cy = 330
r = 280
band = 20
For i = 1 To Array.GetItemCount(colors)
GraphicsWindow.BrushColor = colors[i]
GraphicsWindow.FillEllipse(cx - r, cy - r, 2 * r, 2 * r)
r = r - band
EndFor
' hollow out the centre
GraphicsWindow.BrushColor = sky
GraphicsWindow.FillEllipse(cx - r, cy - r, 2 * r, 2 * r)
' ground
GraphicsWindow.BrushColor = "ForestGreen"
GraphicsWindow.FillRectangle(0, cy, GraphicsWindow.Width, GraphicsWindow.Height - cy)A nice variation: put the loop in a Sub and call it with a smaller radius and lighter colours (e.g. using GraphicsWindow.GetColorFromRGB) to add a faint second rainbow above the first, with the colour order reversed as in a real double rainbow.
Consultor de TI em Portugal (PME). Guia de licenciamento: Office 2024 Professional Plus


![[-]](https://litdev.uk/mybb/images/collapse.png)