How to resolve the algorithm Pinstripe/Display step by step in the PureBasic programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Pinstripe/Display step by step in the PureBasic programming language
Table of Contents
Problem Statement
The task is to demonstrate the creation of a series of vertical pinstripes across the entire width of the display.
c.f. Colour_pinstripe/Display
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Pinstripe/Display step by step in the PureBasic programming language
Source code in the purebasic programming language
#White = $FFFFFF ;color
;Create a Pinstripe image
Procedure PinstripeDisplay(width, height)
Protected x, imgID, psHeight = height / 4, psWidth = 1, psTop, horzBand
imgID = CreateImage(#PB_Any, width, height)
If imgID
StartDrawing(ImageOutput(imgID))
Repeat
x = 0
Repeat
Box(x, psTop, psWidth, psHeight, #White)
x + 2 * psWidth
Until x >= width
psWidth + 1
horzBand + 1
psTop = horzBand * height / 4 ;move to the top of next horizontal band of image
Until psTop >= height
StopDrawing()
EndIf
ProcedureReturn imgID
EndProcedure
;Open a window and display the pinstripe
If OpenWindow(0, 0, 0, 1, 1,"PureBasic Pinstripe", #PB_Window_Maximize | #PB_Window_SystemMenu)
PicID = PinstripeDisplay(WindowWidth(0), WindowHeight(0))
ImageGadget(0, 0, 0, WindowWidth(0), WindowHeight(0), ImageID(PicID))
While WaitWindowEvent() <> #PB_Event_CloseWindow
Wend
EndIf
You may also check:How to resolve the algorithm Closures/Value capture step by step in the Sparkling programming language
You may also check:How to resolve the algorithm Sleep step by step in the C programming language
You may also check:How to resolve the algorithm Rot-13 step by step in the ARM Assembly programming language
You may also check:How to resolve the algorithm Loops/Nested step by step in the Chapel programming language
You may also check:How to resolve the algorithm Animation step by step in the ZX Spectrum Basic programming language