Computer Graphics Exam 1

studied byStudied by 0 people
0.0(0)
get a hint
hint
a)

1 / 276

Tags and Description

Chapter 1 - Chapter 4

277 Terms

1
a)
Which tag does JavaScript go inside when you wish to write it in line with ?

a)
New cards
2

a) Class

Assuming my code does not have any syntax errors in it, what scope is a variable labeled 'this.myVar'?

a) Class

b) Local

c) Global

d) Limited within the
New cards
3

a) extends

What notation does JavaScript use to inherit from one class to another?

a) extends

b) inherits

c) implements

d) :

New cards
4

a) call ‘super()’;

If I have a class (in JavaScript) that inherits from another one, in order to call the constructor in the parent I must:

a) call ‘super()’;

b) not do anything as it will do it automatically

c) call ‘Parent()’

d) must initialize an instance of parent ans assign it to ‘this’

New cards
5

true

(T/F) If I dynamically add an HTML element to page, I do not have to initialize everything at first as I can change the properties of that object once it has been added.

New cards
6

D

If I have the following code in JavaScript

(and assume mySection is a pointer to an HTML
object).

for(var i =0; i < 5; i ++)

{

mySection.innerHTML += "# ";

mySection.innerHTML += "\\n";

}

What will my output be?
If I have the following code in JavaScript

(and assume mySection is a pointer to an HTML <SECTION> object).

for(var i =0; i < 5; i ++)

{

     mySection.innerHTML += "# ";

     mySection.innerHTML += "\\n";

}

What will my output be?
New cards
7

true

(T/F) JavaScript is client-side by default.

New cards
8

false

(T/F) JavaScript is server-side by default.

New cards
9

c) hard-typed language

Which of the following statements are not true about JavaScript?

a) will run in-line with HTML

b) can modify other components using the document object model (DOM) of HTML

c) hard-typed language

d) requires the use of tags

e) none of the above
New cards
10

b) will erase the existing web-page

document.write(); will write text to the page, however, it also

a) redirect the text output to another page

b) will erase the existing web-page

c) won’t be formatted properly

d) has no drawbacks, it will work as intended
New cards
11
a) document.write();
You can use this method to write text to the page but it will erase the existing web-page, if the page has finished loading.

What method is this?

a) document.write();

b) document.getElementById();

c) document.note();

d) document.writeText();
New cards
12
b) document.getElementById();
It is a better idea to use this method when writing text to a page.

What method is this?

a) document.write();

b) document.getElementById();

c) document.note();

d) document.writeText();
New cards
13

a) the title will change to “Hello World”

Given the code, what will happen if the following is written to the console?

var myTitle = document.getElementById(“title”);

myTitle.innerHTML = “Hello World”;

a) the title will change to “Hello World”

b) a new small text “Hello world” will appear under the title

c) another title “Hello World” will appear above the title

d) nothing will happen

<p>Given the code, what will happen if the following is written to the console?</p><p>var myTitle = document.getElementById(“title”);</p><p>myTitle.innerHTML = “Hello World”;</p><p>a) the title will change to “Hello World”</p><p>b) a new small text “Hello world” will appear under the title</p><p>c) another title “Hello World” will appear above the title</p><p>d) nothing will happen</p>
New cards
14
b) console.log();
Which of the following will output to the console?

a) console.warn();

b) console.log();

c) console.error();

d) console.write();
New cards
15
d) console.warn();
Which of the following will output a warning?

a) console.yell()

b) console.log();

c) console.error();

d) console.warn();
New cards
16
b) console.error();
Which of the follow will output an error?

a) console.warn();

b) console.error();

c) console.fault();

d) console.log();
New cards
17

b) current scope

The following declared variable will declare x as 10 in the ______________.

var x = 10;

a) global scope

b) current scope

c) class scope

d) local scope

New cards
18

true

(T/F) The method document.write(); can only be used while the page is loading up unless you wish to destroy the page.
New cards
19

true

(T/F) JavaScript will always do floating point division.

New cards
20

false

(T/F) JavaScript will only sometimes do floating point division.

New cards
21

true

(T/F) OpenGL will only accept float.

New cards
22

false

(T/F) OpenGL will only accept double.

New cards
23

b) 64

By default, all decimal numbers in JavaScript are ________________ bit.

a) 24

b) 64

c) 8

d) 16

New cards
24

c) global

All variables declared outside of a function of class will automatically have ______________ scope.

a) local

b) class

c) global

d) functional

New cards
25

canvas context, instance of main, canvas variable

The only global variables you are allowed to have are

(select multiple)

  • canvas context

  • instance of main

  • class functions

  • canvas variable

New cards
26

document.body.appendChild(this.myImg);

From the code given, which statement allows an object to be dynamically added to the HTML?

<p>From the code given, which statement allows an object to be dynamically added to the HTML?</p>
New cards
27

a) floating-point division

What kind of math is ALWAYS done in JavaScript?

a) floating-point division

b) double-point division

c) floating-point multiplication

d) none of the above

New cards
28

true

(T/F) The default numeric type for JavaScript is float.

New cards
29

you need a global function for a callback, from the global callback we can call the class function

Explain the process of invoking a call back. Assume we want to have all the functionality inside a class. What is the extra piece of work we have to do?

New cards
30

c) canvas

HTML 5 introduced an HTML element called ____________. This element can be used to draw and render images.

a) painting

b) drawer

c) canvas

d) whiteboard

New cards
31

2D, 3D

What are the two contexts in which a programmer can draw images?

New cards
32

fragment and vertex shader, charset, any/all CSS or JavaScript imports, inline functions or classes

The HTML head section contains:

(select multiple)

  • fragment and vertex shader

  • charset

  • HTML canvas element

  • any/all CSS or JavaScript imports

  • global functions or classes

  • inline functions or classes

New cards
33

b) body

The _________________ section of the HTML file will contain the content seen in the webpage.

a) footer

b) body

c) header

d) title

New cards
34

b) code that is not inside a function or a class

JavaScript will begin execution when it encounters _____________________________.

a) any kind of code

b) code that is not inside a function or a class

c) code that is inside a function or a class

d) none of the above, JavaScript will begin execution regardless

New cards
35

d) all of the above

JavaScript has ________________ variable scope.

a) global

b) local

c) class

d) all of the above

New cards
36

d) all of the above

In this class, the only 3 global variables used are

a) instance of the main class

b) canvas object

c) canvas context

d) all of the above

New cards
37

true

(T/F) If a function returns void, it does not have a return statement or it has a return statement with no value.

New cards
38

b) script HTML tag

In basic JavaScript syntax, things such as writing to the console and function declaration must be written between

a) footer HTML tag

b) script HTML tag

c) body HTML tag

d) none of the above

New cards
39

true

(T/F) You cannot overload the constructor in JavaScript.

New cards
40

false

(T/F) You can overload the constructor in JavaScript.

New cards
41

b) constructor()

What is the correct way to declare class functions?

a) class function constructor()

b) constructor()

c) function constructor()

d) class Main::constructor()

New cards
42

parameterized constructor

You cannot overload the constructor in JavaScript but you can have a ___________________ instead of a default.

New cards
43

true

(T/F) All class variables are public.

New cards
44

false

(T/F) All class variables are private.

New cards
45

a) after

Callbacks must be assigned ___________ the class has been initialized.

a) after

b) before

New cards
46

true

(T/F) JavaScript can also iterate through collections, similar to a for-each loop e.g. for(let x in jsArray){…}.

New cards
47

IDs

You can assign different ___________ to HTML elements.

New cards
48

ConsoleSection = document.getElementById(“console”)

How would you assign this given section to a variable called ConsoleSection in JavaScript?

New cards
49

ConsoleSection.innerHTML += “text”

A section called “console” has the corresponding JavaScript variable ConsoleSection. How would you dynamically add text to this section?



ConsoleSection = document.getElementById(“console”)
New cards
50

true

(T/F) When dynamically adding text to a section, the text is displayed in HTML not normal text. Therefore, it must have HTML formatting.

New cards
51

false

(T/F) When dynamically adding text to a section, the text is displayed as a normal text. Therefore, it must doesn’t need to have HTML formatting.

New cards
52

d) top left

The canvas coordinate system will start at the ___________.

a) top right

b) bottom left

c) bottom right

d) top left

New cards
53

true

(T/F) When you go down the screen of the canvas, the Y increases.

New cards
54

false

(T/F) When you go down the screen of the canvas, the Y decreases.

New cards
55

var ctx = canvas.getContext(“2d”)

We are given the JavaScript variable pointing at the canvas.

How would you write the 2D drawing context called ctx for this canvas?

var canvas = document.getElementById(“myCanvas”)

New cards
56

canvas object

We have to find the ______________ and from that we can select 2D and WebGL.

New cards
57

true

(T/F) Once I set a property, it will remain the same until I set it again.

New cards
58

false

(T/F) Once I set a property, I will need to continuously set that property throughout the code.

New cards
59

line color, fill color, line width, line cap, line join

What are the different context 2D properties?

New cards
60

ctx.beginPath(), ctx.moveTo(X,Y), ctx.lineTo(X,Y), ctx.stroke(), ctx.fill()

What are the commands needed in order to draw your own shapes? (use the context variable ctx)

New cards
61

ctx.drawImage(pic, 400, 200), ctx.drawImage(pic, 400, 200, 100, 100)

What are the two different ways to write the commands to draw an image using the image tag and variables given?

We want the image at location (400, 200) and the size of the image should be 100 by 100 pixels. (use the context variable ctx)

”slime”

var pic = document.getElementById(“slime”)
New cards
62

true

(T/F) With context 2D, the last thing drawn will appear ‘on top’ of anything drawn before.

New cards
63

false

With context 2D, the last thing drawn will appear on the same layer of anything drawn before.

New cards
64

immediate-mode

With context 2D, the last thing drawn will appear ‘on top’ of anything drawn before. This is a generic property of _____________________ graphics.

New cards
65

red

I set Shape 1 color to green, Shape 2 color to red, and I forget to set the color for Shape 3. What color will Shape 3 be if I render in this order?

New cards
66

green

I set Shape 1 color to green, Shape 2 color to red, and I forget to set the color for Shape 3. What color will Shape 3 be if I render in this order?

Shape 1, Shape 2, Shape 1, Shape 3

New cards
67

top left

Where is (0,0) in the canvas?

New cards
68

beginPath(), moveTo(), lineTo(), stroke(), fill()

What is the order of commands to draw my own custom shape?

New cards
69

false

(T/F) I can only choose to use stroke() or fill(), but not both.

New cards
70

scalability, confusion between which commands affect which object, not effective for storing specific object information

Why would it be a bad idea to make a large function containing a list on instructions to create a complex scene?

New cards
71

coordinates, color, speed, scaling, other properties we want to give our object

What kind of information would we store in a class that allows us to create an object instance, or multiple instances?

New cards
72

DrawBackground(), For each Object in mySceneObjects

A render cycle, a phase where the screen is updated, would have a pseudocode look something similar to:

  • _________________

  • _________________

  • update any info needed in the object

  • render (or draw) the object on screen

New cards
73

d) all of the above

Why is it important to define some form of entity that can represent an object in your scene?

a) so it can apply to all objects you may need in your scene

b) so it can be stored in one collection

c) so it can be easily updated and render every time a new scene is needed

d) all of the above

New cards
74

[2D or 3D], Rotation, Constructor(), Update(), Render()

A suggested model for rendering a scene would look like:

Class BaseEntity

{

  • Loc = ____________ //an array for storing location

  • _________________ = rotation of the object

  • __________________

  • _________________

  • _________________

}

New cards
75

a) starts at 0 at the top left and increases as it goes down

In context 2D the y-axis

a) starts at 0 at the top left and increases as it goes down

b) is located bottom right and increases as it goes up

c) is located midway through the scene

d) starts at 0 at the bottom left and increases as it goes up

