Difference between revisions of "P5js-desktop-and-mobile"

From Digipool-Wiki
Jump to: navigation, search
Line 12: Line 12:
  
  
Add this to your p5js code
+
Add this to your p5js code into setup
 
<pre>
 
<pre>
 
   // go 16:9
 
   // go 16:9

Revision as of 19:41, 19 April 2020


Add this to your Html header

  <meta name="viewport" content="user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1,width=device-width">

  <style>
    body {
      background-image: url('stripe.png');
    }


Add this to your p5js code into setup

  // go 16:9
  if (windowWidth < windowHeight) { 
    // if portrait=mobil then use the full display height
    createCanvas(displayHeight * 0.5625, displayHeight);
  } else {
    // if landscape=dektop then use the full window height
    createCanvas(windowHeight * 0.5625, windowHeight);
  }