For my midterm Intro to Computational Media project, I decided to tie in some work with my other class, DIY Health. I focused on writing a Meal Builder program. Part of my inspiration came from thinking about other uses of the functionality on display in Roopa’s week 3 & 4 Mr. Potato Head homework.
The aim for my program would be to log what you are eating and figure out the total carb count for the meal. For diabetics like me, carb count is directly related to how much insulin you should take to cover the meal. Most of the current apps on the market for this are all text-driven, so it seems like a good chance to experiment with a visually driven example.
But I decided to start with photos so that I could spend more time coding and less time generating the graphics. So I started by doing this quick mock-up:
The ingredients would appear along the bottom (where the gray boxes are) and would be dragged to the right, adding them to sandwich. Each ingredient would also be assigned a carb value. The program would be able to add up all the ingredients and calculate the total carb count of the sandwich.
However, I discovered a few logistical problems with building this. I figured there would need to be an assigned number of slots for ingredients in the sandwich. First, I didn’t know how to code those slots. Second, dragging the ingredients even close to the slot, you would want the ingredient to snap into place. That also seemed a little complicated to execute.
So I kept the idea, but switched to a salad. This allows me to skirt these issues since there could be an infinite number of salad ingredients and they could stack on top of each other. I got the dragging to work and learned how to generate a new ingredient every time one was dragged to the bowl (with a little help from Dan). Finally, I made it so that any ingredient that was dragged outside the bowl would be sent to an assigned spot within the bowl.
Dealing with all these issues, I have yet to tackle the carb counter functionality. In theory, it seems like this won’t be too difficult since each ingredient can be assigned a carb value. I will have to sort out keeping track of the total number of items dragged to the bowl and add the various values.
For the final project, I could expand from the salad format and also include a sandwich, burger and pizza interface. Not the full gamut of what people eat, but probably a considerable percentage of what grad students chow down in between class assignments.
I also need to just clean up the design (pick more interesting fonts, fine tune the bowl, add a random angle change on dragging or dropping into the bowl). As Dan pointed out, I could also clean up the code. I create a different array for each vegetable. Instead, I could replace these 8 arrays with one Vegetable array. It certainly would have been a lot less coding. Perhaps if I add things like burgers, I’ll organize ingredients by Vegetable, Meat, Dairy, Bread, Fruit and Oil arrays.
Other ideas I could potentially add would be a time/date function and the ability to save the meal into a food log. Then it would need a recall function to see your eating history. Of course, I could also add a wider variety of ingredients, but that is a slippery slope given the seemingly infinite number of options.