> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/c/colour-bars/display.md).

# Display

```ruby
require('GD')
 
var colors = Hash(
              white   => [255, 255, 255],
              red     => [255, 0,   0],
              green   => [0,   255, 0],
              blue    => [0,   0,   255],
              magenta => [255, 0,   255],
              yellow  => [255, 255, 0],
              cyan    => [0,   255, 255],
              black   => [0,   0,   0],
             )
 
var barwidth = 160/8
var image    = %O<GD::Image>.new(160, 100)
var start    = 0
 
colors.values.each { |rgb|
    var paintcolor = image.colorAllocate(rgb...)
    image.filledRectangle(start * barwidth, 0, start*barwidth + barwidth - 1, 99, paintcolor)
    start++
}

%f'colorbars.png'.open('>:raw').print(image.png)
```
