Java, HTML, CSS: Week 3

¡Supera tus tareas y exámenes ahora con Quizwiz!

You have the following code excerpt to allow a user to select a file from the input element with ID "finput" and display it to a canvas with ID "can." var file = document.getElementById("finput"); var image = new SimpleImage(file); var canvas = document.getElementById("can"); image.drawTo(canvas); Which of the following do you need to add, so that this code will work in CodePen or on another web page?

A script specifying where to find the JavaScript library for SimpleImage

You have two pixels to convert to grayscale, and you would like to determine visually whether your code is likely to be working, so you work an example by hand. The first pixel is orange and has rgb(255,153,51), and the second pixel is green and has rgb(51,153,51). Once the grayscale pixels are printed, which one should appear as a lighter gray (closer to white).

First pixel

What is the purpose of initializing the global image variables to null in the green screen web page?

The code can check if the image is null before processing it.

You are building a web page, and you create a text input element and specify an element ID for it. Why did you do this?

You would like to be able to reference the input element programmatically.

You have created the following file input element: <input type="file" onchange="loadImage()" > Which of the following attributes can you add to restrict the file upload to image files?

accept="image/*"

You would like to display an alert message if the image variable for the foreground image fgImage is not loaded. Which two of the following expressions evaluate to true if the image is not ready?

fgImage == null ! fgImage.complete()

You have defined the following HTML slider input element. <input type="range" min="10" max="100" value="10" id="sldr" oninput="doThing()" > You have accessed this element in the JavaScript function doThing() function doThing() { var sliderinput = document.getElementById("sldr"); // code goes here } What line of code will declare a variable size and initialize it to be the number from the slider?

var size = sliderinput.value;

The following canvas element is defined using HTML: <canvas id="can"> </canvas> You would like to create a JavaScript variable canvas. var canvas = ? What code goes to the right of the assignment operator (equals sign) in order to get this element?

document.getElementById("can");

Which of the following attributes specifies the event handler in an HTML input element?

onclick

In which of the following code snippets does the program alert the user "x is null"?

var x = null; function myFunction() { var x = 2; } myFunction(); if (x == null) { alert("x is null"); }


Conjuntos de estudio relacionados

Theorems, Postulates, Corollaries, and Important Terms after Theorem 8-2

View Set

Practice test final exam [test 1-4] micro

View Set

research literacy in psychology final

View Set

Dual enrollment final exam american government

View Set