Skip to content

Commit f364296

Browse files
committed
Add P5 example of the rect() function
1 parent b261085 commit f364296

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

‎tutorials/javascript/p5/index.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ <h1>Some Simple P5 Tutorials</h1>
1414
<li><a href="create-canvas.html">createCanvas()</a></li>
1515
<li><a href="background.html">background()</a></li>
1616
<li><a href="point.html">point()</a></li>
17+
<li><a href="rect.html">rect()</a></li>
1718
<li><a href="translate-and-rotate.html">translate() and rotate()</a></li>
1819
<li><a href="ellipse.html">ellipse()</a></li>
1920
<li><a href="save.html">save()</a></li>

‎tutorials/javascript/p5/js/rect.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
const WIDTH = 640,
4+
HEIGHT = 480;
5+
6+
function setup() {
7+
createCanvas(WIDTH, HEIGHT);
8+
}
9+
10+
function draw() {
11+
// Read more at https://p5js.org/reference/#/p5/rect
12+
rect(0, 0, (WIDTH/2), (HEIGHT/2));
13+
}

‎tutorials/javascript/p5/rect.html‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>rect | P5 Tutorial</title>
6+
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.0/p5.min.js"
7+
integrity="sha256-GDuv15eqQpLqWvLkRnd+EvvsHLngEUnerY5BDSYfLuM="
8+
crossorigin="anonymous"></script>
9+
<script src="js/rect.js"></script>
10+
11+
<!-- Delete the following CSS if you don’t want a border around your canvas. -->
12+
<style>canvas { border: 1px solid #ddd; }</style>
13+
</head>
14+
<body><!-- Your P5 code does not go here. It goes in js/rect.js. --></body>
15+
</html>

0 commit comments

Comments
 (0)