Dear members of the forum, I received a test task of this type. I can not understand a few things:
The end result is a certain number of horizontal lines, which in turn consist of individual blocks of different colors?
if so, then why specify a color for the objects in the lines array, if it will still be covered with objects from the elements?
How best to implement the update color: a separate function through setInterval? There are no ideas yet.
I will be glad to any answer. Thank!
Here is a description of the problem:
“Everyone faced preventive broadcasting on television channels. You need to implement the following task.
You have a set of input data in an object by type:
var params = { lines: [ { background: '#00F', updateTime: 1000, elements: [{ background: '#00F', width: 25 }, { background: '#00F', width: 50 }, { background: '#00F', width: 25 },... ] }... ] } Implement the drawing of this data as follows. The entire screen should be filled with elements of the lines array whose width is equal to the width of the screen, and the height of the result of dividing the height of the screen by the number of lines. The color of the line should be taken from the background property.
In each line there are elements whose parameters are taken from the elements array, each element must be drawn with the corresponding width specified in percent, the height equal to the height of the line, and the color from the background property.
Depending on the updateTime property in each row, it is necessary to implement a color change to any other color (it is necessary to implement a color generator), in the time interval the corresponding number of milliseconds specified in the property.
When performing tasks, it is not recommended to use extraneous libraries, frameworks, it is also necessary that the examples work in the same way in the main browsers Chrome, Firefox, IE9 +, Opera "