Jump to content

Colour bars/Display: Difference between revisions

BASIC | Applesoft BASIC
(BASIC | Applesoft BASIC)
Line 98:
Return</lang>
 
=={{header|BBC BASIC}}==
 
==={{header|Applesoft BASIC}}===
<lang ApplesoftBasic>1 DATA1,12,6,3,14,13,15
2 HOME : GR : FOR I = 1 TO 7
3 READ C(I) : NEXT
4 FOR I = 0 TO 39
5 COLOR= C(I / 5)
6 VLIN 0,39 AT I : NEXT</lang>
 
==={{header|BBC BASIC}}===
{{works with|BBC BASIC for Windows}}
<lang bbcbasic> SW_MAXIMIZE = 3
Line 120 ⟶ 130:
NEXT
</lang>
 
==={{header|Liberty BASIC}}===
<lang lb>nomainwin
colors$="black red green blue pink cyan yellow white"
WindowWidth=DisplayWidth:WindowHeight=DisplayHeight
UpperLeftX=1:UpperLeftY=1
barWidth=DisplayWidth/8
graphicbox #main.g, 0,0,DisplayWidth,DisplayHeight
open "" for window_popup as #main
#main "trapclose [quit]"
#main.g "down; setfocus; when characterInput [quit]"
#main.g "when leftButtonUp [quit]"
#main.g "size ";barWidth
 
for x = barWidth/2 to DisplayWidth step barWidth
i=i+1
if i>8 then i=1
col$=word$(colors$,i)
#main.g "color ";col$;"; line ";x;" 0 ";x;" ";DisplayHeight
next
wait
[quit] close #main:end
</lang>
 
==={{header|Locomotive Basic}}===
 
[[File:CPC color bars.png|thumb|right]]
 
Show the default MODE 0 palette (includes two blinking colors at the end):
 
<lang locobasic>10 MODE 0:BORDER 23
20 FOR x=0 TO 15
30 ORIGIN x*40,0
40 GRAPHICS PEN x
50 FOR z=0 TO 39 STEP 4:MOVE z,0:DRAW z,400:NEXT
60 NEXT
70 CALL &bb06 ' wait for key press</lang>
 
==={{header|PureBasic}}===
Press Enter or Escape to exit the program.
<lang PureBasic>Dim color(7)
color(0) = RGB($00, $00, $00) ;black
color(1) = RGB($FF, $00, $00) ;red
color(2) = RGB($00, $FF, $00) ;green
color(3) = RGB($00, $00, $FF) ;blue
color(4) = RGB($FF, $00, $FF) ;magenta
color(5) = RGB($00, $FF, $FF) ;cyan
color(6) = RGB($FF, $FF, $00) ;yellow
color(7) = RGB($FF, $FF, $FF) ;white
 
If Not InitKeyboard(): End: EndIf ;can't init keyboard
If Not InitSprite(): End: EndIf ;can't init sprite/screen library
If Not ExamineDesktops(): End: EndIf ;can't retrieve information about desktop
 
height = DesktopHeight(0)
width = DesktopWidth(0)
depth = DesktopDepth(0)
If OpenScreen(width, height, depth, "Press ENTER to exit")
StartDrawing(ScreenOutput())
For c = 0 To 7
Box((width * c) / 8, 0, width / 8, height, color(c))
Next
StopDrawing()
FlipBuffers()
 
Repeat
Delay(10)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape) Or KeyboardPushed(#PB_Key_Return)
CloseScreen()
EndIf</lang>
====Alternate method using console====
<lang PureBasic>DataSection
;Black, Red, Green, Blue, Magenta, Cyan, Yellow, White
Data.i 0, 12, 10, 9, 13, 11, 14, 15
EndDataSection
 
Dim colors(7)
For c = 0 To 7
Read.i colors(c)
Next
 
If OpenConsole()
;The console display is 80 columns wide by 25 rows
For r = 0 To 24
For c = 0 To 7
ConsoleColor(colors(c), colors(c))
Print(Space(80 / 8))
Next
Next
EnableGraphicalConsole(1)
ConsoleLocate(0, 0)
ConsoleTitle("Press ENTER to exit"): Input()
CloseConsole()
EndIf</lang>
 
==={{header|Run BASIC}}===
<lang runbasic>colors$ = "black,red,green,blue,magenta,cyan,yellow,white"
html "<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=4><tr height=70>"
for i = 1 to 8
html "<td width=20 bgcolor='";word$(colors$,i,",");"'</td>"
next i
html "</tr></table>"</lang>
<pre>Output</pre>
 
[[File:ColorBarRunBasic.png]]
 
==={{header|ZX Spectrum Basic}}===
<lang zxbasic>10 REM The ZX Spectrum display is 32 columns wide, so we have 8 columns of 4 spaces
20 FOR r=0 TO 20: REM There are 21 rows
30 FOR c=0 TO 7: REM We use the native colour sequence here
40 PAPER c: REM set the background colour for the spaces to be printed
50 PRINT " ";: REM four spaces, the semicolon prevents newline
60 NEXT c
70 REM at this point the cursor has wrapped, so we don't need a newline
80 NEXT r</lang>
 
=={{header|C}}==
Line 429 ⟶ 556:
}
</lang>
=={{header|Liberty BASIC}}==
<lang lb>nomainwin
colors$="black red green blue pink cyan yellow white"
WindowWidth=DisplayWidth:WindowHeight=DisplayHeight
UpperLeftX=1:UpperLeftY=1
barWidth=DisplayWidth/8
graphicbox #main.g, 0,0,DisplayWidth,DisplayHeight
open "" for window_popup as #main
#main "trapclose [quit]"
#main.g "down; setfocus; when characterInput [quit]"
#main.g "when leftButtonUp [quit]"
#main.g "size ";barWidth
 
