1. Consider writing code that turns the red part of every pixel in "chapel.png" to the highest red value possible. The image changes from the picture on the left to the redder picture on the right.

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter4: Graphic Design With Css: Creating A Graphic Design For A Genealogy website
Section4.2: Visual Overview: Shadows And Gradients
Problem 7QC
icon
Related questions
Question

HELP!

1. Consider writing code that turns the red part of every pixel in "chapel.png" to the highest red value possible. The image
changes from the picture on the left to the redder picture on the right.
The code has been started below but has missing code.
var image = new Simplelmage("chapel.png");
// missing code
print(image);
Which one of the following is the best choice for the correct missing code to turn the chapel red?
for (var pixel of image.values()) {
pixel.setRed(255);
}
for (var pixel of image.values()) {
pixel.setRed(100000);
}
for (var pixel of image.values()) {
var number = pixel.getRed();
pixel.setRed(number + 20);
}
for (var pixel of image.values()) {
pixel.setRed(200);
pixel.setBlue(0);
pixel.setGreen(0);
}
I Incorrect
This is not a correct answer. This code gets the current value of red in a pixel, and changes the pixel's red value
by just adding 20. It is changing the red value only a small amount and that number may also be too large,
greater than 255.
Transcribed Image Text:1. Consider writing code that turns the red part of every pixel in "chapel.png" to the highest red value possible. The image changes from the picture on the left to the redder picture on the right. The code has been started below but has missing code. var image = new Simplelmage("chapel.png"); // missing code print(image); Which one of the following is the best choice for the correct missing code to turn the chapel red? for (var pixel of image.values()) { pixel.setRed(255); } for (var pixel of image.values()) { pixel.setRed(100000); } for (var pixel of image.values()) { var number = pixel.getRed(); pixel.setRed(number + 20); } for (var pixel of image.values()) { pixel.setRed(200); pixel.setBlue(0); pixel.setGreen(0); } I Incorrect This is not a correct answer. This code gets the current value of red in a pixel, and changes the pixel's red value by just adding 20. It is changing the red value only a small amount and that number may also be too large, greater than 255.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Encryption and Decryption
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
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning