Colour bars/Display: Difference between revisions

m
Added the Sidef language
(Added Befunge example)
m (Added the Sidef language)
Line 894:
contents=new ColorBars()
}</lang>
 
=={{header|Sidef}}==
{{trans|Perl}}
<lang ruby>require 'GD';
 
var colors = Hash.new(
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 = %s'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);</lang>
 
=={{header|Tcl}}==
2,747

edits