Skip to content

Instantly share code, notes, and snippets.

View claytical's full-sized avatar

Clay Ewing claytical

View GitHub Profile
@claytical
claytical / findneighbors
Created January 26, 2014 21:08
Recursive function for finding matches in a vector grid
void testApp::findMatchingColors(Candy &c) {
float upNeighborX = c.position.x;
float upNeighborY = c.position.y - GRID_SQUARE_SIZE;
float downNeighborX = c.position.x;
float downNeighborY = c.position.y + GRID_SQUARE_SIZE;
float leftNeighborX = c.position.x - GRID_SQUARE_SIZE;
float leftNeighborY = c.position.y;
float rightNeighborX = c.position.x + GRID_SQUARE_SIZE;
float rightNeighborY = c.position.y;
@claytical
claytical / sketch.js
Created September 7, 2015 15:10
lerpColor example
var startColor;
var endColor;
var bgColor;
var counter;
function setup() {
// uncomment this line to make the canvas the full size of the window
createCanvas(windowWidth, windowHeight);
startColor = color(255,0,0);
endColor = color(127,30,200);
@claytical
claytical / sketch.js
Created September 7, 2015 16:06
shape example
function setup() {
// uncomment this line to make the canvas the full size of the window
createCanvas(windowWidth, windowHeight);
}
function draw() {
// draw stuff here
@claytical
claytical / sketch.js
Created September 7, 2015 18:10
shape example with colors
function setup() {
// uncomment this line to make the canvas the full size of the window
createCanvas(windowWidth, windowHeight);
}
function draw() {
// draw stuff here
@claytical
claytical / sketch.js
Created September 7, 2015 18:43
p5js event functions
function setup() {
// uncomment this line to make the canvas the full size of the window
createCanvas(windowWidth, windowHeight);
}
function draw() {
@claytical
claytical / sketch.js
Created September 7, 2015 19:12
Pulling it all together #1
var startColor;
var endColor;
var counter;
var bgColor;
var y = 0;
var ySpeed = 1;
function setup() {
// uncomment this line to make the canvas the full size of the window
createCanvas(windowWidth, windowHeight);
@claytical
claytical / sketch.js
Created September 15, 2015 00:51
True/False Conditional Example
var shouldDrawCircle = false;
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
if (shouldDrawCircle == true) {
ellipse(mouseX,mouseY, 50, 50);
}
@claytical
claytical / sketch.js
Created September 15, 2015 00:58
Conditional Statement Comparison Example
var y;
function setup() {
createCanvas(windowWidth, windowHeight);
y = 0;
}
function draw() {
background(0);
ellipse(width/2, y, 50, 50);
@claytical
claytical / sketch.js
Last active February 1, 2016 16:27
Conditional Statement, And/Or
function setup() {
createCanvas(windowWidth, windowHeight);
y = 0;
}
function draw() {
background(0);
var oneThird = width/3;
var twoThirds = width - width/3;
@claytical
claytical / sketch.js
Created September 15, 2015 01:28
Conditional Else If Example
function setup() {
createCanvas(windowWidth, windowHeight);
rectMode(CENTER);
background(255);
}
function draw() {