Skip to content

Instantly share code, notes, and snippets.

@ambernomani
ambernomani / experiment.js
Created January 8, 2015 10:21
Falling snowflakes
var hi;
var speed = 3;
//var song;
//function preload() {
// song = loadSound("soft_relaxing_music_white_snow.mp3");
//}
function setup() {
createCanvas(800,600);
// song.loop();
@ambernomani
ambernomani / snowflake.js
Created January 12, 2015 01:41
Snowflake
function Snowflake(x1, y1) {
this.x = x1;
this.y = y1;
this.h = random(50);
this.speed = random(1,3);
this.create = function() {
noFill(0);
stroke(255);
line(this.x + this.h, this.y, this.x - this.h, this.y);
line(this.x, this.y + this.h, this.x, this.y - this.h);
function Particle(x1, x2){
this.a = x1;
this.b = x2;
this.t1 = random(50);
this.t2 = random(50);
this.update = function(){
this.a = noise(this.t1)*width;
this.b = noise(this.t2)*height;
this.t1 = this.t1 + 20;
var particles = []
function setup(){
createCanvas(360, 360);
colorMode(HSB, 360, 100, 100);
}
function draw(){
background(255);
var img;
var clip;
var slider;
function preload(){
img = loadImage("woods.jpg");
clip = loadSound("scream.mp3");
}
@ambernomani
ambernomani / snow.js
Created January 19, 2015 18:32
using vectors
var flake;
var snow = [];
function setup() {
createCanvas(800, 600);
//flake = new Snowflake(200, 200);
bg = loadImage("wp_snow2.jpg");
}
function draw() {
@ambernomani
ambernomani / snowfall.js
Created January 19, 2015 18:33
snowfall using vectors
function Snowflake(x1, y1) {
//this.x = x1;
//this.y = y1;
this.h = random(50);
//this.speed = random(1,3);
this.pos = createVector(x1, y1); // for position
this.vel = createVector(0, 0); // for velocity
this.acc = createVector(0,0)
//this.r = 16;
function colorWheel() {
this.move = function(stop, bp) {
colorMode(HSB, 360, 100, 100);
angleMode(DEGREES);
for (i = 90; i < stop; i++) {
fill(i%360, 100, 100);
stroke(i%360, 100, 100);
arc(700, 90, 130, 130, i, i+1)
function Cloud(x1, y1){
this.pos = createVector (x1, y1);
this.vel = createVector(0,0);
this.scale= random(0.2, 1.2);
//this.acc=createVector(0,0);
this.applyForce = function(force){
this.vel.add(force);
}
function Rain(){
this.pos = createVector (random(799), random(799));
this.height = random (50,130);
this.vel = createVector(0,random(1,4))
this.acc = createVector (0, 1)
this.applyForce=function(force){
this.acc.add(force);
}