let newFont;
let currentLightColor =
"red"
;
let currentSpecularColor =
"red"
;
function
preload() {
newFont = loadFont(
'fonts/Montserrat.otf'
);
}
function
setup() {
createCanvas(600, 300, WEBGL);
textFont(newFont, 16);
materialColorSel = createSelect();
materialColorSel.position(30, 70);
materialColorSel.option(
'red'
);
materialColorSel.option(
'green'
);
materialColorSel.option(
'blue'
);
materialColorSel.changed(() => {
currentSpecularColor = materialColorSel.value();
});
lightColorSel = createSelect();
lightColorSel.position(30, 120);
lightColorSel.option(
'red'
);
lightColorSel.option(
'green'
);
lightColorSel.option(
'blue'
);
lightColorSel.changed(() => {
currentLightColor = lightColorSel.value();
});
}
function
draw() {
background(
'white'
);
fill(
'black'
);
text(
"Select an option below to set the light"
+
" and specular material color"
, -285, -125);
text(
"Select directional light color"
, -285, -100);
text(
"Select specular material color"
, -285, -50);
shininess(10);
noStroke();
specularMaterial(currentSpecularColor);
directionalLight(color(currentLightColor),
height / 2, width / 2, -250);
translate(100, 0, 0);
sphere(100);
translate(-100, 0, 0);
}