xxxxxxxxxx
81
// Load fonts in WEBGL mode by uploading the font-file
// eg. ttf to your Sketch Files
//
// check the Sketch Files and the additional file
// KronaOne-Regular.ttf
//
// You must load and set a font before drawing text.
// See `loadFont` and `textFont` for more details.
//
// if you are using the default renderer, you can use
// the link tag inside the index.html file, see example:
//
// https://editor.p5js.org/sojamo/sketches/yvc00Kv1x
let font;
function preload() {
font = loadFont("ChakraPetch-Bold.ttf");
}
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
textFont(font);
textSize(windowWidth*0.1);
}
function draw() {
background('#0018FF');
fill(40);
textAlign(CENTER);
push();
for (let i = 0; i < 10; i++) {
translate(0,tan(frameCount*0.01)*100);
rotateX(sin(frameCount*0.01));
rotateY(0);
rotateZ(0);
fill('#FFFFFF')
text("turbine", 0,0);}
pop();
}
// go to fullscreen
// copy lines below to add fullscreen toggle to
// your sketch. Notice that if you are already using
// the keyPressed function, add lines 20-22 to it.
function keyPressed() {
if (key === "o" || key === "O") {
enterFullscreen();
}
}
/* enter fullscreen-mode via
* https://editor.p5js.org/kjhollentoo/sketches/H199a0c-x
*/
function enterFullscreen() {
var fs = fullscreen();
if (!fs) {
fullscreen(true);
}
}
/* full screening will change the size of the canvas */
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}
/* prevents the mobile browser from processing some default
* touch events, like swiping left for "back" or scrolling
* the page.
*/
document.ontouchmove = function (event) {
event.preventDefault();
};