From cc15b2e36fa2f5f3ae2c3ddb7cd121d6a67397c2 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Thu, 19 Mar 2020 10:15:18 -0400 Subject: [PATCH] Add M&Ms and skittles --- media/attribution.js | 9 +++++++++ presets/food.js | 30 ++++++++++++++++++++---------- presets/objects.js | 14 +++++++++++--- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/media/attribution.js b/media/attribution.js index 7303c43a..31f1ab57 100644 --- a/media/attribution.js +++ b/media/attribution.js @@ -7120,6 +7120,15 @@ const attributionData = { "dimensions-guide" ] }, + { + prefix: "./media/food/candy/", + files: [ + + ], + authors: [ + "chemicalcrux" + ] + }, { prefix: "./media/food/dinosaurs/", files: [ diff --git a/presets/food.js b/presets/food.js index d5004146..c02e90e7 100644 --- a/presets/food.js +++ b/presets/food.js @@ -70,11 +70,11 @@ function makeFood() { results.push( makeHeightWeight([ - ["blue-whale", 4.5, 125e3], - ["sperm-whale", 3, 42e3], - ["dairy-cow", 1.7, 800], - ["horse", 2.08, 550], - ["african-elephant", 3.2, 4000] + ["blue-whale", 4.5, "meters", 125e3, "kg"], + ["sperm-whale", 3, "meters", 42e3, "kg"], + ["dairy-cow", 1.7, "meters", 800, "kg"], + ["horse", 2.08, "meters", 550, "kg"], + ["african-elephant", 3.2, "meters", 4000, "kg"] ], "Animals", "", @@ -83,11 +83,11 @@ function makeFood() { results.push( makeHeightWeight([ - ["brachiosaurus", 13, 56e3], - ["pterodactyl", 2.3, 200], - ["stegosaurus", 4.5, 7e3], - ["tyrannosaurus", 5.2, 14e3], - ["velociraptor", 1.6, 15] + ["brachiosaurus", 13, "meters", 56e3, "kg"], + ["pterodactyl", 2.3, "meters", 200, "kg"], + ["stegosaurus", 4.5, "meters", 7e3, "kg"], + ["tyrannosaurus", 5.2, "meters", 14e3, "kg"], + ["velociraptor", 1.6, "meters", 15, "kg"] ], "Dinosaurs", "", @@ -122,6 +122,16 @@ function makeFood() { "food" )); + results.push(makeHeightWeight( + [ + ["m&m", 0.5262, "inches", 43/50, "g", "./media/objects/circle.svg"], + ["skittle", 0.50, "inches", 53/50, "g", "./media/objects/circle.svg"], + ], + "Candy", + "", + "food" + )) + results.sort((b1, b2) => { e1 = b1.constructor(); e2 = b2.constructor(); diff --git a/presets/objects.js b/presets/objects.js index b628d612..cd4ea099 100644 --- a/presets/objects.js +++ b/presets/objects.js @@ -72,10 +72,18 @@ function makeHeight(info, category, prefix="", type="objects") { function makeHeightWeight(info, category, prefix="", type="objects") { const views = {}; info.forEach(object => { + let src; + // this lets us provide our own source if needed + // useful for reusing existing art + if (object[5]) { + src = object[5]; + } else { + src = "./media/" + type + "/" + category.replace(/ /g, "-").toLowerCase() + "/" + prefix + object[0] + ".svg"; + } views[object[0]] = { - height: math.unit(object[1], "meters"), - mass: math.unit(object[2], "kilograms"), - image: { source: "./media/" + type + "/" + category.replace(/ /g, "-").toLowerCase() + "/" + prefix + object[0] + ".svg" }, + height: math.unit(object[1], object[2]), + mass: math.unit(object[3], object[4]), + image: { source: src }, name: object[0].replace(/-/g, " ").replace(/\b\w/g, x => x.toUpperCase()), rename: true }