Skip to content

Instantly share code, notes, and snippets.

//JSON
var params = {
mode: 0,
mouseMode: false, //it's ","
angleAdj: 63,
maxSpeed: 1, //it's ","
maxSteerForce: 0.01,
sizeAdj: 0.3,
red: 255,
green: 100,
var points = [];
var RESOLUTION = 50;
var rows, cols;
var linePoints = [];
function setup() {
createCanvas(500, 600);
background(0);
//JSON
var params = {
casualMode: false,
patternMode: false,
mouseMode: false, //it's ","
angleAdj: 63,
maxSpeed: 1, //it's ","
maxSteerForce: 0.01,
sizeAdj: 1,
red: 255,
//JSON
var params = {
mouseMode: false, //it's ","
maxSpeed: 1, //it's ","
maxSteerForce: 0.01,
sinAdj: 1,
red: 255,
green: 100,
blue: 0
@XiaohanYa
XiaohanYa / Fish.js
Created May 1, 2017 14:30
Autonomous Agents/Fish Simulation
"use strict";
class Boid {
constructor(x, y) {
this.pos = createVector(x, y);
this.vel = createVector(random(-1, 1), random(-1, 1));
this.acc = createVector();
this.maxSpeed = 3; // max speed;
this.maxSteerForce = 0.05; // max steering force
"use strict"
class Thread {
constructor(_pos, h, s, b) {
this.pos = _pos.copy();
this.vel = createVector(random(-5, 5), random(-5, 5));
this.acc = createVector();
this.angle = 0;
this.maxDesiredVelocity = random(0.1, 5);
"use strict";
class Vehicle {
constructor(x, y, h, s, b) {
this.pos = createVector(x, y);
this.vel = createVector(random(-10, 10), random(-10, 10));
this.acc = createVector();
this.angle = 0;
this.maxDesiredVelocity = random(0.1, 1);
this.maxSteerForce = random(1, 10);
"use strict";
class Vehicle {
constructor(x, y, h, s, b) {
this.pos = createVector(x, y);
this.vel = createVector(random(-5, 5), random(-5, 5));
this.acc = createVector();
this.angle = 0;
this.maxDesiredVelocity = random(0.1, 1);
this.maxSteerForce = random(1, 10);
"use strict";
class Ball {
constructor(x, y, c) {
this.pos = createVector(x, y);
this.vel = createVector(0, 0);
this.acc = createVector();
this.mass = random(5, 30);
this.rad = this.mass;
"use strict";
class Ball {
constructor(x, y, c) {
this.pos = createVector(x, y);
this.vel = createVector(2, 2);
this.acc = createVector();
this.mass = random(5, 30);
this.rad = this.mass;