Graphics Programming using Allegro

Practice Test

Drawing Primitives

Published:  September 8, 2008
By Richard G. Baldwin

File: Allegro00120PracticeTest


Questions

1.  True or False:  When calling the function shown below to create a graphics window on the screen, you can cause the dimensions of the window to be anything that you want provided that it will fit within the overall dimensions of the screen on all Allegro-compatible computers.


  set_gfx_mode(GFX_AUTODETECT_WINDOWED,400,400,0,0);

Answer and Explanation

2.  True or False:  You can cause an Allegro graphics window to have a solid background color by calling the function named clear_to_color.

Answer and Explanation

3.  True or False:  When calling the function shown below to create a graphics window on the screen, the horizontal dimension that you specify must be divisible by four on some Allegro-compatible computers.


  set_gfx_mode(GFX_AUTODETECT_WINDOWED,400,400,0,0);

Answer and Explanation

4.  True or False:  You can cause an Allegro graphics window to have a solid white background color by calling the function named clear_to_white.

Answer and Explanation

5.  True or False:  The most appropriate way to control the color of an individual pixel in an Allegro graphics window is to call the function named setPixel.

Answer and Explanation

6.  True or False:  The most appropriate way to control the color of an individual pixel in an Allegro graphics window is to call the function named putpixel.

Answer and Explanation

7.  True or False:  The most appropriate way to control the color of an individual pixel in an Allegro graphics window is to draw an extremely small colored circle at the location of the pixel.

Answer and Explanation

8.  True or False:  When you call the Allegro circle function to draw a circle, you specify the coordinates of two diagonal corners of a rectangle in which the circle will be inscribed.  If the rectangle is not a square, the result will be an ellipse.

Answer and Explanation

9.  True or False:  When you call the Allegro circle function to draw a circle, you specify the coordinates of the center of the circle along with the radius of the circle and some other parameters as well.

Answer and Explanation

10.  True or False:  The floodfill function shown below cannot be used to fill an area between two previously drawn geometric objects (such as concentric circles) with a solid color.

  floodfill(screen,5,200,makecol(0,0,255));

Answer and Explanation

11.  True or False:  The behavior of the floodfill function is similar to the behavior of similar features in paint programs, filling the entire area around a point that is inside a closed contour with a specified color.

Answer and Explanation

12.  True or False:  The Allegro function that is used to draw a circle that is filled with a specified color is named filledCircle.

Answer and Explanation

13.  True or False:  The Allegro function that is used to draw a circle that is filled with a specified color is named circlefill.

Answer and Explanation

14.  True or False:  When you call the rect function shown below to draw a rectangle, among other things, you specify the coordinates of the upper-left corner of the rectangle along with the width and the height of the rectangle.

  //Draw an empty blue rectangle.
  rect(screen,150,75,250,125,makecol(0,0,255));

Answer and Explanation

15.  True or False:  When you call the rect function shown below to draw a rectangle, among other things, you specify the coordinates of two diagonal corners of the rectangle.

  //Draw an empty blue rectangle.
  rect(screen,150,75,250,125,makecol(0,0,255));

Answer and Explanation

16True or False:  The Allegro function that is used to draw a rectangle that is filled with a specified color is named filledRect.

Answer and Explanation

17True or False:  The Allegro function that is used to draw a rectangle that is filled with a specified color is named rectfill.

Answer and Explanation

18True or False:  When you call the line function to draw a straight line, among other things, you specify the coordinates of the end points of the line.

Answer and Explanation

19True or False:  When you call the line function to draw a straight line, among other things, you specify the coordinates of the beginning point of the line and the length of the line.

Answer and Explanation

20True or False:  The Allegro function named triangle draws a triangle that is filled with a specified color.

Answer and Explanation

21True or False:  The Allegro function named triangle draws an empty triangle with an outline that is a specified color.

Answer and Explanation



Copyright 2008, Richard G. Baldwin.  Reproduction in whole or in part in any form or medium without express written permission from Richard Baldwin is prohibited.

Richard Baldwin is a college professor (at Austin Community College in Austin, TX) and private consultant whose primary focus is a combination of Java, C#, and XML. In addition to the many platform and/or language independent benefits of Java and C# applications, he believes that a combination of Java, C#, and XML will become the primary driving force in the delivery of structured information on the Web.

Richard has participated in numerous consulting projects and he frequently provides onsite training at the high-tech companies located in and around Austin, Texas.  He is the author of Baldwin's Programming Tutorials, which have gained a worldwide following among experienced and aspiring programmers. He has also published articles in JavaPro magazine.

In addition to his programming expertise, Richard has many years of practical experience in Digital Signal Processing (DSP).  His first job after he earned his Bachelor's degree was doing DSP in the Seismic Research Department of Texas Instruments.  (TI is still a world leader in DSP.)  In the following years, he applied his programming and DSP expertise to other interesting areas including sonar and underwater acoustics.

Richard holds an MSEE degree from Southern Methodist University and has many years of experience in the application of computer technology to real-world problems.

Baldwin@DickBaldwin.com

 


Answers and Explanations


Answer 21

False - unlike rect and circle, which draw empty geometric objects, triangle draws a filled object.

Explanation 21

Back to Question 21
 


Answer 20

True

Explanation 20

Back to Question 20
 


Answer 19

False - you specify the two end points of the line

Explanation 19

Back to Question 19


Answer 18

True

Explanation 18

Back to Question 18


Answer 17

True

Explanation 17

Back to Question 17


Answer 16

False - rectfill, not filledRect

Explanation 16

Back to Question 16


Answer 15

True

Explanation 15

Back to Question 15


Answer 14

False - you specify coordinates of diagonal corners

Explanation 14

Back to Question 14


Answer 13

True

Explanation 13

Back to Question 13


Answer 12

False - circlefill, not filledCircle

Explanation 12

Back to Question 12


Answer 11

True

Explanation 11

Back to Question 11


Answer 10

False - the function can be used for that purpose

Explanation 10

Back to Question 10


Answer 9

True

Explanation 9

Back to Question 9


Answer 8

False

Explanation 8

Back to Question 8


Answer 7

False

Explanation 7

Back to Question 7


Answer 6

True

Explanation 6

Back to Question 6


Answer 5

False  putpixel, not setPixel

Explanation 5

Back to Question 5


Answer 4

False

Explanation 4

Back to Question 4


Answer 3

True

Explanation 3

Back to Question 3


 

Answer 2

True

Explanation 2

Back to Question 2


Answer 1

False

Explanation 1

Back to Question 1


Copyright 2008, Richard G. Baldwin.  Reproduction in whole or in part in any form or medium without express written permission from Richard Baldwin is prohibited.

Richard Baldwin is a college professor (at Austin Community College in Austin, TX) and private consultant whose primary focus is a combination of Java, C#, and XML. In addition to the many platform and/or language independent benefits of Java and C# applications, he believes that a combination of Java, C#, and XML will become the primary driving force in the delivery of structured information on the Web.

Richard has participated in numerous consulting projects and he frequently provides onsite training at the high-tech companies located in and around Austin, Texas.  He is the author of Baldwin's Programming Tutorials, which have gained a worldwide following among experienced and aspiring programmers. He has also published articles in JavaPro magazine.

In addition to his programming expertise, Richard has many years of practical experience in Digital Signal Processing (DSP).  His first job after he earned his Bachelor's degree was doing DSP in the Seismic Research Department of Texas Instruments.  (TI is still a world leader in DSP.)  In the following years, he applied his programming and DSP expertise to other interesting areas including sonar and underwater acoustics.

Richard holds an MSEE degree from Southern Methodist University and has many years of experience in the application of computer technology to real-world problems.

Baldwin@DickBaldwin.com

 

-end-