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
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.
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8303)
Azure Data and AI Architect Handbook by Olivier Mertens & Breght Van Baelen(6754)
Building Statistical Models in Python by Huy Hoang Nguyen & Paul N Adams & Stuart J Miller(6730)
Serverless Machine Learning with Amazon Redshift ML by Debu Panda & Phil Bates & Bhanu Pittampally & Sumeet Joshi(6612)
Data Wrangling on AWS by Navnit Shukla | Sankar M | Sam Palani(6395)
Driving Data Quality with Data Contracts by Andrew Jones(6341)
Machine Learning Model Serving Patterns and Best Practices by Md Johirul Islam(6104)
Learning SQL by Alan Beaulieu(5997)
Weapons of Math Destruction by Cathy O'Neil(5783)
Big Data Analysis with Python by Ivan Marin(5371)
Data Engineering with dbt by Roberto Zagni(4370)
Solidity Programming Essentials by Ritesh Modi(4020)
Time Series Analysis with Python Cookbook by Tarek A. Atwan(3878)
Pandas Cookbook by Theodore Petrou(3586)
Blockchain Basics by Daniel Drescher(3298)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2909)
Feature Store for Machine Learning by Jayanth Kumar M J(2816)
Learn T-SQL Querying by Pam Lahoud & Pedro Lopes(2798)
Mastering Python for Finance by Unknown(2745)
