less copy protection, more size visualization
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

121 wiersze
4.5 KiB

  1. function makeState(name, height, width, area) {
  2. return {
  3. name: name,
  4. constructor: () => makeEntity(
  5. name,
  6. "State",
  7. {
  8. state: {
  9. attributes: {
  10. height: {
  11. name: "Height",
  12. power: 1,
  13. type: "length",
  14. base: height
  15. },
  16. width: {
  17. name: "Width",
  18. power: 1,
  19. type: "length",
  20. base: width
  21. },
  22. area: {
  23. name: "Area",
  24. power: 2,
  25. type: "area",
  26. base: area
  27. },
  28. },
  29. name: "State",
  30. image: {
  31. source: "./media/naturals/" + name.toLowerCase().replace(" ", "-") + ".svg"
  32. }
  33. }
  34. }
  35. )
  36. }
  37. }
  38. function makePlanet(name, diameter, mass, image) {
  39. return {
  40. name: name,
  41. constructor: () => makeObject(
  42. name,
  43. {
  44. body: {
  45. height: diameter,
  46. mass: mass,
  47. image: (image === undefined ? {
  48. source: "./media/naturals/planet-generic.svg"
  49. } : image),
  50. name: "Body"
  51. }
  52. }
  53. )
  54. };
  55. }
  56. function makeMountains() {
  57. const views = {};
  58. [
  59. ["Everest", 29029],
  60. ["K2", 28251],
  61. ["Kilimanjaro", 19341],
  62. ["Rainier", 14409],
  63. ["Pikes Peak", 14114],
  64. ["Fuji", 12388],
  65. ["Olympus", 9573],
  66. ].forEach(mountain => {
  67. views[mountain[0]] = {
  68. height: math.unit(mountain[1], "feet"),
  69. image: { source: "./media/naturals/mountain.svg" },
  70. name: mountain[0]
  71. }
  72. });
  73. return {
  74. name: "Mountains",
  75. constructor: () => makeObject(
  76. "Mountains",
  77. views
  78. )
  79. };
  80. }
  81. function makeNaturals() {
  82. const results = [];
  83. results.push(makePlanet("Mercury", math.unit(4879, "km"), math.unit(0.330e24, "kg")));
  84. results.push(makePlanet("Venus", math.unit(12104, "km"), math.unit(4.87e24, "kg")));
  85. results.push(makePlanet("Earth", math.unit(12756, "km"), math.unit(5.97e24, "kg")));
  86. results.push(makePlanet("Moon", math.unit(3475, "km"), math.unit(0.073e24, "kg")));
  87. results.push(makePlanet("Mars", math.unit(6792, "km"), math.unit(0.642e24, "kg")));
  88. results.push(makePlanet("Jupiter", math.unit(142984, "km"), math.unit(1898e24, "kg")));
  89. results.push(makePlanet("Saturn", math.unit(120536, "km"), math.unit(568e24, "kg"), { source: "./media/naturals/saturn.svg" }));
  90. results.push(makePlanet("Uranus", math.unit(51118, "km"), math.unit(86.8e24, "kg")));
  91. results.push(makePlanet("Neptune", math.unit(49528, "km"), math.unit(102e24, "kg")));
  92. results.push(makePlanet("Pluto", math.unit(2370, "km"), math.unit(0.0146e24, "kg")));
  93. results.push(makePlanet("Sol", math.unit(865370, "mi"), math.unit(1.989e30, "kg")));
  94. results.push(makePlanet("Betelgeuse", math.unit(1234.2e6, "mi"), math.unit(2.188e31, "kg")));
  95. results.push(makeState("Alaska", math.unit(2071.44, "km"), math.unit(2483.83, "km"), math.unit(1723337, "km^2")));
  96. results.push(makeState("California", math.unit(1048.82, "km"), math.unit(852.02, "km"), math.unit(423967, "km^2")));
  97. results.push(makeState("Colorado", math.unit(442.44, "km"), math.unit(604.47, "km"), math.unit(269601, "km^2")));
  98. results.push(makeState("Florida", math.unit(716.79, "km"), math.unit(723.97, "km"), math.unit(170312, "km^2")));
  99. results.push(makeState("Maine", math.unit(505.94, "km"), math.unit(330.98, "km"), math.unit(91633, "km^2")));
  100. results.push(makeState("Montana", math.unit(497.99, "km"), math.unit(983.98, "km"), math.unit(380831, "km^2")));
  101. results.push(makeState("New York", math.unit(494.92, "km"), math.unit(536.63, "km"), math.unit(141297, "km^2")));
  102. results.push(makeState("Texas", math.unit(1183.33, "km"), math.unit(1226.69, "km"), math.unit(695662, "km^2")));
  103. results.push(makeMountains());
  104. results.sort((b1, b2) => {
  105. e1 = b1.constructor();
  106. e2 = b2.constructor();
  107. return -math.subtract(e1.views[e1.defaultView].height, e2.views[e2.defaultView].height).value;
  108. });
  109. return results;
  110. }