Visualizing Data by Ben Fry

Visualizing Data by Ben Fry

Author:Ben Fry [Ben Fry]
Language: eng
Format: epub, pdf
Tags: COMPUTERS / Computer Graphics
ISBN: 9780596554729
Publisher: O'Reilly Media
Published: 2008-12-16T16:00:00+00:00


Changing How Points Are Drawn When Zooming (Refine)

A bit of time spent playing with the zoom mode makes it clear that points are quickly lost because the single pixels spread out and become difficult to see. This problem springs from how we perceive images, and it requires that points be handled differently as the zoom shifts.

To resolve the issue, points should become larger as more digits are typed. Even better would be to add more information along the way, keeping the density of information on the screen constant as the zoom occurs. For instance, after typing three digits, map data depicting state outlines and major interstates could be included. Although the data retrieval and formatting for that enhancement are too complicated to show in this chapter, we can at least implement one simple way to add a little more information: showing the remaining possibilities for the last digit after the user has typed the first four.

An updated version of the draw( ) method found inside the Place class handles two refinements: changing points to rectangles and showing possible final digits:

void draw( ) { float xx = TX(x); float yy = TY(y); if ((xx < 0) || (yy < 0) || (xx >= width) || (yy >= height)) return; if ((zoomDepth.value < 2.8f) || !zoomEnabled) { // show simple dots set((int)xx, (int)yy, faders[matchDepth].colorValue); } else { // show slightly more complicated dots noStroke( ); fill(faders[matchDepth].colorValue); if (matchDepth == typedCount) { if (typedCount == 4) { // on the fourth digit, show possibilities text(code % 10, TX(x), TY(y)); } else { // show a larger box for selections rect(xx, yy, zoomDepth.value, zoomDepth.value); } } else { // show a slightly smaller box for unselected rect(xx, yy, zoomDepth.value-1, zoomDepth.value-1); } } }

Figure 6-5 shows a selection, with the adjacent locations being drawn using rectangles instead of single pixels as a result of the new draw( ) method.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.