Colour bars/Display: Difference between revisions

m
size of picture adjusted
m (size of picture adjusted)
 
(16 intermediate revisions by 7 users not shown)
Line 477:
 
End</syntaxhighlight>
 
==={{header|IS-BASIC}}===
<syntaxhighlight lang="is-basic">100 GRAPHICS LORES 16
110 SET PALETTE BLACK,RED,GREEN,BLUE,MAGENTA,CYAN,YELLOW,WHITE
120 FOR I=1 TO 7
130 CALL BAR(I)
140 NEXT
150 DEF BAR(C)
160 SET INK C
170 PLOT C*160,0;C*160,719;C*160+152,719;C*160+152,0;C*160,0
180 PLOT C*160+16,16,PAINT
190 END DEF</syntaxhighlight>
 
==={{header|Liberty BASIC}}===
Line 931 ⟶ 943:
=={{header|EasyLang}}==
 
[https://easylang.dev/show/#cod=TYyxCoAwDET3fsWNKqjpmMEvKZ1KhUK1UER/34uTQ7i7l0tSqyFiQ4CIQDmiHFF6pacyKzW6hz3PxoqaTyS7dHvrKMZxtR8GzHBnsXz5aHfGgwlDwQw/Qoz2nC5SvnWLewE= Run it]
[https://easylang.online/apps/_color_bars.html Run it]
 
<syntaxhighlight lang="text">
col[] = [ 000 900 090 009 909 099 990 999 ]
w = 100.0 / len col[]
for i = 1 to len col[]
color col[i]
move w * (i - 1) 0
rect w 100
.
</syntaxhighlight>
Line 1,101 ⟶ 1,113:
where attrs = map color2attr colors
nBars = length colors
colors = [black, brightRed, brightGreen, brightBlue, brightMagenta, brightCyan, brightYellow, brightWhite]
color2attr c = Attr Default Default (SetTo c)
 
main :: IO ()
main = do
cfg <- standardIOConfig
Line 1,119 ⟶ 1,132:
showBars bounds
shutdown vty</syntaxhighlight>
 
[[File:Haskell_Colourbars_A_0.png|700px]]
 
Graphical version using SFML.
Line 1,486 ⟶ 1,501:
 
=={{header|Perl}}==
<syntaxhighlight lang="perl">#!/usr/bin/perluse -wstrict;
use strict warnings;
use GD ;
 
my %colors = ( white => [ 255 , 255 , 255 ] , red => [255 , 0 , 0 ] ,
white => [255,255,255], red green => [255, 0 0, 255 0], green => [ 0,255, ] 0], blue => [ 0 0, 0 , 255 ] ,
magenta => [255, 0,255], magentayellow => [ 255 ,255, 0 0], 255cyan ] => [ 0,255,255], yellowblack => [ 255 0, 255 0, 0 ] ,);
 
cyan => [ 0 , 255 , 255 ] , black => [ 0 , 0 , 0 ] ) ;
my $barwidthstart = 160 / 8= 0;
my $imagebarwidth = new GD::Image( 160 , 100 )/ 8;
my $startimage = 0GD::Image->new( 160 , 100 );
 
foreachfor my $rgb ( values %colors ) {
my $paintcolor = $image->colorAllocate( @$rgb ) ;
$image->filledRectangle( $start * $barwidth , 0 , $start * $barwidth +
$barwidth - 1 , 99 , $paintcolorimage->colorAllocate( @$rgb ) );
$start++ ;
}
open ( DISPLAY , ">" , "testprogrambars.png" ) ||or die ;
binmode DISPLAY ;
print DISPLAY $image->png ;
close DISPLAY ;#to be watched with <image viewer> testprogram.png</syntaxhighlight>
 
=={{header|Phix}}==
Line 2,040 ⟶ 2,055:
tput sgr0 # reset</syntaxhighlight>
 
=={{header|Uxntal}}==
<syntaxhighlight lang="uxntal">( uxnasm color-bars.tal color-bars.rom && uxnemu color-bars.rom )
 
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
 
|0100
( set 4 color theme
rgb
color0: 000 - black
color1: f00 - red
color2: 0f0 - green
color3: 00f - blue )
#0f00 .System/r DEO2
#00f0 .System/g DEO2
#000f .System/b DEO2
 
( store bars width )
.Screen/width DEI2 #0004 DIV2 ,&quarter STR2
( set starting position )
#0000 .Screen/y DEO2
 
( draw bars )
#00
&loop
#00 OVR [ LIT2 &quarter $2 ] MUL2
.Screen/x DEO2
DUP #80 ORA .Screen/pixel DEO
INC DUP #04 NEQ ?&loop
BRK</syntaxhighlight>
[[File:Color-bars.png|alt=Color bars task implemented in Uxntal.|thumb|Color bars task implemented in Uxntal.|none]]
=={{header|Wren}}==
{{trans|Go}}
{{libheader|DOME}}
<syntaxhighlight lang="ecmascriptwren">import "graphics" for Canvas, Color
import "dome" for Window
 
5

edits