JavaScript and Color Theory Quiz
35 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which statement accurately describes JavaScript arrays?

  • JavaScript arrays require explicit type declaration.
  • JavaScript arrays are objects and can have dynamic sizes. (correct)
  • JavaScript arrays do not inherit methods.
  • JavaScript arrays are fixed in size like C arrays.

Which type of image uses gray levels and is analogous to black and white film?

  • Monochromatic Image
  • Color Image
  • Three-Color Theory Image
  • Luminance Image (correct)

What is the key difference between the operators '==' and '===' in JavaScript?

  • '==' compares reference, whereas '===' compares values.
  • '==' is used for comparison, and '===' for assignment.
  • '==' checks value and type equality, while '===' checks value only.
  • '==' checks for value equality, while '===' checks for strict equality including type. (correct)

What are the primary colors used in the additive color model?

<p>Red, Green, Blue (B)</p> Signup and view all the answers

Why might developers prefer standard JavaScript arrays over typed arrays?

<p>Standard JavaScript arrays allow dynamic resizing which is useful. (D)</p> Signup and view all the answers

What is the role of rods in the human visual system?

<p>Monochromatic night vision (D)</p> Signup and view all the answers

Which of the following is a characteristic of JavaScript's typing system?

<p>JavaScript uses dynamic typing, allowing variable types to change. (A)</p> Signup and view all the answers

What is the preferred approach to coding with graphics in JavaScript as suggested?

<p>Focus exclusively on core JavaScript and HTML without extra packages. (A)</p> Signup and view all the answers

In which context is subtractive color primarily used?

<p>Printing processes (B)</p> Signup and view all the answers

What is the purpose of the three types of cones in the human eye?

<p>To enable color sensitivity (A)</p> Signup and view all the answers

Which equation is used for the projection of a point in a pinhole camera model?

<p>xp = -x/z/d (A)</p> Signup and view all the answers

What coding language is primarily used for WebGL development?

<p>JavaScript (D)</p> Signup and view all the answers

Which statement is true about the three-color theory?

<p>Only three primary colors are needed. (A)</p> Signup and view all the answers

What is the purpose of gl.clearColor function in the WebGL configuration?

<p>To clear the canvas with a specified color. (A)</p> Signup and view all the answers

Which method initializes the shader program for WebGL?

<p>initShaders (D)</p> Signup and view all the answers

What does the gl.drawArrays function do?

<p>Renders the shapes defined by the vertex buffer. (B)</p> Signup and view all the answers

What will happen if the WebGL context cannot be created during setup?

<p>An alert will be shown indicating WebGL isn't available. (C)</p> Signup and view all the answers

Which data type is used for the position attribute in WebGL?

<p>vec2 (D)</p> Signup and view all the answers

When editing the HTML and JS files, what is specifically requested in the exercise?

<p>To change the color and display multiple triangles. (C)</p> Signup and view all the answers

What is a primary characteristic of JavaScript as mentioned in the notes?

<p>It is interpreted and object-oriented. (B)</p> Signup and view all the answers

What kind of triangle is rendered by the provided WebGL code?

<p>Equilateral triangle (C)</p> Signup and view all the answers

What aspect does computer graphics focus on?

<p>Generating images with a computer (C)</p> Signup and view all the answers

Which software is mentioned as being built on top of OpenGL?

<p>Maya (A)</p> Signup and view all the answers

What was the primary output device used in early computer graphics?

<p>Cathode Ray Tube (CRT) (D)</p> Signup and view all the answers

What development in computer graphics occurred between the years 1960-1970?

<p>Evolution of wireframe graphics (C)</p> Signup and view all the answers

Who recognized the potential of man-machine interaction in computer graphics?

<p>Ivan Sutherland (C)</p> Signup and view all the answers

What does the term 'Raster Graphics' refer to?

<p>Graphics produced using pixels (D)</p> Signup and view all the answers

Which development in computer graphics was emphasized during the 1980-1990 decade?

<p>Photorealism (C)</p> Signup and view all the answers

What was significant about the OpenGL API introduced in the 1990-2000 period?

<p>It allowed for real-time graphics rendering. (D)</p> Signup and view all the answers

What advancement in technology contributed to the growth of photorealism in computer graphics between 2000-2010?

<p>Programmable graphics pipelines (C)</p> Signup and view all the answers

What is a defining characteristic of the graphics environment from 2011 onwards?

<p>Increase of graphics in mobile and embedded systems (B)</p> Signup and view all the answers

What are the key components for forming an image in computer graphics?

<p>Objects, viewer, light sources (B)</p> Signup and view all the answers

Which aspect of light is emphasized in relation to the visual system?

<p>Wavelengths causing visual reactions (C)</p> Signup and view all the answers

What technique in image formation involves following rays from a point source?

<p>Ray tracing (D)</p> Signup and view all the answers

What was a characteristic of computers during the early days of computer graphics?

<p>They were slow, expensive, and unreliable. (C)</p> Signup and view all the answers

Flashcards

What are the attributes of a color image?

Color images are comprised of hue, saturation, and lightness. They are created by simulating the human eye's response to color.

What are the primary colors in additive color models?

The three primary colors of light are red, green, and blue. Combining these in different proportions creates a vast range of colors.

What are the primary colors in subtractive color models?

The three primary colors of pigments or inks are cyan, magenta, and yellow. These colors subtract specific wavelengths of light, creating different shades.

How does a pinhole camera work?

A pinhole camera uses a small hole to project an image onto a surface. This creates a simple and inverted projection of the scene.

Signup and view all the flashcards

What is WebGL?

WebGL is a JavaScript library that allows developers to write 3D graphics applications within web browsers.

Signup and view all the flashcards

What is the purpose of the vPosition attribute in WebGL shaders?

The vPosition attribute holds vertex position data. This data is used to calculate the final position of each vertex.

Signup and view all the flashcards

What is the purpose of the gl_Position variable in WebGL shaders?

The gl_Position variable represents the final position of a vertex in clip space. It is the output of the vertex shader.

Signup and view all the flashcards

What is the purpose of the gl_FragColor variable in WebGL shaders?

The gl_FragColor variable sets the color of a fragment. It is the output of the fragment shader.

Signup and view all the flashcards

JS Data Types

JavaScript's core data types include numbers, strings, and booleans, allowing for flexible data representation.

Signup and view all the flashcards

JS Number Type

JavaScript uses a single 32-bit floating-point number type for both integers and decimals, which can lead to potential issues in loops and equality comparisons.

Signup and view all the flashcards

JS Arrays as Objects

JavaScript arrays are objects, meaning they inherit methods that allow for dynamic manipulation, like adding or removing elements, without the need for explicit loops or indexing.

Signup and view all the flashcards

Typed Arrays

Typed arrays in JavaScript provide a way to work with data in a way similar to C-style arrays, allowing for efficient memory management and data transfer to the GPU.

Signup and view all the flashcards

Minimalist Approach

The minimalist approach in JavaScript graphics programming focuses on core JavaScript and HTML, avoiding unnecessary libraries and frameworks, emphasizing simplicity and efficiency in graphics development.

Signup and view all the flashcards

What is Computer Graphics?

Creating images with computers, encompassing hardware, software, and applications.

Signup and view all the flashcards

Cathode Ray Tube (CRT)

A display device that uses an electron beam to illuminate a screen coated with phosphors.

Signup and view all the flashcards

Display Processor

A specialized computer that handles the display refresh, freeing the host computer for other tasks.

Signup and view all the flashcards

Wireframe Graphics

Drawing only the outlines of objects, creating a skeletal representation.

Signup and view all the flashcards

Raster Graphics

Representing images as a grid of pixels, forming a continuous image.

Signup and view all the flashcards

GKS (Graphical Kernel System)

A standard for 2D graphics, developed in Europe.

Signup and view all the flashcards

Core (Computer Graphics Standards)

A standard for 3D graphics, developed in North America.

Signup and view all the flashcards

OpenGL API

A software interface for rendering 2D and 3D graphics.

Signup and view all the flashcards

Ray Tracing

Following rays of light from a point source to determine how they interact with objects and create an image.

Signup and view all the flashcards

Geometric Optics

Describing the behavior of light as it interacts with objects, using mathematical equations.

Signup and view all the flashcards

Elements of Image Formation

The objects, the viewer and the light sources that contribute to an image.

Signup and view all the flashcards

Light

The portion of the electromagnetic spectrum that our eyes can perceive.

Signup and view all the flashcards

Ray Tracing and Geometric Optics

A process of creating digital images by tracing paths of light.

Signup and view all the flashcards

Photorealism

Simulating the interaction of light with materials to create realistic images.

Signup and view all the flashcards

Augmented Reality (AR)

The ability to experience computer-generated environments that blend with the real world.

Signup and view all the flashcards

JavaScript

A programming language commonly used for web development, allowing for dynamic and interactive web pages.

Signup and view all the flashcards

window.onload

A function that is executed when a web page is fully loaded.

Signup and view all the flashcards

HTML5 canvas

A method used to draw 2D shapes on a web page. It uses a coordinate system similar to a graph paper.

Signup and view all the flashcards

render()

A function that is executed repeatedly to update and redraw the content of a canvas.

Signup and view all the flashcards

WebGLUtils.setupWebGL

A library for interacting with WebGL, a low-level API for drawing 3D graphics directly on a canvas.

Signup and view all the flashcards

gl.viewport

A key technique for setting the drawing region and size within a canvas.

Signup and view all the flashcards

gl.clear

A function used to clear the content of a canvas, preparing it for new drawings.

Signup and view all the flashcards

gl.drawArrays(gl.TRIANGLES, 0, 3)

A function that draws triangles onto a canvas using the data specified in the vertex buffer.

Signup and view all the flashcards

Study Notes

Course Information

  • Course title: Computer Graphics & Visualization
  • Course code: CSE-423
  • Lecturer: Dr. Reda Elbasiony
  • Semester: Fall, 2024
  • University: EGYPT-JAPAN UNIVERSITY OF SCIENCE AND TECHNOLOGY (E-JUST)
  • Website: www.ejust.edu.eg

What is Computer Graphics?

  • Computer graphics involves all aspects of creating images with a computer, including hardware, software, and applications.
  • Computer graphics deals with producing images using a computer.

Preliminary Answer

  • Application: The image is an artistic representation of the sun for a planetarium animation.
  • Software: Maya, built on OpenGL, is used for modeling and rendering.
  • Hardware: A PC with a graphics card was used for modeling and rendering.

Basic Graphics System

  • Input devices send data to the processor (CPU).
  • The CPU sends data to the graphics processor (GPU).
  • The GPU processes the data and displays it on the output device.
  • The frame buffer stores and displays the image.
  • The CPU handles input and processing tasks.
  • The GPU handles image display tasks.

Computer Graphics: 1950-1960

  • The earliest computer graphics involved strip charts and pen plotters.
  • Simple displays used A/D converters to display images on CRTs.
  • Cost of CRT refresh was high, and computers were slow, expensive, and unreliable.

Cathode Ray Tube (CRT)

  • CRTs used an electron gun and a phosphor-coated screen.
  • The electron gun emits electrons that strike the phosphor.
  • Focusing mechanisms ensure the electron beam strikes the correct part of the phosphor to create the desired image.

Shadow Mask CRT

  • Shadow mask CRTs use a shadow mask to precisely direct the electron beams from separate color guns to the appropriate areas of the phosphor dots on the screen.
  • This produces images with color.

Computer Graphics: 1960-1970

  • Wireframe graphics involved displaying only lines, such as those in a sketchpad.
  • Display processors were used for processing graphics.
  • Storage tubes were used to store graphics.
  • Wireframe representation, e.g., sun object.

Sketchpad

  • Ivan Sutherland's PhD thesis at MIT showed the potential of man-machine interaction via a sketchpad.
  • The sketchpad showed a new display system using a light pen.
  • Computer graphics algorithms were invented by Sutherland.

Display Processor (DPU)

  • A dedicated display processor takes over the task of refreshing the display.
  • Graphics are stored in the display list.
  • The host computer compiles the display list and sends it to the DPU.

Computer Graphics: 1970-1980

  • Raster graphics were introduced, using graphic standards such as IFIPS and GKS.
  • Raster graphics became a standard graphics method.
  • Workstations and PCs improved graphics capabilities.

Raster Graphics

  • Raster Graphics produces images as an array of pixels within a frame buffer.
  • Raster graphics allows filling in polygons.

Computer Graphics: 1980-1990

  • Realism in computer graphics is enhanced with smooth shading, environment mapping, and bump mapping.

Special Purpose Hardware

  • Silicon Graphics geometry engine.
  • VLSI implementation of graphics pipelines.
  • PHIGS (Programmer's Hierarchical Interactive Graphics System) standard.
  • RenderMan standard.
  • Networked graphics, such as X Window System.
  • Human-computer interfaces (HCI).

Computer Graphics: 1990-2000

  • OpenGL API.
  • Completely computer-generated feature-length movies.
  • New hardware capabilities (texture mapping, blending, accumulation & stencil buffers).

Computer Graphics: 2000-2010

  • Photorealism, with graphics cards dominating the PC market (Nvidia, ATI).
  • Computer graphics routines for movie industries (Maya, Lightwave).
  • Programmable pipelines.
  • New display technologies.

Generic Flat Panel Display

  • Light emitting elements are arranged in a grid pattern.

Computer Graphics 2011-

  • Graphics became ubiquitous in cell phones and embedded systems.
  • OpenGL ES and WebGL.
  • Enhanced reality.
  • 3D movies and TV.

Image Formation

  • Images are two-dimensional representations of objects, viewers, and light sources.
  • Methods for creating images are analogous to how physical imaging systems (cameras, microscopes, telescopes) create images.
  • Formation of images involves capturing and displaying light from scenes.

Elements of Image Formation

  • Objects: 3D representations of the scene elements.
  • Viewer: 3D location and perspective of the image viewer.
  • Light Sources: Light coming from sources in the scene to illuminate elements.
  • Interactions: How light interacts with the scene materials (objects and surfaces).
  • Independence of objects: Each object in the scene has separate characteristics that can be analyzed.
  • Independence of Viewer: Various perspectives can be shown.
  • Independence of light sources: Various light sources will produce different effects.

Light

  • Light is part of the electromagnetic spectrum that reacts within visual systems.
  • Light wavelengths are between 350-750 nanometers.
  • Long wavelengths appear red while short wavelengths appear blue.

Ray Tracing and Geometric Optics

  • Using trigonometry, computer graphics create images using rays of light following from a point to objects to a camera lens.

Luminance and Color Images

  • Luminance images are monochromatic (gray levels).
  • Analogous to black and white film or TV.
  • Color images use hue, saturation, and lightness.

Three-Color Theory

  • Human visual systems use two types of sensors: rods (monochrome, used for low light) and cones (color vision)
  • Cones have three types for color vision sensitivity (red, green, and blue).
  • Computer graphics only needs three primary colors to generate colors (red, green, and blue).

Additive and Subtractive Color

  • Additive: Mixing primary colors (red, green, blue) to form compound colors. e.g. CRTs, projector systems
  • Subtractive: Mixing light with filters of cyan, magenta, yellow. e.g. pigments, printing

Pinhole Camera

  • Trigonometry determines the projection of a 3D point onto a 2D plane.
  • Equations of simple perspective are used.

Coding in WebGL

  • WebGL can run on recent browsers (Chrome, Firefox, Safari).
  • Scripts are written in JavaScript to form display elements.
  • JavaScript code runs within the browser and uses the local resources.

Example Code

  • Code example of a triangle using vertex and fragment shaders.

HTML File

  • Example HTML to set up canvas element and link JavaScript sources.

JS File

  • Example JavaScript code using WebGL to draw a triangle.

JS File (cont)

  • Further example of JS code for WebGL intial setup and display.

JS File (cont) 2

  • Example code showing variables and functions to display data in the screen

Exercise

  • Exercise: Run and edit provided files (triangle.html, triangle.js) to use WebGL to render.

JavaScript Notes

  • JavaScript is the language for Web browsers.
  • It is interpreted and object-oriented programming languages.
  • Refer to online resources, including tutorials and books, for specific information.

JS Notes

  • JavaScript engines in browsers are now fast enough to handle graphics data.
  • JS is "too big" for simple use in cases where it isn't needed.
  • Focus on graphic parts using JavaScript and avoid unnecessary structures.

JS Notes 2

  • JS has limited data types.
  • Number has a single 32-bit floating-point type.
  • Be mindful of potential issues with loops.

JS Arrays

  • JavaScript arrays are objects with methods, unlike C-style arrays.

Typed Arrays

  • Typed arrays in JavaScript are similar to C arrays.
  • Standard arrays are preferred to convert them into typed arrays.

A Minimalist Approach

  • Only use core elements of JS and HTML when developing.
  • Do not employ extra or varied packages unless absolutely needed.
  • No additional packages like JQuery.
  • Focus solely on core graphics functionality.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Description

Test your knowledge on JavaScript arrays, operators, and graphics coding. Additionally, explore concepts related to color theory and the human visual system. This quiz is perfect for those delving into programming and visual sciences.

More Like This

JavaScript Editing Techniques
3 questions
JavaScript Flashcards
95 questions

JavaScript Flashcards

JubilantUvarovite avatar
JubilantUvarovite
Basic JavaScript Functions Quiz
6 questions

Basic JavaScript Functions Quiz

SustainableAntigorite1088 avatar
SustainableAntigorite1088
JavaScript Class Definition
12 questions
Use Quizgecko on...
Browser
Browser