Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/p5.min.js"></script>
	<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.9.0/addons/p5.dom.min.js"></script>
    <script src="p5test2.js"></script>
<body>
  <div id="wrapper">
	<header>
		<nav>
			<ul>
				<li>home</li>
				<li>about</li>
				<li>contact</li>
			</ul>
		</nav>
		<div id="container1">
			<h1 class="entry-title">lorem ipsum</h1>
		</div>
	</header>

	<div class="section1">
	  <p>Quisque ut gravida ligula, nec mollis dui.<br>
	  Etiam id massa eu urna faucibus pretium. Proin volutpat<br>
	  leo ut tellus facilisis, vitae fermentum turpis sagittis.<br>
	  Sed vel ligula a justo tempus vulputate. Nulla vitae commodo<br>
	  orci, pharetra ultricies arcu. Praesent lorem purus,<br>
	  tincidunt eu vehicula vel, tristique quis quam.
	  <br>
	  <br>
	  leo ut tellus facilisis, vitae fermentum turpis sagittis.<br>
	  Sed vel ligula a justo tempus vulputate. Nulla vitae commodo<br>
	  Quisque ut gravida ligula, nec mollis dui.<br>
	  orci, pharetra ultricies arcu. Praesent lorem purus,<br>
      </p>
      <p>
      Quisque ut gravida ligula, nec mollis dui.<br>
	  Etiam id massa eu urna faucibus pretium. Proin volutpat<br>
	  leo ut tellus facilisis, vitae fermentum turpis sagittis.<br>
	  orci, pharetra ultricies arcu. Praesent lorem purus,<br>
	  tincidunt eu vehicula vel, tristique quis quam.
	  <br>
	  <br>
	  leo ut tellus facilisis, vitae fermentum turpis sagittis.<br>
	  Sed vel ligula a justo tempus vulputate. Nulla vitae commodo<br>
	  Quisque ut gravida ligula, nec mollis dui.<br>
	  orci, pharetra ultricies arcu. Praesent lorem purus,<br>
      </p>
      <p>Quisque ut gravida ligula, nec mollis dui.<br>
	  Etiam id massa eu urna faucibus pretium. Proin volutpat<br>
	  leo ut tellus facilisis, vitae fermentum turpis sagittis.<br>
	  Sed vel ligula a justo tempus vulputate. Nulla vitae commodo<br>
	  orci, pharetra ultricies arcu. Praesent lorem purus,<br>
	  tincidunt eu vehicula vel, tristique quis quam.
	  <br>
	  <footer>
	  </footer>
    </div>
   </div>
 </body>
              
            
!

CSS

              
                html,body{
            margin: 0;
            height: 100%;/*コンテンツの内容に合わせて画面の高さが伸びる*/
	        color:#444;
	        font-family:sans-serif;
	    }
	    #wrapper {
            width: 100%;
            position:relative;
            /*子要素のfooterをposition: absolute; bottom:0;にして下に固定する*/
            min-height: 100%;
        }
	    h1{
	    	font-size:4em;
	    }
	    p{
	    	margin:6em;
	    	line-height: 1.5em;
	    }
	    nav{
	    	width: 100%;
	    	position: fixed;
	    	background: #545;
	    	color: #eee;
	    }
	    li{
	    	list-style: none;
	    	display: inline-block;
	    	font-size:1.3em;
	    	margin: 0.8em;
	    }
	    div{
		    overflow-x: hidden;
		    text-align: center;
		}
	    #container1{
	    	width: 100%;
	    	height:20em;
	    }
	    .entry-title{
	    	margin-top: 2.7em;
	    	text-align: center;
	    	color: #ddd;
	    }
	    .section1{
	        background-color: #dbd;
		    height: 100vh;
	    }
	    footer{
	    	height:5em;
	    	width: 100%;
	    	background: #545;
	    	/*下の2行 ↓↓ 親要素(ここでは#wrapper)にposition:relative;を指定することで下に固定する*/
	    	position: absolute;
	    	bottom:0;
	    }
              
            
!

JS

              
                var sketch;//出力するファイルの名前を定義
var dot = {
  x: 0,
  y: 0
}
var col = {//色の変数
  r: 0,
  g: 0,
  b: 0
}
function windowResized() {
    resizeCanvas(windowWidth, 400);
    background(20);//リサイズ後に色を再描画
}
function setup() {
    canvas = createCanvas(windowWidth,400);
    canvas.position(0,0);//canvasをページの原点に固定
    canvas.style('z-index','-1');//canvasを後ろに移動する
    background(20);
}

function draw() {
   frameRate(10);
   col.r = map(mouseX,0,windowWidth,0,255);//map(value, start1, stop1, start2, stop2, [withinBounds])
   col.g = random(0, 100);
   col.b = map(mouseY,0,windowHeight,0,255);
   dot.x = random(0, windowWidth);
   dot.y = random(0, windowHeight);
   noStroke();
   fill(col.r, col.g, col.b,70);
   ellipse(dot.x, dot.y, 30, 50);

}
new p5(sketch, "container1");//このsketchを、htmlで指定したIDの要素へ出力する
              
            
!
999px

Console