Skip to content

Instantly share code, notes, and snippets.

@aurelianonava
Forked from Outrights/index.html
Created October 5, 2017 18:39
Show Gist options
  • Save aurelianonava/8bbc00789e9ede51cce44056543e5ba8 to your computer and use it in GitHub Desktop.
Save aurelianonava/8bbc00789e9ede51cce44056543e5ba8 to your computer and use it in GitHub Desktop.
Create and Call a function
<!DOCTYPE html>
<html>
<head>
<script data-require="p5.js@*" data-semver="0.5.7" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/p5.min.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
<title>Experimenting with creating my own functions</title>
</head>
<body>
<h3>We will be experimenting with creating our own functions. It should be fun.</h3>
</body>
</html>
function setup() {
canvas = createCanvas(480, 320);
}
function draw() {
background(200);
if(mouseX > width/2) {
myFun1();
}
}
function myFun1() {
fill(random(0, 255), random(0, 255), random(0, 255));
ellipse(width/2, height/2, 50, 50);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment