Skip to content

Instantly share code, notes, and snippets.

View claytical's full-sized avatar

Clay Ewing claytical

View GitHub Profile
@claytical
claytical / index.html
Created October 13, 2015 00:57
Input with Canvas Example
<html>
<head>
<meta charset="UTF-8">
<script language="javascript" type="text/javascript" src="../p5.js"></script>
<!-- uncomment lines below to include extra p5 libraries -->
<script language="javascript" src="../addons/p5.dom.js"></script> <!--<script language="javascript" src="../addons/p5.sound.js"></script>-->
<script language="javascript" type="text/javascript" src="sketch.js"></script>
<!-- this line removes any default padding and style. you might only need one of these values set. -->
<style>
#left_panel {
@claytical
claytical / index.html
Created October 13, 2015 00:37
Canvas Parent and Position Example
<html>
<head>
<meta charset="UTF-8">
<script language="javascript" type="text/javascript" src="../p5.js"></script>
<!-- uncomment lines below to include extra p5 libraries -->
<script language="javascript" src="../addons/p5.dom.js"></script> <!--<script language="javascript" src="../addons/p5.sound.js"></script>-->
<script language="javascript" type="text/javascript" src="sketch.js"></script>
<!-- this line removes any default padding and style. you might only need one of these values set. -->
<style>
#left_panel {
@claytical
claytical / sketch.js
Created October 6, 2015 15:36
Array of Object Changes
var Ball = function() {
this.x = random(width);
this.y = random(height);
this.speedX = random(-1,1);
this.diameter = random(20,50);
}
var balls = [];
@claytical
claytical / sketch.js
Created October 3, 2015 17:01
Ball Object Example with Methods
var Ball = function(x, y) {
this.x = x;
this.y = y;
this.diameter = 10;
}
Ball.prototype.show = function() {
ellipse(this.x, this.y, this.diameter, this.diameter);
}
@claytical
claytical / sketch.js
Created October 3, 2015 16:52
Simple Object Array with Parameters
var Ball = function(x, y) {
this.x = x;
this.y = y;
this.diameter = 10;
}
var balls = [];
@claytical
claytical / sketch.js
Created October 3, 2015 16:50
Simple Object with Array Example
var Ball = function() {
this.x = mouseX;
this.y = mouseY;
this.diameter = 10;
}
var balls = [];
@claytical
claytical / sketch.js
Created October 3, 2015 16:44
Simple Ball Object Example
var ball = { x: 50,
y: 50,
diameter: 50
};
function setup() {
createCanvas(windowWidth, windowHeight);
}
@claytical
claytical / sketch.js
Created September 28, 2015 22:21
Saving Points Example
var xPoints = [];
var yPoints = []
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(0);
@claytical
claytical / sketch.js
Created September 28, 2015 22:14
Nested For Loop Example
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(0);
noFill();
stroke(255);
@claytical
claytical / sketch.js
Created September 28, 2015 22:01
For Example
var dots = [];
function setup() {
createCanvas(windowWidth, windowHeight);
for (var i = 0; i < 10; i++) {
dots.push(random(10,50));
}
}