Greyscale bars/Display: Difference between revisions

From Rosetta Code
Content added Content deleted
m (moved Contrast bars/Display to Greyscale bars/Display: new title is more descriptive)
(vertical greyscale bars)
Line 1: Line 1:
{{draft task}}
{{draft task}}


The task is to display a series of contrast bars across the width of the display.
The task is to display a series of vertical greyscale bars (contrast bars) across the width of the display.


For the top quarter of the display, the left hand bar should be black, and we then incrementally step though six shades of grey until we have a white bar on the right hand side of the display. (This gives a total of 8 bars)
For the top quarter of the display, the left hand bar should be black, and we then incrementally step though six shades of grey until we have a white bar on the right hand side of the display. (This gives a total of 8 bars)
Line 12: Line 12:


ZX Spectrum Basic cannot natively produce greyscale. However, the colours have been
ZX Spectrum Basic cannot natively produce greyscale. However, the colours have been
cleverly arranged, so that the monochrome signals are in sequential order of brightness. Wind the colour down, or use a black and white television
cleverly arranged, so that the native colours give monochrome signals in sequential order of brightness. Wind the colour down, or use a black and white television
and we have a set of 8 bars:
and we have a set of 8 bars:



Revision as of 19:19, 23 May 2011

Greyscale bars/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 display a series of vertical greyscale bars (contrast bars) across the width of the display.

For the top quarter of the display, the left hand bar should be black, and we then incrementally step though six shades of grey until we have a white bar on the right hand side of the display. (This gives a total of 8 bars)

For the second quarter down, we start with white and step down through 14 shades of gray, getting darker until we have black on the right hand side of the display. (This gives a total of 16 bars).

Halfway down the display, we start with black, and produce 32 bars, ending in white, and for the last quarter, we start with white and step through 62 shades of grey, before finally arriving at black in the bottom right hand corner, producing a total of 64 bars for the bottom quarter.

ZX Spectrum Basic

ZX Spectrum Basic cannot natively produce greyscale. However, the colours have been cleverly arranged, so that the native colours give monochrome signals in sequential order of brightness. Wind the colour down, or use a black and white television and we have a set of 8 bars:

<lang basic> 10 REM wind the colour down or use a black and white television to see greyscale bars 20 REM The ZX Spectrum display is 32 columns wide, so we have 8 columns of 4 spaces 30 FOR r=0 TO 20: REM There are 21 rows 40 FOR c=0 TO 7: REM We use the native colour sequence here 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>