How to resolve the algorithm Greyscale bars/Display step by step in the Plain English programming language
How to resolve the algorithm Greyscale bars/Display step by step in the Plain English programming language
Table of Contents
Problem Statement
The task is to display a series of vertical greyscale bars (contrast bars) with a sufficient number of bars to span the entire width of the display. For the top quarter of the display, the left hand bar should be black, and we then incrementally step through 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.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Greyscale bars/Display step by step in the Plain English programming language
Source code in the plain programming language
To run:
Start up.
Clear the screen.
Imagine a box with the screen's left and the screen's top and the screen's right and the screen's bottom divided by 4.
Make a gradient with the box and 8 and "left-to-right".
Draw the gradient.
Draw the next gradient given the gradient.
Draw the next gradient given the gradient.
Draw the next gradient given the gradient.
Refresh the screen.
Wait for the escape key.
Shut down.
A gradient is a record with
A box,
A partitions number,
And a direction string. \"left-to-right" or "right-to-left"
To make a gradient with a box and a number and a string:
Put the box into the gradient's box.
Put the number into the gradient's partitions.
Put the string into the gradient's direction.
To draw a gradient:
Put the white color into a color.
Put 1000 [the maximum lightness] divided by the gradient's partitions into an amount.
If the gradient's direction is "left-to-right", put the black color into the color.
Put the gradient's box into a box.
Put the gradient's box's width divided by the gradient's partitions into a width number.
Put the width plus the box's left into the box's right.
Loop.
If a counter is past the gradient's partitions, exit.
Draw and fill the box with the color.
Move the box right the width.
If the gradient's direction is "left-to-right", lighten the color by the amount; repeat.
Darken the color by the amount.
Repeat.
To draw the next gradient given a gradient:
Move the gradient's box down the gradient's box's height.
Double the gradient's partitions.
If the gradient's direction is "left-to-right", set a flag.
If the flag is set, put "right-to-left" into the gradient's direction.
If the flag is not set, put "left-to-right" into the gradient's direction.
Draw the gradient.
You may also check:How to resolve the algorithm String concatenation step by step in the Plain English programming language
You may also check:How to resolve the algorithm Write language name in 3D ASCII step by step in the Plain English programming language
You may also check:How to resolve the algorithm Loops/For step by step in the Plain English programming language
You may also check:How to resolve the algorithm Generate lower case ASCII alphabet step by step in the Plain English programming language
You may also check:How to resolve the algorithm Real constants and functions step by step in the Plain English programming language