Anonymous user
Greyscale bars/Display: Difference between revisions
→{{header|PureBasic}}
m (→{{header|Phix}}: added syntax colouring, made p2js compatible) |
|||
Line 1,383:
=={{header|PureBasic}}==
<lang PureBasic>
If Not InitSprite(): End: EndIf ;can't init sprite/screen library▼
If Not ExamineDesktops(): End: EndIf ;can't retrieve information about desktop▼
Macro Check(Function)
height.f = DesktopHeight(0)▼
EndMacro
width.f = DesktopWidth(0)▼
depth = DesktopDepth(0)▼
Check(InitKeyboard()) ; Cannot initialize keyboard
If OpenScreen(width, height, depth, "Press ENTER to exit")▼
▲
StartDrawing(ScreenOutput())▼
For v = 0 To 3▼
columns = (v + 1) * 8▼
columnWidth = Round(width / columns, #PB_Round_Up)▼
Define.i iHeight, iWidth, iDepth
For h = 1 To columns - 2▼
If v % 2 = 0▼
Else▼
▲ EndIf
Next▼
Next ▼
StopDrawing()▼
FlipBuffers()▼
Repeat▼
Define.i bMode.b, iLines, fLine.f, iRow, iSpans, fSpan.f,
Delay(10)▼
fColor.f, iTop, iWide, iHigh, iCol, iShade
ExamineKeyboard()▼
▲ If StartDrawing(ScreenOutput())
Until KeyboardPushed(#PB_Key_Escape) Or KeyboardPushed(#PB_Key_Return)▼
bMode = #True ; Pow = #True; Add = #False
iLines = 32 ; Number of Lines
If iLines < 1 : iLines = 1 : EndIf ; Pow/Add-Min
If bMode
If iLines > 6 : iLines = 6 : EndIf ; Pow-Max
Else
If iLines > 32 : iLines = 32 : EndIf ; Add-Max
EndIf
fLine = iHeight / iLines
iLines - 1
iSpans = Pow(2, iRow + 3) - 1 ; Pow
EndIf
fSpan = iWidth / (iSpans + 1)
fColor = 255 / iSpans
iWide = Round(fSpan, #PB_Round_Up)
iHigh = Round(fLine, #PB_Round_Up)
iShade = Round(fColor * iCol, #PB_Round_Up)
If iRow % 2 <> 0 : iShade = 255 - iShade : EndIf ; Alternation
Box(Round(iCol * fSpan, #PB_Round_Up), iTop, iWide, iHigh,
RGB(iShade, iShade, iShade))
▲ Next
▲ StopDrawing()
▲ FlipBuffers()
▲ Repeat
▲ ExamineKeyboard()
KeyboardPushed(#PB_Key_Return)
EndIf
CloseScreen()
EndIf
End</lang>
Press Enter or Escape to exit the programs's display.
|