Using a scrollbar to transition background color that corresponds with text of beer recipes
in
Programming Questions
•
5 months ago
I know this has to be simple and I'm just not getting it. I was given some code to try to accomplish this but I can't seem to adjust it to my needs. Plus the code I was given transitions using a HSB colorMode and I can't figure out how to use a color array that I've specified.
color[] beerrainbow = {#FDD207, #BF7E04, #FE7612, #611203, #1D0100, #1B100D};
My goal is for a display of beer recipes that correspond with the colors that can be scrolled through using the scroll bar.
These are the recipes:
//blonde ale (#FDD207)
Blonde Ale
Malt:
6.00 lb Extra Light Dry Malt Extract
Specialty Grains:
0.50 lb CaraPils
0.50 lb Crystal 10L
Hops:
0.75 oz Willamette - 60 min
0.75 oz Willamette - 20 min
0.50 oz Willamette - 1 min
Yeast:
Addittional:
1 unit, Whirfloc - 20 min
//ipa (#BF7E04)
Historic English IPA
Malt:
9.45 lbs Gold Malt syrup - 60 min
Specialty Grains:
NA
Hops:
4 oz UK Kent Goldings - 60 min
3 oz UK Kent Goldings - 15 min
7 oz UK Fuggle - 15 min
Yeast:
Wyeast 1098 British Ale - Liquid
Addittional:
1 lbs Clear Candi Sugar - 60 min
//pale ale (#FE7612)
Pale Ale
Malt:
6 lbs Pilsen Malt Syrup
Specialty Grains:
1 lb Bairds Light Carastan
Hops:
1 oz Palisade - 60 min
0.5 oz Centennial - 10 min
0.5 oz Columbus - 10 min
0.5 oz Centennial - 0 min
0.5 oz Columbus - 0 min
Yeast:
Safale US-05 Ale Yeast - Dry
Wyeast 1056 American Ale - Liquid
Addittional:
NA
//amber ale (#611203)
American Amber Ale
Malt:
- 3.15 lbs Amber malt syrup
- 3.15 lbs Amber malt syrup late addition - 15 min
Specialty Grains:
1 lb Briess Caramel 20
Hops:
- 2 oz Cascade - 60 min
- 1 oz Cascade - 1 min
Yeast:
Wyeast 1056 American Ale - Liquid
Safale US-05 Ale Yeast - Dry
Addittional:
//porter (#1D0100)
Bourbon Barrel Porter
Malt:
2 lbs Wheat malt dried malt extract - 60 min
6.3 lbs Dark malt extract syrup late addition - 15 min
Specialty Grains:
1.0 lbs English Chocolate Malt
0.5 lbs English Dark Crystal
0.5 lbs English Black Malt
Hops:
1 oz Chinook - 60 min
0.5 oz US Goldings - 15 min
0.5 oz US Goldings - 5 min
Yeast:
Danstar Windsor Ale Yeast - Dry
Wyeast 1728 Scottish Ale Yeast - Liquid
Addittional:
2 oz US Medium Plus Oak Cubes - add to secondary
16 oz bourbon - add to secondary
//stout (#1B100D)
Brunch Stout
Malt:
6 lbs Maris Otter Malt Syrup
2 lbs Golden Light dry malt extract
1 lb D-180 Candi Syrup - add at end of boil
Specialty Grains:
1.25 lbs English Roasted Barley
1 lbs English Dark Crystal
0.4 lbs Franco-Belges Kiln Coffee Malt
0.35 lbs English Chocolate Malt
Hops:
2 oz Nugget - 60 min
Yeast:
Safale S-04 Ale Yeast - Dry
Wyeast 1028 London Ale - Liquid
Addittional:
4 oz Peace Coffee Organic French Roast - 0 min
*Crush coarsely*
And this is the code I've been given:
int wide = 1000; // Width of window
int high = 300; // Height of window
int x1 = wide * 1/10; // Starting point of slider
int x2 = wide * 9/10; // Ending point of slider
int sw = x2 - x1; // Width of slider
int y = high*2; // Y coordinate for slider
int d = 20; // Diameter for button
float sliderX = x1; // X coordinate for button
//float hue; // Hue of background color
//color c; // Color variable for background
color[] beerrainbow = {#FDD207, #BF7E04, #FE7612, #611203, #1D0100, #1B100D};
void setup() {
size(1000, 650); // Set size of window
smooth(); // Use anti-aliasing
// colorMode(HSB, 360, 100, 100); // Use HSB color system for background color
}
void draw() {
// hue = map(sliderX, x1, x2, 0, 360); // Maps hue (0-360) to slider position
background(beerrainbow[0]); // Uses hue for background color
// Line for slider)
stroke(255); // White line
strokeCap(SQUARE); // Square ends for slider line
strokeWeight(5); // 5 pixels thick
line(x1, y, x2, y); // Positions slider using variables from top
// Slider button
noStroke(); // Turns off outline
fill(180); // Light gray for button
// Checks if mouse is above button and clicked
if ((dist(mouseX, mouseY, sliderX, y) < d) && mousePressed) {
sliderX = mouseX; // If so, button follows mouse on X
sliderX = constrain(sliderX, x1, x2); // But don't go off ends
}
ellipse(sliderX, y, d, d); // Draws the button
}
Any advice or help is greatly appreciated
1