Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
To keep track of what they draw, many applications, such as drawing applications, computer-aided design systems, and games, maintain a list of display objects. Often, such applications let users edit their display objects; for example, CAD applications let users select, move, and resize elements of the design.
Users typically select display objects with either mouse clicks or finger touches. To facilitate selection, among other things, the Canvas API provides a pointInPath() method that returns true if a specified point lies within the current path. In this section, we make use of that method through an extension of the polygon application discussed in Section 2.11.1, “Polygon Objects,” on p. 147 that lets users drag polygons.