function printTagCloud($tags, $method='point') { //method above can be either point or area //point is typical tag cloud scaling //area scales tags approximately, such that *overall tag area* is proportional to the tag occurrences $max_area = 12000; $max_size = 55; // max font size in pixels $min_size = 12; // min font size in pixels $max_qty = max(array_values($tags)); $min_qty = min(array_values($tags)); $spread = $max_qty - $min_qty; if ($spread == 0) { // we don't want to divide by zero $spread = 1; } $step = ($max_size - $min_size) / ($spread); foreach ($tags as $key => $value) { if ($method == 'area') { $area = ($value / $max_qty) * $max_area; $size = sqrt((2*$area)/strlen($key)); } else if ($method == 'point') { $size = round($min_size + (($value - $min_qty) * $step)); } print '' . $key . ' '; } } /* FILE ARCHIVED ON 21:02:22 Jun 23, 2013 AND RETRIEVED FROM THE INTERNET ARCHIVE ON 11:39:51 Apr 22, 2020. JAVASCRIPT APPENDED BY WAYBACK MACHINE, COPYRIGHT INTERNET ARCHIVE. ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. SECTION 108(a)(3)). */ /* playback timings (ms): load_resource: 391.678 LoadShardBlock: 184.006 (3) RedisCDXSource: 8.678 PetaboxLoader3.resolve: 144.293 exclusion.robots: 0.309 PetaboxLoader3.datanode: 196.714 (4) captures_list: 215.594 CDXLines.iter: 18.011 (3) exclusion.robots.policy: 0.289 esindex: 0.022 */