Colour bars/Display: Difference between revisions

m
size of picture adjusted
m (syntax highlighting fixup automation)
m (size of picture adjusted)
 
(27 intermediate revisions by 10 users not shown)
Line 316:
 
=={{header|BASIC}}==
 
==={{header|AmigaBASIC}}===
 
<syntaxhighlight lang="amigabasic">SCREEN 1,320,200,5,1
WINDOW 2,"Color bars",(0,10)-(297,186),15,1
Line 357 ⟶ 355:
</syntaxhighlight>
 
==={{header|CommodoreChipmunk BASICBasic}}===
The sequence of colors.
<syntaxhighlight lang="basic">
100 rem Colour bars/Display
110 graphics 0 : graphics cls
120 for i = 0 to 7
130 read r,g,b
140 graphics color r,g,b
150 for j = 0 to 79
160 x = i*80+j
170 graphics moveto x,0
180 graphics lineto x,399
190 next j
200 next i
500 data 0,0,0 : rem black
510 data 100,0,0 : rem red
520 data 0,100,0 : rem green
530 data 0,0,100 : rem blue
540 data 100,0,100 : rem magenta
550 data 0,100,100 : rem cyan
560 data 100,100,0 : rem yellow
570 data 100,100,100 : rem white
</syntaxhighlight>
 
==={{header|Commodore BASIC}}===
This task achieved only on Commodore computers with color capabilities. The example below tested as-is in VICE on the following machines:
* Commodore 64
Line 365 ⟶ 386:
* Commodore CBM-II (with VIC-II video)
* Commodore SX-64
 
 
It will also work well on the VIC-20 if you either omit line 310 or comment (REM) it out as the VIC-20 has only an eight-color palette.
Line 392 ⟶ 412:
310 data 129,149,150,151,152,153,154,155
320 data 0:rem data terminato</syntaxhighlight>
 
==={{header|FreeBASIC}}===
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
' Draw the color bars on an 80 x 25 console using the system palette of 16 colors
' i.e. 5 columns per color
Width 80, 25
Shell "cls"
Locate ,, 0 '' turn cursor off
For clr As UInteger = 0 To 15
Color 0, clr
For row As Integer = 1 to 25
Locate row, clr * 5 + 1
Print Space(5);
Next row
Next clr
 
Sleep
' restore default settings
Locate ,, 1 '' turn cursor on
Color 7, 0 '' white text on black background</syntaxhighlight>
 
==={{header|FutureBasic}}===
[[File:ColorBarsDisplayFB300.png|right]]
<syntaxhighlight lang="futurebasic">
void local fn DoIt
long index, x = 0
CFArrayRef colors = @[fn ColorBlack,fn ColorRed,
fn ColorGreen,fn ColorBlue,fn ColorMagenta,
fn ColorCyan,fn ColorYellow,fn ColorWhite]
window 1, @"Color bars/Display", (0,0,480,270), NSWindowStyleMaskTitled
pen -1
for index = 0 to len(colors) - 1
rect fill (x,0,60,270), colors[index]
x += 60
next
end fn
 
fn DoIt
 
HandleEvents
</syntaxhighlight>
 
==={{header|Gambas}}===
<syntaxhighlight lang="gambas">Public Sub Form_Open()
Dim iColour As Integer[] = [Color.Black, Color.red, Color.Green, Color.Magenta, Color.Cyan, Color.Yellow, Color.white]
Dim hPanel As Panel
Dim siCount As Short
 
With Me
.Arrangement = Arrange.Horizontal
.Height = 300
.Width = 400
End With
 
For siCount = 0 To 6
hpanel = New Panel(Me)
hpanel.Expand = True
hpanel.H = 500
HPanel.Background = iColour[siCount]
Next
 
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 417 ⟶ 514:
 
==={{header|Locomotive Basic}}===
 
[[File:CPC color bars.png|thumb|right]]
 
Show the default MODE 0 palette (includes two blinking colors at the end):
 
<syntaxhighlight lang="locobasic">10 MODE 0:BORDER 23
20 FOR x=0 TO 15
Line 498 ⟶ 592:
 
[[File:ColorBarRunBasic.png]]
 
==={{header|SmileBASIC}}===
<syntaxhighlight lang="smilebasic">FOR I=0 TO 7
READ R,G,B
GFILL I*50,0,I*50+49,239,RGB(R,G,B)
NEXT
REPEAT UNTIL BUTTON(0) AND #B
 
DATA 0,0,0
DATA 255,0,0
DATA 0,255,0
DATA 0,0,255
DATA 255,0,255
DATA 0,255,255
DATA 255,255,0
DATA 255,255,255</syntaxhighlight>
 
==={{header|TI Basic}}===
<LANGsyntaxhighlight lang="basic">100 REM SMPTE Format Color Bars
110 REM with 400 Hz reference tone
120 CALL CLEAR
Line 543 ⟶ 653:
540 NEXT I
590 RETURN
</syntaxhighlight>
</LANG>
 
==={{header|ZX Spectrum Basic}}===
Line 833 ⟶ 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 909 099 990 999 ]
col[] = [ 000 900 090 009 909 099 990 999 ]
w = 100.0 / len col[]
forw i= range100 / len col[]
for i color= 1 to len col[i]
move w *color col[i 0]
rect move w 100* (i - 1) 0
rect w 100
.</syntaxhighlight>
.
</syntaxhighlight>
 
=={{header|Factor}}==
Line 872 ⟶ 984:
<br> The color bars are shown in Society of Motion Picture and Television Engineers (SMPTE) order.
 
<syntaxhighlight lang="camel99 forth">
\ Color Bars for TI-99 CAMEL99 Forth
 
Line 937 ⟶ 1,049:
 
CR .( Done. Type BARS to run)
</syntaxhighlight>
</LANG>
 
=={{header|FreeBASIC}}==
<syntaxhighlight lang="freebasic">' FB 1.05.0 Win64
 
' Draw the color bars on an 80 x 25 console using the system palette of 16 colors
' i.e. 5 columns per color
Width 80, 25
Shell "cls"
Locate ,, 0 '' turn cursor off
For clr As UInteger = 0 To 15
Color 0, clr
For row As Integer = 1 to 25
Locate row, clr * 5 + 1
Print Space(5);
Next row
Next clr
 
Sleep
' restore default settings
Locate ,, 1 '' turn cursor on
Color 7, 0 '' white text on black background</syntaxhighlight>
 
=={{header|Gambas}}==
<syntaxhighlight lang="gambas">Public Sub Form_Open()
Dim iColour As Integer[] = [Color.Black, Color.red, Color.Green, Color.Magenta, Color.Cyan, Color.Yellow, Color.white]
Dim hPanel As Panel
Dim siCount As Short
 
With Me
.Arrangement = Arrange.Horizontal
.Height = 300
.Width = 400
End With
 
For siCount = 0 To 6
hpanel = New Panel(Me)
hpanel.Expand = True
hpanel.H = 500
HPanel.Background = iColour[siCount]
Next
 
End</syntaxhighlight>
 
=={{header|Go}}==
Line 1,043 ⟶ 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,061 ⟶ 1,132:
showBars bounds
shutdown vty</syntaxhighlight>
 
[[File:Haskell_Colourbars_A_0.png|700px]]
 
Graphical version using SFML.
Line 1,428 ⟶ 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 );
 
foreach my $rgb ( values %colors ) {
for 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 1,940 ⟶ 2,013:
 
%f'colorbars.png'.open('>:raw').print(image.png);</syntaxhighlight>
 
=={{header|SmileBASIC}}==
<syntaxhighlight lang="smilebasic">FOR I=0 TO 7
READ R,G,B
GFILL I*50,0,I*50+49,239,RGB(R,G,B)
NEXT
REPEAT UNTIL BUTTON(0) AND #B
 
DATA 0,0,0
DATA 255,0,0
DATA 0,255,0
DATA 0,0,255
DATA 255,0,255
DATA 0,255,255
DATA 255,255,0
DATA 255,255,255</syntaxhighlight>
 
=={{header|Tcl}}==
Line 1,998 ⟶ 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
 
Line 2,053 ⟶ 2,141:
{{omit from|Axe}}
{{omit from|GUISS}}
{{omit from|Minimal BASIC}}
 
[[Category:Test card]]
5

edits