Commit 66a6ea80 authored by Zach Knox's avatar Zach Knox

Merge branch 'issue4' into 'master'

Issue4 pt:1

See merge request !8
parents 567984a6 d4ba0495
//NOTES
//This file's main function will be called for each time of weather, evrey update.
//therefore this file needs to be optimiezed to be as fast as possible
//this is not implemented yet and just a proof of concept to start work
// will be implemented once we get live numbers to frontend
//HOW TO USE:
//Pass colorMain(type,deg);
//type(boolean) = farenheit or celcius
// true = farenheit
// false = celcius
//deg = degrees
//you will have a color in #111111 format returned
//main function
function colorMain(type,deg) {
if (type = true) {
return degToColor(deg);
} else {
return degToColor(convertToF(deg));
}
}
//deg needs to be farenheit
function degToColor(deg) {
switch (true) {
case deg < 10:
text = "#6b469c";
break;
case deg < 20:
text = "#a0c9c1";
break;
case deg < 30:
text = "#3ec2cf";
break;
case deg < 40:
text = "#007dc5";
break;
case deg < 50:
text = "#425195";
break;
case deg < 60:
text = "#a39382";
break;
case deg < 70:
text = "#ffcc33";
break;
case deg < 80:
text = "#f7941e";
break;
case deg < 90:
text = "#f37021";
break;
case deg < 100:
text = "#ac1d37";
break;
case deg > 100:
text = "#a62380";
break;
default:
text = "#F433FF";
}
return text;
}
function convertToF(CDeg){ //a possible widely used function
Fdeg = Cdeg*(9/5)+32;
return Fdeg;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment