xxxxxxxxxx
174
let slider_water;
let slider_barley;
let slider_hops;
let sliderFromLeft = 100;
let fromTop = 300;
let margin = 30;
let sliderWidth = 80;
function setup() {
createCanvas(800, 400);
frameRate(30);
slider_water = createSlider(0, 20, 5);
slider_water.position(sliderFromLeft, fromTop);
slider_water.style('width', sliderWidth+'px');
slider_barley = createSlider(0, 10, 2);
slider_barley.position(sliderFromLeft, fromTop+margin)
slider_barley.style('width', sliderWidth+'px');
slider_hops = createSlider(1, 65, 15);
slider_hops.position(sliderFromLeft, fromTop+margin*2)
slider_hops.style('width', sliderWidth+'px');
}
function draw() {
background(240);
let ingredients = {
water : slider_water.value(),
barley : slider_barley.value(),
hops : slider_hops.value(),
}
fill(80);
text( 'water hardness', 10, fromTop + 12 );
text( 'malt darkness', 10, fromTop + margin + 12 );
text( 'hops bitterness', 10, fromTop + margin*2 + 12 );
text( ingredients.water+'°dH', 110+sliderWidth, fromTop + 12 );
text( ingredients.barley, 110+sliderWidth, fromTop + margin + 12 );
text( ingredients.hops+' IBU', 110+sliderWidth, fromTop + margin*2 + 12 );
fill(150);
text(`On April 23, 1516, the Germany Purity Law was passed by duke Wilhelm IV. and his younger brother Ludwig X. It specifies that beer should not be brewed with something different than water, hops, and malt. Since now more than 500 years, beer in Bavaria only consists of these three ingredients, still allowing for such various sorts. The process consists of a small series of steps, while the ingredients, mixture, temperature, and duration change the outcome.
1. Maischen — The malt is mixed with the water and cooked
2. Läutern — The shells are taken away from the brew
3. Gären — Sugar is transformed into alcohol and carbonic acid
4. Filtrieren — A final filtration to get rid of the unwanted bits
Play around with the ingredients to create your beer!
`, 10, 50, 360, 300 );
pop();
push();
textSize(20);
text( 'Beer Mixer 🍻', 10, 30 );
textSize(12);
fill(180);
// text( 'The three ingredients of beer\nby the German purity law, since 1516.', 10, 50 );
beer( ingredients )
}
const allBeers = [
'pils',
'hell', 'export', 'lager',
'alt',
'märzen',
'kölsch',
'bock',
'fest',
'malz',
'schwarz',
];
let beer = (i) => {
let beerType = allBeers;
let scale = 3;
let name = "helles";
let beerColor = '#ffdd75'
// WATER
// https://hobbybrauer.de/forum/wiki/doku.php/brauwasser
// HOPS
// http://www.mathe-fuer-hobbybrauer.de/hopfen/
// malt
// https://brauen.de/blog/malzsorten-das-sollten-bierbrauer-darueber-wissen
if( i.water == 0 ){
// pils
beerType = beerType.filter( (b) => b === 'pils' )
}else if( i.water <= 5 ){
// hell, export, lager
beerType = beerType.filter( (b) => b === 'hell' || b === 'export' || b === 'lager' || b === 'bock' )
}else if( i.water >= 10 ){
// alt
beerType = beerType.filter( (b) => b === 'alt' )
}else {
// märzen
beerType = beerType.filter( (b) => b === 'märzen' )
}
if( i.hops <= 25 ){
beerType = beerType.filter( (b) =>b === 'märzen' || b === 'lager' || b === 'hell' )
}else{
beerType = beerType.filter( (b) => b === 'alt' || b === 'kölsch' || b === 'export' || b === 'pils' || b === 'bock' )
}
if( i.barley <= 4 ){
beerType = beerType.filter( (b) => b === 'helles' || b === 'lager' || b === 'pils' )
}else if( i.barley <= 7 ){
beerType = beerType.filter( (b) => b === 'märzen' || b === 'export' )
}else if( i.barley >= 10 ){
beerType = beerType.filter( (b) => b === 'schwarz' )
}else{
beerType = beerType.filter( (b) => b === 'alt' || b === 'bock' )
}
let colorVal = map(i.barley,10, 0, 50, 255);
beerColor = color( 20+colorVal, colorVal, 0 )
let beerColor2 = color( 20+colorVal-10, colorVal-10, 0 );
push();
translate( width/2+50, 20 );
textAlign('center');
textSize(16);
if( beerType.length > 0 ){
fill(0);
text( beerType[0].toUpperCase(), 25*scale, height-50 );
fill(beerColor);
noStroke();
quad(1*scale, 25*scale, 49*scale, 25*scale, 43*scale, 100*scale, 7*scale, 100*scale);
arc(25*scale, 100*scale, 36*scale, 8*scale, 0, PI);
fill(beerColor2)
ellipse(25*scale, 25*scale, 49*scale, 5*scale);
stroke(50);
noFill();
ellipse(25*scale, 15*scale, 50*scale, 5*scale)
arc(25*scale, 100*scale, 36*scale, 8*scale, 0, PI);
line(0*scale, 15*scale, 7*scale, 100*scale);
line(50*scale, 15*scale, 43*scale, 100*scale);
stroke(50,50);
arc(25*scale, 100*scale, 36*scale, 8*scale, PI, 0);
}else{
fill(180);
text( 'this beer does not seem to taste good', 25*scale, height/2 );
}
pop();
}