Skip to content

Instantly share code, notes, and snippets.

View nick3499's full-sized avatar
🏠
Working from home

nick3499 nick3499

🏠
Working from home
  • USA
View GitHub Profile
<!doctype html>
<html lang="en">
<head>
<meta charset=utf-8>
<title>
Gravitational Force
</title>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
</head>
<body>
function setup() {
createCanvas(720, 400);
}
function draw() {
background(random(128, 255), random(128, 255), random(128, 255));
noStroke(0);
for (var i = 0; i < 100; i++) {
var x1 = random(0, width);
var y1 = random(0, height);
function setup() {
createCanvas(720, 400);
}
function draw() {
background(random(0, 255), random(0, 255), random(0, 255));
noStroke(0);
for (var i = 0; i < 50; i++) {
var x1 = random(0, width);
var y1 = random(0, height);
@nick3499
nick3499 / arc-chord.js
Created April 19, 2016 14:59
Arc Chord. Using p5.js library.
function setup () {
createCanvas(896, 504);
}
function draw () {
background('#ed225d');
noStroke();
for (i = 0; i < 6000; i++) {
fill(random(255), random(0, 170), random(255), 150);
// negative x-axis values help arc chords fill entire canvas
@nick3499
nick3499 / array.js
Created April 19, 2016 15:00
Array. Using p5.library.
var nums = [600, 500, 400, 300, 200, 100];
function setup() {
createCanvas(648, 648);
}
function draw() {
background(random(85, 170), random(85, 170), random(85, 170));
stroke(random(85, 170), random(85, 170), random(85, 170), 100);
strokeWeight(60);
@nick3499
nick3499 / beginShape-quads.js
Created April 19, 2016 15:02
Begin Shape Quads. Using p5.js library.
var x = 100;
var y = 50;
function setup() {
// decreased resolution = increased performance
createCanvas(896, 504);
}
function draw() {
background(0);
@nick3499
nick3499 / lerp-color.js
Created April 19, 2016 15:04
Lerp Color. Using p5.js library.
function setup() {
createCanvas(720, 400);
background(255);
noStroke();
}
function draw() {
background(255);
from = color(255, 0, 0, 0.2 * 255);
to = color(0, 0, 255, 0.2 * 255);
@nick3499
nick3499 / dot-notation.js
Created April 19, 2016 15:07
Dot Notation. Using p5.js library.
var e = { x: 0, y: 360, d: 100 };
var c1 = { r: 0, g: 255, b: 255 };
var c2 = { r: 255, g: 255, b: 0 };
function setup() {
createCanvas( 1280, 720 );
}
function draw() {
// dot syntax
@nick3499
nick3499 / lerp-color-2.js
Created April 19, 2016 15:08
Lerp Color 2. Using p5.js library.
function setup() {
createCanvas(720, 400);
background(255);
stroke(255);
strokeWeight(2);
}
function draw() {
background(255);
from = color(255, 255, 0, 0.2 * 255);
@nick3499
nick3499 / lerp-color-3.js
Created April 19, 2016 15:10
Lerp Color 3. Using p5.js library.
var b1, b2;
function setup() {
createCanvas(1024, 576);
}
function draw() {
background(255);
from = color('rgba(255,0,0,0.3)');
to = color('rgba(0,0,255,0.3)');
c1 = lerpColor(from, to, 0.20);