New cards
76

a) green

I have four shapes:

Shape one will set the color to red, shape two will set the color to blue, and shape three will set the color to green.

I forget to set my color for shape four and I call the following render functions:

Shape2.render()

Shape1.render()

Shape3.render()

Shape4.render()

What color will shape 4 be?

a) green

b) not enough information

c) red

d) blue

New cards
77

false

(T/F) Color #FFF is the same color as #F0F0F0.

New cards
78

true

(T/F) Color #FFF is the same color as #FFFFFF.

New cards
79

B

Which one is round?

<p>Which one is round?</p>
New cards
80

A

Which one is miter?

<p>Which one is miter?</p>
New cards
81

C

Which one is bevel?

<p>Which one is bevel?</p>
New cards
82

false

(T/F) Line caps "Square" and "Butt" are exactly the same.

New cards
83

b) C

Which language was OpenGL written in?

a) Java

b) C

c) C++

d) JavaScript

New cards
84

d) JavaScript

Which language does WebGL force the user to program in?

a) C

b) C++

c) Java

d) JavaScript

New cards
85

true

(T/F) Modern PCs will almost always transfer the graphical workload from the CPU to the GPU.

New cards
86

c) CPU

What best describes the following?

Designed for general purpose computing and can handle all computational tasks.

a) RAM

b) GPU

c) CPU

d) Cached Graphic Memory

New cards
87

c) GPU

Which best describes:

Specific hardware configuration for graphical computational purposes.

Specializes in parallelism and mathematical operations.

a) CPU

b) RAM

c) GPU

d) Cached Graphic Memory

New cards
88

d) resolution

When I say a picture is 100 pixels by 40 pixels I am talking about the ___________________.

a) full color

b) depth

c) monochrome

d) resolution

New cards
89

d) aspect ratio

When I divide the width by the height I get

a) picture depth

b) resolution

c) full color

d) aspect ratio

New cards
90

a) monochrome

I have 1 bit to define color so I have

a) monochrome

b) 256 color

c) full color

d) 16-bit color

New cards
91

OpenGL

Am I describing OpenGL or WebGL?

  • uses C as a primary language

  • written at a very low level

  • optimized and one of the most popular graphics libraries

New cards
92

WebGL

Am I describing OpenGL or WebGL?

  • uses JavaScript

  • creates graphics on HTML 5 Canvas objects

  • written to allow 3D (and 2D) graphic rendering over the web

  • built on top of OpenGL

New cards
93

a) to represent data visually

What is the point of Computer Graphics?

a) to represent data visually

b) to draw pictures digitally

c) to create data on the computer

d) none of the above

New cards
94

input devices, CPU, GPU, memory, frame buffer, output devices

The graphical system will contain:

  • ___________

  • ______________________

  • ______________________

  • ___________

  • ___________

  • _______________

New cards
95

frame buffer

The _________________ holds the data for the image and is loaded into a display device.

New cards
96

resolution

The width and height of the frame buffer is the ______________________.

New cards
97

depth

The number of bits used for each pixel is the ____________ or the precision of the image.

New cards
98

b) full color

If the depth of an image is 24 bits then that means the image is in

a) monochrome

b) full color

c) 256 color

d) none of the above

New cards
99

c) monochrome

If the depth of an image is 1 bit then that means the image is in

a) 256 color

b) full color

c) monochrome

d) none of the above

New cards
100

true

(T/F) Computer Graphics is the opposite of Computer Vision.

New cards

Explore top notes

note Note
studied byStudied by 12 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 12 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 63 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 22 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 12 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 6 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 37 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 101 people
Updated ... ago
5.0 Stars(4)

Explore top flashcards

flashcards Flashcard212 terms
studied byStudied by 12 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard43 terms
studied byStudied by 12 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard50 terms
studied byStudied by 3 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard65 terms
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard20 terms
studied byStudied by 23 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard44 terms
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard30 terms
studied byStudied by 4 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard26 terms
studied byStudied by 5 people
Updated ... ago
5.0 Stars(1)