Skip to content

Instantly share code, notes, and snippets.

View claytical's full-sized avatar

Clay Ewing claytical

View GitHub Profile
@claytical
claytical / sketch.js
Created February 1, 2016 16:07
Simple If Statement
function setup() {
createCanvas(500,500);
}
function draw() {
background(255,255,255);
if (mouseX > 250) {
ellipse(50,50,50,50);
}
}
@claytical
claytical / sketch.js
Last active February 1, 2016 16:15
Multiple If Statements
var canDraw = false;
function setup() {
createCanvas(500,500);
background(255,255,0);
}
function draw() {
@claytical
claytical / sketch.js
Created February 1, 2016 16:19
If with Else
var c;
function setup() {
createCanvas(500,500);
c = color(255,255,255);
}
function draw() {
if (mouseY > height/2) {
c = color(255,0,0);
@claytical
claytical / sketch.js
Created February 1, 2016 16:24
If with and
function setup() {
createCanvas(500,500);
}
function draw() {
background(255,255,255);
if (mouseY > height/2 && mouseX > width/2) {
fill(255,0,0);
ellipse(width/2, height/2, 50, 50);
@claytical
claytical / sketch.js
Created February 1, 2016 16:39
If, Else If, Else
var x;
var y;
var xSpeed;
var ySpeed;
function setup() {
createCanvas(windowWidth, windowHeight);
x = width/2;
y = height/2;
xSpeed = 0;
@claytical
claytical / sketch.js
Created March 28, 2016 01:09
Google Spreadsheet with P5JS Example
var url = "https://spreadsheets.google.com/feeds/list/1qwbpwuHScQcujaMEg434eWPmpChMGBzaRQ9n39tYBjE/od6/public/values?alt=json";
var dudes = [];
function setup() {
createCanvas(windowWidth, windowHeight);
// Request the data from openweathermap
loadJSON(url, gotSpreadsheet);
}
function draw() {
background(0);
@claytical
claytical / getjson.html
Created September 19, 2019 19:28
Get JSON Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>GetJSON Example</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script
src="https://code.jquery.com/jquery-3.4.1.min.js"
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
crossorigin="anonymous"></script>
@claytical
claytical / linedraw.pde
Created March 15, 2022 17:09
Processing, Line Drawing Program with Colors Based on Conditions
//draw a contiuous line
int r = 0;
int g = 0;
int b = 0;
void setup() {
size(500, 500);
background(0, 0, 0);
@claytical
claytical / linedraw.pde
Last active March 15, 2022 17:12
Processing, Line Drawing Program With Conditional Colors, Default Stroke Width
//draw a contiuous line
int r = 0;
int g = 0;
int b = 0;
void setup() {
size(500, 500);
background(0, 0, 0);
@claytical
claytical / linedraw.pde
Created March 15, 2022 17:11
Processing, Line Drawing Program Looped Gradient Greens
//draw a contiuous line
void setup() {
size(500, 500);
background(0, 0, 0);
}
void draw() {