Posts
Showing posts from June, 2016
Design Principles for Programming - Lesson 3 -week 3 - Solving Programming Problems solutions
- Get link
- X
- Other Apps
The Green Screen Problem Coursera Practice Quiz solution
- Get link
- X
- Other Apps
Green Screen Algorithm
- Get link
- X
- Other Apps
// write your code here var fgImage = new SimpleImage("drewRobert.png"); var bgImage = new SimpleImage("dinos.png"); var output = new SimpleImage( fgImage.getWidth(), fgImage.getHeight()); for (var pixel of fgImage.values()){ if (pixel.getGreen() >= pixel.getRed() + pixel.getBlue()){ var x = pixel.getX(); var y = pixel.getY(); var bgPixel = bgImage.getPixel(x,y); output.setPixel(x,y,bgPixel); } else { output.setPixel(pixel.getX(), pixel.getY(), pixel); } } print (output);
Answers To Coursera Learning To Program In JavaScript week 3 Quiz 1
- Get link
- X
- Other Apps
5 The following image is 200 by 200 pixels. We suspect that the blue square portion of the image is a true blue with blue value 255 and red and green values 0, but we are not sure.
- Get link
- X
- Other Apps
5 The following image is 200 by 200 pixels. We suspect that the blue square portion of the image is a true blue with blue value 255 and red and green values 0, but we are not sure. To check it, we want to print the RGB values for one pixel in that section. Consider the following code to print the RGB values of one of the blue pixels in the image. Note that the part [MISSING CODE] should assign a value to the variables xvalue and yvalue . 1 2 3 4 5 6 var image = new SimpleImage ( "p1.png" ) ; [ MISSING CODE ] px = image . getPixel ( xvalue , yvalue ) ; print ( px . getRed ( )) ; print ( px . getGreen ( )) ; print ( px . getBlue ( )) ; Which three of the following are valid assignments to xvalue and yvalue as the [MISSING CODE] to print the value of one blue pixel? 1 2 var xvalue = image.getWidth()/3; var yv...
6. Assume an image named image is all green
- Get link
- X
- Other Apps
6. Assume an image named image is all green and we execute the following code segment. 1 2 3 4 5 6 7 8 w = image . getWidth ( ) ; for ( var pixel of image . values ( )) { x = pixel . getX ( ) ; y = pixel . getY ( ) ; if ( x + y < w ) { pixel . setRed ( 255 ) ; } } Which one of the following is the image generated by this code segment?
Consider writing a program to draw a square 200 pixels by 200 pixels that looks like the square below with colors red (red value 255), green (green value 255), and blue (blue value 255).
- Get link
- X
- Other Apps
11. Consider writing a program to draw a square 200 pixels by 200 pixels that looks like the square below with colors red (red value 255), green (green value 255), and blue (blue value 255). All other RGB values are set to 0. Consider that the square is black to start out with. Examine the following code to draw this image that has one MISSING CONDITION to draw the blue pixels. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 for ( var pixel of image . values ( )) { x = pixel . getX ( ) ; y = pixel . getY ( ) ; if ( y <= image . getHeight ( ) / 3 ) { pixel . setRed ( 255 ) ; } else if ( MISSING CONDITION ) { pixel . setBlue ( 255 ) ; } else if ( x <= image . getWidth ( ) / 3 ) { pixel . setRed ( 255 ) ; } else { pixel . setGreen ( 255 ) ; } } Which one of...