added some formatting
This commit is contained in:
@@ -5,14 +5,14 @@ function preload() {
|
|||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
createCanvas(img1.width, img1.height);
|
createCanvas(img1.width, img1.height);
|
||||||
background(255,255,255)
|
background(255, 255, 255)
|
||||||
|
|
||||||
//image(img1, 0, 0);
|
//image(img1, 0, 0);
|
||||||
|
|
||||||
for (let col = 0; col < img1.width; col += 1) {
|
for (let col = 0; col < img1.width; col += 1) {
|
||||||
for (let row = 0; row < img1.height; row += 1) {
|
for (let row = 0; row < img1.height; row += 1) {
|
||||||
let c = img1.get(col, row);
|
let c = img1.get(col, row);
|
||||||
if (col%2 == 0){
|
if (col % 2 == 0) {
|
||||||
stroke(color(c));
|
stroke(color(c));
|
||||||
strokeWeight(1);
|
strokeWeight(1);
|
||||||
point(col, row);
|
point(col, row);
|
||||||
@@ -22,7 +22,7 @@ function setup() {
|
|||||||
for (let col = 0; col < img2.width; col += 1) {
|
for (let col = 0; col < img2.width; col += 1) {
|
||||||
for (let row = 0; row < img2.height; row += 1) {
|
for (let row = 0; row < img2.height; row += 1) {
|
||||||
let c = img2.get(col, row);
|
let c = img2.get(col, row);
|
||||||
if (col%2 == 1){
|
if (col % 2 == 1) {
|
||||||
stroke(color(c));
|
stroke(color(c));
|
||||||
strokeWeight(1);
|
strokeWeight(1);
|
||||||
point(col, row);
|
point(col, row);
|
||||||
@@ -36,6 +36,6 @@ function draw() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mousePressed(){
|
function mousePressed() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,13 +5,13 @@ var mouseIndex = 0
|
|||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
createCanvas(500, 500);
|
createCanvas(500, 500);
|
||||||
background(255,255,255)
|
background(255, 255, 255)
|
||||||
noFill();
|
noFill();
|
||||||
for (i = 0; i < 30; i++){
|
for (i = 0; i < 30; i++) {
|
||||||
size = random(0, 15)*i;
|
size = random(0, 15) * i;
|
||||||
randomX = random(-width/10, width/10);
|
randomX = random(-width / 10, width / 10);
|
||||||
randomY = random(-height/10, height/10);
|
randomY = random(-height / 10, height / 10);
|
||||||
square(width/2 +randomX - size/2, height/2 +randomY- size/2, size);
|
square(width / 2 + randomX - size / 2, height / 2 + randomY - size / 2, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,10 +20,10 @@ function draw() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mousePressed(){
|
function mousePressed() {
|
||||||
mouseIndex++
|
mouseIndex++
|
||||||
size = random(0, 15)*i;
|
size = random(0, 15) * i;
|
||||||
randomX = random(-width/10, width/10);
|
randomX = random(-width / 10, width / 10);
|
||||||
randomY = random(-height/10, height/10);
|
randomY = random(-height / 10, height / 10);
|
||||||
square(width/2 +randomX - size/2, height/2 +randomY- size/2, size);
|
square(width / 2 + randomX - size / 2, height / 2 + randomY - size / 2, size);
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ var numberOfSquaresY = 4;
|
|||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
createCanvas(500, 500);
|
createCanvas(500, 500);
|
||||||
background(255,255,255);
|
background(255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,31 +3,31 @@ function setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function draw() {
|
function draw() {
|
||||||
background(random(100,200), 0, random(100,200));
|
background(random(100, 200), 0, random(100, 200));
|
||||||
|
|
||||||
for (let i = 0; i <= width * sqrt(2); i += 10){
|
for (let i = 0; i <= width * sqrt(2); i += 10) {
|
||||||
stroke(random(255),random(255),random(255))
|
stroke(random(255), random(255), random(255))
|
||||||
strokeWeight(2)
|
strokeWeight(2)
|
||||||
noFill()
|
noFill()
|
||||||
circle(width/2 + random(0,30),height/2 + random(0,30),i)
|
circle(width / 2 + random(0, 30), height / 2 + random(0, 30), i)
|
||||||
|
|
||||||
const strokeValue = i%20 ? 100 : 0;
|
const strokeValue = i % 20 ? 100 : 0;
|
||||||
stroke(strokeValue)
|
stroke(strokeValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < 50; i++){
|
for (let i = 0; i < 50; i++) {
|
||||||
stroke(random(255),random(255),random(255))
|
stroke(random(255), random(255), random(255))
|
||||||
let x = random(0, width)
|
let x = random(0, width)
|
||||||
let y = random(0, height)
|
let y = random(0, height)
|
||||||
line(width/2,height/2,x,y)
|
line(width / 2, height / 2, x, y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mousePressed(){
|
function mousePressed() {
|
||||||
for (let i = 0; i < 50; i++){
|
for (let i = 0; i < 50; i++) {
|
||||||
stroke(random(255),random(255),random(255))
|
stroke(random(255), random(255), random(255))
|
||||||
let x = random(0, width)
|
let x = random(0, width)
|
||||||
let y = random(0, height)
|
let y = random(0, height)
|
||||||
line(mouseX,mouseY,x,y)
|
line(mouseX, mouseY, x, y)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,10 +5,10 @@ function preload() {
|
|||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
createCanvas(img1.width, img1.height);
|
createCanvas(img1.width, img1.height);
|
||||||
background(255,255,255)
|
background(255, 255, 255)
|
||||||
|
|
||||||
//image(img1, 0, 0);
|
//image(img1, 0, 0);
|
||||||
var glithes= random(3, 10);
|
var glithes = random(3, 10);
|
||||||
|
|
||||||
for (let col = 0; col < img1.width; col += 1) {
|
for (let col = 0; col < img1.width; col += 1) {
|
||||||
for (let row = 0; row < img1.height; row += 1) {
|
for (let row = 0; row < img1.height; row += 1) {
|
||||||
@@ -25,6 +25,6 @@ function draw() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mousePressed(){
|
function mousePressed() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ function preload() {
|
|||||||
|
|
||||||
function setup() {
|
function setup() {
|
||||||
createCanvas(img1.width, img1.height);
|
createCanvas(img1.width, img1.height);
|
||||||
background(255,255,55)
|
background(255, 255, 55)
|
||||||
|
|
||||||
//image(img1, 0, 0);
|
//image(img1, 0, 0);
|
||||||
|
|
||||||
@@ -12,11 +12,11 @@ function setup() {
|
|||||||
for (let row = 0; row < img1.height; row += 1) {
|
for (let row = 0; row < img1.height; row += 1) {
|
||||||
let c = img1.get(col, row);
|
let c = img1.get(col, row);
|
||||||
|
|
||||||
if (c[0] + c[1] + c[2] < random(0, 255)*3) {
|
if (c[0] + c[1] + c[2] < random(0, 255) * 3) {
|
||||||
c[0] = 0;
|
c[0] = 0;
|
||||||
c[1] = 0;
|
c[1] = 0;
|
||||||
c[2] = 0;
|
c[2] = 0;
|
||||||
}else{
|
} else {
|
||||||
c[0] = 255;
|
c[0] = 255;
|
||||||
c[1] = 255;
|
c[1] = 255;
|
||||||
c[2] = 255;
|
c[2] = 255;
|
||||||
@@ -33,6 +33,6 @@ function draw() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mousePressed(){
|
function mousePressed() {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -173,7 +173,7 @@ function applyCohesion(p, particleGrid, cellX, cellY) {
|
|||||||
if (other === p) continue;
|
if (other === p) continue;
|
||||||
let ddx = other.x - p.x;
|
let ddx = other.x - p.x;
|
||||||
let ddy = other.y - p.y;
|
let ddy = other.y - p.y;
|
||||||
let dist = sqrt(ddx*ddx + ddy*ddy);
|
let dist = sqrt(ddx * ddx + ddy * ddy);
|
||||||
if (dist > 0 && dist < cohesionRadius) {
|
if (dist > 0 && dist < cohesionRadius) {
|
||||||
let strength = cohesionStrength * (1 - dist / cohesionRadius);
|
let strength = cohesionStrength * (1 - dist / cohesionRadius);
|
||||||
fx += ddx * strength;
|
fx += ddx * strength;
|
||||||
@@ -245,7 +245,7 @@ function draw() {
|
|||||||
if (p.y <= radius || p.y >= height - radius) p.vy *= -0.9;
|
if (p.y <= radius || p.y >= height - radius) p.vy *= -0.9;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = waterParticles.length-1; i >= 0; i--) {
|
for (let i = waterParticles.length - 1; i >= 0; i--) {
|
||||||
let p = waterParticles[i];
|
let p = waterParticles[i];
|
||||||
if (p.y + radius >= height) {
|
if (p.y + radius >= height) {
|
||||||
waterParticles.splice(i, 1);
|
waterParticles.splice(i, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user