PART B: colorArray ToCSS(colorArray) function This function should simply take an array of three numbers from 0 to 255 and return a string that can be used as a CSS color in rgb form. For example, the input array [48, 243, 156] would return the string "rgb(48, 243, 156)".

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 5GZ
icon
Related questions
Question
What would part b look like?
PART B: colorArray ToCSS(colorArray)
function
This function should simply take an array of three
numbers from 0 to 255 and return a string that can
be used as a CSS color in rgb form. For example,
the input array [48, 243, 156] would return the string
"rgb(48, 243, 156)".
PART C: generateColors() function
This code should loop through each of the color
boxes from 0 to 4. It should first check the isLocked
array to find out if the box is locked. If the box is not
locked, then it should replace the current color in
the box with a new random color.
Replacing the color in a box involves a few steps.
First, you need to generate a new random color
using the pre-written function,
getRandomColorArray().
1. The background color of the entire box
defined by the div element should change to
the new color.
2. The text in the span element which displays
the RGB value string should change to
describe the new color.
3. The text color in the box defined by the div
element should be set to either black or
white depending on the brightness of the
color. This should be determined by
summing the red, green, and blue values. If
the sum is greater than 382, make the text
color black, otherwise make it white. For
example, the values in the color
"rgb(165,40,200)" add up to 405, meaning
the text color should be black.
Transcribed Image Text:PART B: colorArray ToCSS(colorArray) function This function should simply take an array of three numbers from 0 to 255 and return a string that can be used as a CSS color in rgb form. For example, the input array [48, 243, 156] would return the string "rgb(48, 243, 156)". PART C: generateColors() function This code should loop through each of the color boxes from 0 to 4. It should first check the isLocked array to find out if the box is locked. If the box is not locked, then it should replace the current color in the box with a new random color. Replacing the color in a box involves a few steps. First, you need to generate a new random color using the pre-written function, getRandomColorArray(). 1. The background color of the entire box defined by the div element should change to the new color. 2. The text in the span element which displays the RGB value string should change to describe the new color. 3. The text color in the box defined by the div element should be set to either black or white depending on the brightness of the color. This should be determined by summing the red, green, and blue values. If the sum is greater than 382, make the text color black, otherwise make it white. For example, the values in the color "rgb(165,40,200)" add up to 405, meaning the text color should be black.
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning