Skip to main content

2D Graphics

  • Chapter
  • First Online:
  • 2177 Accesses

Abstract

Objects can be drawn, edited and transformed in 2D and 3D spaces. One can create objects ranging from simple 2D primitives to complex 3D environments. Planar objects, sometimes called 2D shapes, are created on a single plane (usually the \(xy\)-plane) while 3D objects utilize all three dimensions of space. Focusing on planar objects, 2D primitives like lines, circles, etc. may be used to create more complex shapes. Thus, it is important to know how to create/draw such primitives as groups of pixels utilizing their equations; a process that is referred to as scan conversion (Working with graphics as mathematical equations is referred to as vector graphics while working with them as a series of pixels is called raster graphics .). A line can be scan-converted (i.e., expressed as a set of pixels that approximate its path) if we know its endpoints, which define its equation. Likewise, a circle is scan-converted if we know the location of its center as well as its radius; i.e., components that define its equation. The same concept applies to other primitives. Different operations may be applied to objects in 2D space. For example, an object can be clipped using a clip window or a clip polygon to preserve a part of that object. (Some systems refer to the clipping process as trimming .) Other operations that may be applied to such objects are called transformations. Such operations include translating (i.e., moving), rotating, scaling, stretching, reflecting (i.e., mirroring) and shearing the objects. In this chapter, we will look at how to create 2D primitives like lines and circles. Also, we will talk about polygons and polylines and how to clip line segments and polygons. We will dedicate Chap. 3 to talk about different transformations in 2D space. 3D object creation and operations will be discussed in subsequent chapters. Before starting the discussion, we should mention that there are two different Cartesian coordinate systems that could be used. These are left-handed and right-handed coordinate systems (see Sect. B.1.1). In the right-handed coordinate system, the origin is at the lower left corner of the screen and the \(y\)-axis is pointing upwards. On the contrary, in the left-handed coordinate system, the origin is at the upper left corner of the screen and the \(y\)-axis is pointing downwards. In this chapter, we will show a line drawn in both systems only once. Afterwards, we will stick to the right-handed coordinate system to avoid confusion. (The usual convention working with raster images is to use the left-handed coordinate system where the origin is at the upper left corner and the \(y\)-axis is pointing downwards. However, switching between the left- and right-hand coordinate system is easy and can be done using Eq. (B.7).)

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    \([0^\circ , 360^\circ )\) represents a half-open interval where \(0^\circ \) is included while \(360^\circ \) is excluded.

References

  • Aken, J.V. 1984. An efficient ellipse-drawing algorithm. IEEE Computer Graphics and Applications 4(9): 24–35.

    Article  Google Scholar 

  • Bresenham, J.E. 1965. Algorithm for computer control of a digital plotter. IBM Systems Journal 4(1): 25–30.

    Article  Google Scholar 

  • Cyrus, M., and J. Beck. 1978. Generalized two- and three-dimensional clipping. Computers and Graphics 3(1): 23–28.

    Article  Google Scholar 

  • Foley, J.D., A. van Dam, S.K. Feiner, and J. Hughes. 1995. Computer Graphics: Principles and Practice in C, 2nd ed. The systems programming series. Addison-Wesley, Reading, MA.

    Google Scholar 

  • Liang, Y.-D., and B.A. Barsky. 1984. A new concept and method for line clipping. ACM Transactions on Graphics (TOG) 3(1): 1–22.

    Article  MATH  Google Scholar 

  • Maillot, P.-G. 1992. A new, fast method for 2d polygon clipping: analysis and software implementation. ACM Transactions on Graphics (TOG) 11(3): 276–290.

    Article  MATH  Google Scholar 

  • Nicholl, T.M., D.T. Lee, and R.A. Nicholl. 1987. An efficient new algorithm for 2-d line clipping: its development and analysis. ACM SIGGRAPH Computer Graphics 21(4): 253–262.

    Article  Google Scholar 

  • Pitteway, M. 1967. Algorithm for drawing ellipses or hyperbolae with a digital plotter. Computer Journal 10(3): 282–289.

    Article  Google Scholar 

  • Sutherland, I.E., and G.W. Hodgman. 1974. Reentrant polygon clipping. Communications of the ACM 17(1): 32–42.

    Article  MATH  Google Scholar 

  • Van Aken, J., and M. Novak. 1985. Curve-drawing algorithms for raster displays. ACM Transactions on Graphics 4(2): 147–169.

    Article  Google Scholar 

  • Weiler, K., and P. Atherton. 1977. Hidden surface removal using polygon area sorting. ACM SIGGRAPH Computer Graphics 11(2): 214–222.

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Rimon Elias .

Rights and permissions

Reprints and permissions

Copyright information

© 2014 Springer International Publishing Switzerland

About this chapter

Cite this chapter

Elias, R. (2014). 2D Graphics. In: Digital Media. Springer, Cham. https://doi.org/10.1007/978-3-319-05137-6_2

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-05137-6_2

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-05136-9

  • Online ISBN: 978-3-319-05137-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics