Pinstripe/Display: Difference between revisions
Content added Content deleted
(initial content) |
(Adding PureBasic) |
||
Line 6: | Line 6: | ||
[[Category:Test card]] |
[[Category:Test card]] |
||
=={{header|PureBasic}}== |
|||
Generating the Pinstripe picture |
|||
<lang PureBasic>Procedure PinstripeDisplay(Width=800) |
|||
Protected x, l=1, imgID |
|||
imgID=CreateImage(#PB_Any, Width, 1) |
|||
If imgID |
|||
StartDrawing(ImageOutput(imgID)) |
|||
Repeat |
|||
Line(x, 0, l, 1, #White) |
|||
If x>=3*Width/4 : l=4 |
|||
ElseIf x>=Width/2 : l=3 |
|||
ElseIf x>=Width/4 : l=2 |
|||
EndIf |
|||
x+2*l |
|||
Until x >= Width |
|||
StopDrawing() |
|||
EndIf |
|||
ProcedureReturn imgID |
|||
EndProcedure</lang> |
|||
Test the code, and save the result. |
|||
<lang PureBasic>PicID=PinstripeDisplay() |
|||
If PicID And UsePNGImageEncoder() |
|||
Path$=GetSpecialFolder(#CSIDL_DESKTOP)+"PB_Pinstripe.png" |
|||
SaveImage(PicID, Path$,#PB_ImagePlugin_PNG,0,2) |
|||
EndIf</lang> |
|||
Result |
|||
[[file:PB_Pinstripe.png]] |
Revision as of 16:45, 22 May 2011
Pinstripe/Display is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
The task is to demonstrate the creation of 1 pixel wide pinstripes across the width of the display. The pinstripes should alternate one pixel white, one pixel black.
Quarter of the way down the display, we can switch to a wider 2 pixel wide pinstripe pattern, alternating two pixels white, two pixels black. Half way down the display, we switch to 3 pixels wide, and for the lower quarter of the display we use 4 pixels.
PureBasic
Generating the Pinstripe picture <lang PureBasic>Procedure PinstripeDisplay(Width=800)
Protected x, l=1, imgID imgID=CreateImage(#PB_Any, Width, 1) If imgID StartDrawing(ImageOutput(imgID)) Repeat Line(x, 0, l, 1, #White) If x>=3*Width/4 : l=4 ElseIf x>=Width/2 : l=3 ElseIf x>=Width/4 : l=2 EndIf x+2*l Until x >= Width StopDrawing() EndIf ProcedureReturn imgID
EndProcedure</lang> Test the code, and save the result. <lang PureBasic>PicID=PinstripeDisplay() If PicID And UsePNGImageEncoder()
Path$=GetSpecialFolder(#CSIDL_DESKTOP)+"PB_Pinstripe.png" SaveImage(PicID, Path$,#PB_ImagePlugin_PNG,0,2)
EndIf</lang> Result