for x = barWidth/2 to DisplayWidth step barWidth
i=i+1
if i>8 then i=1
col$=word$(colors$,i)
#main.g "color ";col$;"; line ";x;" 0 ";x;" ";DisplayHeight
next
wait
[quit] close #main:end
</lang>
 
=={{header|Locomotive Basic}}==
 
[[File:CPC color bars.png|thumb|right]]
 
Show the default MODE 0 palette (includes two blinking colors at the end):
 
<lang locobasic>10 MODE 0:BORDER 23
20 FOR x=0 TO 15
30 ORIGIN x*40,0
40 GRAPHICS PEN x
50 FOR z=0 TO 39 STEP 4:MOVE z,0:DRAW z,400:NEXT
60 NEXT
70 CALL &bb06 ' wait for key press</lang>
 
=={{header|Mathematica}}==
Line 593 ⟶ 684:
imagepng($image);
imagedestroy($image);</lang>
 
=={{header|PureBasic}}==
Press Enter or Escape to exit the program.
<lang PureBasic>Dim color(7)
color(0) = RGB($00, $00, $00) ;black
color(1) = RGB($FF, $00, $00) ;red
color(2) = RGB($00, $FF, $00) ;green
color(3) = RGB($00, $00, $FF) ;blue
color(4) = RGB($FF, $00, $FF) ;magenta
color(5) = RGB($00, $FF, $FF) ;cyan
color(6) = RGB($FF, $FF, $00) ;yellow
color(7) = RGB($FF, $FF, $FF) ;white
 
If Not InitKeyboard(): End: EndIf ;can't init keyboard
If Not InitSprite(): End: EndIf ;can't init sprite/screen library
If Not ExamineDesktops(): End: EndIf ;can't retrieve information about desktop
 
height = DesktopHeight(0)
width = DesktopWidth(0)
depth = DesktopDepth(0)
If OpenScreen(width, height, depth, "Press ENTER to exit")
StartDrawing(ScreenOutput())
For c = 0 To 7
Box((width * c) / 8, 0, width / 8, height, color(c))
Next
StopDrawing()
FlipBuffers()
 
Repeat
Delay(10)
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape) Or KeyboardPushed(#PB_Key_Return)
CloseScreen()
EndIf</lang>
===Alternate method using console===
<lang PureBasic>DataSection
;Black, Red, Green, Blue, Magenta, Cyan, Yellow, White
Data.i 0, 12, 10, 9, 13, 11, 14, 15
EndDataSection
 
Dim colors(7)
For c = 0 To 7
Read.i colors(c)
Next
 
If OpenConsole()
;The console display is 80 columns wide by 25 rows
For r = 0 To 24
For c = 0 To 7
ConsoleColor(colors(c), colors(c))
Print(Space(80 / 8))
Next
Next
EnableGraphicalConsole(1)
ConsoleLocate(0, 0)
ConsoleTitle("Press ENTER to exit"): Input()
CloseConsole()
EndIf</lang>
 
 
=={{header|Python}}==
Line 714 ⟶ 745:
(void (new full-frame%))
</lang>
 
=={{header|Run BASIC}}==
<lang runbasic>colors$ = "black,red,green,blue,magenta,cyan,yellow,white"
html "<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=4><tr height=70>"
for i = 1 to 8
html "<td width=20 bgcolor='";word$(colors$,i,",");"'</td>"
next i
html "</tr></table>"</lang>
<pre>Output</pre>
 
[[File:ColorBarRunBasic.png]]
 
=={{header|Scala}}==
Line 806 ⟶ 826:
SetVid(3); \restore normal text mode
]</lang>
 
== {{header|ZX Spectrum Basic}} ==
 
<lang zxbasic>10 REM The ZX Spectrum display is 32 columns wide, so we have 8 columns of 4 spaces
20 FOR r=0 TO 20: REM There are 21 rows
30 FOR c=0 TO 7: REM We use the native colour sequence here
40 PAPER c: REM set the background colour for the spaces to be printed
50 PRINT " ";: REM four spaces, the semicolon prevents newline
60 NEXT c
70 REM at this point the cursor has wrapped, so we don't need a newline
80 NEXT r</lang>
 
{{omit from|GUISS}}
413

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.