Skip to content

Instantly share code, notes, and snippets.

@danielgtaylor
Last active December 14, 2015 09:29
Show Gist options
  • Save danielgtaylor/5065626 to your computer and use it in GitHub Desktop.
Save danielgtaylor/5065626 to your computer and use it in GitHub Desktop.
Calculating gravities, color, IBU, alcohol by volume, and calories for a beer recipe.
<script type="text/javascript" src="/scripts/brauhaus.min.js"></script>
<script type="text/javascript">
// Create a recipe
var r = new Brauhaus.Recipe({
name: 'My test brew',
description: 'A new test beer using Brauhaus.js!',
batchSize: 20.0,
boilSize: 10.0
});
// Add ingredients
r.add('fermentable', {
name: 'Extra pale liquid extract',
color: 2.5,
weight: 4.2,
yield: 78.0
});
r.add('spice', {
name: 'Cascade hops',
weight: 0.028,
aa: 5.0,
use: 'boil',
form: 'pellet'
});
r.add('yeast', {
name: 'Wyeast 3724 - Belgian Saison',
type: 'ale',
form: 'liquid',
attenuation: 80
});
// Calculate values
r.calculate();
// Print out calculated values
console.log('Original Gravity: ' + r.og.toFixed(3));
console.log('Final Gravity: ' + r.fg.toFixed(3));
console.log('Color: ' + r.color.toFixed(1) + '&deg; SRM (' + r.colorName() + ')');
console.log('IBU: ' + r.ibu.toFixed(1));
console.log('Alcohol: ' + r.abv.toFixed(1) + '% by volume');
console.log('Calories: ' + Math.round(r.calories) + ' kcal');
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment