Created
June 29, 2016 04:38
-
-
Save rb-roomba/5f88368fa1e68eca39a87c5de84519f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head></head> | |
<body> | |
<br> | |
<canvas id="canvas1" style="margin-top:20px;"></canvas> | |
<script type="text/javascript" src="hue.js"></script> | |
<script type="text/javascript" src="color.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var c1 = document.getElementById("canvas1"); | |
c1.width = 900; | |
c1.height = 600; | |
var ctx = c1.getContext("2d"); | |
// center X, Y | |
var cx = 250; | |
var cy = 300; | |
// draw circular sector | |
function draw_csector(cx, cy, radius, theta1, theta2){ | |
ctx.beginPath(); | |
ctx.moveTo(cx, cy) // center | |
ctx.arc(cx, cy, radius, -theta1, -theta2, true); | |
ctx.closePath(); | |
ctx.fill(); | |
} | |
// draw circular histogram | |
for (i=0; i<180; i++){ | |
radius = Math.pow(data[i], 0.5)*600 | |
ctx.fillStyle = "hsl(" + 2*i + ", 100%, 50%)" | |
draw_csector(cx, cy, radius, 2*i*Math.PI/180, 2*(i+1)*Math.PI/180); | |
} | |
// draw gray circles | |
ctx.lineWidth = 0.5; | |
ctx.strokeStyle = "rgba(80, 80, 80, 0.3)"; | |
for (var i=0; i<12; i++){ | |
ctx.beginPath(); | |
ctx.arc(cx, cy, 50*(i+1), 0, 2*Math.PI, true); | |
ctx.stroke(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data={"0": 1.0, "1": 0.047014447435875774, "2": 0.033367172513780123, "3": 0.0061570926359083358, "4": 0.017618899156682574, "5": 0.0006573299197228156, "6": 0.0011917944338899649, "7": 0.00099367396743145269, "8": 0.0087280512471606571, "9": 0.00078633859555626547, "10": 0.0075316493605623548, "11": 0.0029718069968776828, "12": 0.0073243139886871676, "13": 0.00098292324444533173, "14": 0.0012347973258344481, "15": 0.012897795948206088, "16": 0.0050098369115323003, "17": 0.0037842544911145274, "18": 0.0014590266909735394, "19": 0.0014851355896541186, "20": 0.0034617328015309028, "21": 0.02001016711230973, "22": 0.02036033351814338, "23": 0.016399460006542584, "24": 0.15663803390778031, "25": 0.042101367031218563, "26": 0.059918386654359647, "27": 0.026500532160787814, "28": 0.006241562602227857, "29": 0.00063582847375057399, "30": 0.0025125975436133792, "31": 0.0006404359264589115, "32": 0.00044385127756984514, "33": 0.00059896885208387412, "34": 0.00067268809541727397, "35": 0.00027183970979191205, "36": 0.00019504883131962053, "37": 0.00071261935222286551, "38": 0.00020733537187518717, "39": 0.00048071089923654506, "40": 0.0003409515004169745, "41": 0.0001535817569445831, "42": 0.00037473948694478275, "43": 0.00056671668312551166, "44": 0.00049914071006989505, "45": 0.00029948442604193706, "46": 0.00026108898680579125, "47": 0.00027951879763914124, "48": 0.0058591440274358454, "49": 0.00016126084479181225, "50": 0.0002887337030558162, "51": 0.00032712914229196202, "52": 0.00035784549368087859, "53": 0.0063659638253529697, "54": 0.00050221234520878672, "55": 0.013304787604109233, "56": 0.00045613781812541178, "57": 0.01559776323529186, "58": 0.00020426373673629552, "59": 0.00077865950770903628, "60": 0.04098022020552311, "61": 0.0058745022031303036, "62": 7.0647608194508227e-05, "63": 0.007385746691465001, "64": 0.0054521523715326996, "65": 0.021464586350574934, "66": 0.027686183324399996, "67": 0.017239552217029452, "68": 0.00040699165590314521, "69": 0.025528359639328601, "70": 0.0044369769581290054, "71": 0.020435588579046225, "72": 0.013289429428414774, "73": 0.018428275015780527, "74": 0.091640698551263292, "75": 0.047404545098515015, "76": 0.02437188900953589, "77": 0.0059712587100053905, "78": 0.052412846192477873, "79": 0.016826417290848526, "80": 0.00011365050013899149, "81": 0.0059835452505609572, "82": 0.026867592559885366, "83": 0.012151388609455414, "84": 6.9111790625062391e-05, "85": 9.2149054166749863e-05, "86": 7.2183425763954051e-05, "87": 9.2149054166749863e-05, "88": 0.0047272464787542681, "89": 0.00023190845298632048, "90": 0.00033173659500029947, "91": 0.00013975939881957062, "92": 0.00014897430423624561, "93": 0.00020579955430574133, "94": 0.024957035503494752, "95": 0.0056164848514634038, "96": 0.0059666512572970534, "97": 0.00032712914229196202, "98": 0.019031851320572737, "99": 0.037481627782325506, "100": 0.022811498358978926, "101": 0.012132958798622065, "102": 0.017208835865640537, "103": 0.061518708561722202, "104": 0.045371122636568735, "105": 0.037109959930519611, "106": 0.059417710126720306, "107": 0.022671738960159355, "108": 0.019855049537795703, "109": 0.066616087074712921, "110": 0.10282145045682893, "111": 0.083101552865144465, "112": 0.014912788599319018, "113": 0.022485905034256411, "114": 0.01374095979383185, "115": 0.00026416062194468292, "116": 0.0096833297753559644, "117": 2.9180533819470786e-05, "118": 0.0043048966471566641, "119": 2.3037263541687466e-05, "120": 0.028994699893567843, "121": 0.0032236810782667992, "122": 0.00018429810833349973, "123": 6.4504337916724893e-05, "124": 0.0058146053179219158, "125": 3.9931256805591604e-05, "126": 4.9146162222266592e-05, "127": 1.9965628402795802e-05, "128": 0.00047456762895876177, "129": 5.8361067638941573e-05, "130": 2.4573081111133296e-05, "131": 2.7644716250024956e-05, "132": 6.9111790625062391e-05, "133": 1.2286540555566648e-05, "134": 1.8429810833349972e-05, "135": 5.2217797361158252e-05, "136": 2.4573081111133296e-05, "137": 1.8429810833349972e-05, "138": 3.0716351388916616e-05, "139": 1.8429810833349972e-05, "140": 1.9965628402795802e-05, "141": 2.4573081111133296e-05, "142": 4.607452708337493e-06, "143": 1.0750722986120816e-05, "144": 1.8429810833349972e-05, "145": 1.6893993263904142e-05, "146": 2.6108898680579126e-05, "147": 1.5358175694458308e-05, "148": 9.214905416674986e-06, "149": 1.9965628402795802e-05, "150": 0.00018583392590294554, "151": 1.0750722986120816e-05, "152": 9.214905416674986e-06, "153": 4.607452708337493e-06, "154": 8.1398331180629045e-05, "155": 1.5358175694458308e-05, "156": 1.5358175694458308e-05, "157": 0.00026723225708357459, "158": 0.00014743848666679978, "159": 2.7644716250024956e-05, "160": 0.00015051012180569142, "161": 3.3787986527808284e-05, "162": 5.3753614930604082e-05, "163": 5.5289432500049912e-05, "164": 2.4573081111133296e-05, "165": 0.00020887118944463301, "166": 0.00026108898680579125, "167": 5.2217797361158252e-05, "168": 5.2217797361158252e-05, "169": 8.7541601458412366e-05, "170": 0.00030102024361138284, "171": 0.011798150568482874, "172": 0.00017354738534737889, "173": 0.016648262452792807, "174": 0.10694358481322154, "175": 0.0081813001924379413, "176": 0.079129928630557553, "177": 0.28528579261241033, "178": 0.15076660333978889, "179": 0.10680382541440198} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment