xxxxxxxxxx
54
let radDen;
let denScl;
function setup() {
createCanvas(400, 400);
radDen = 30;
denScl = 0.01;
translate(0, radDen);
let c1 = new Country(1, "Monaco", 38300, 18960);
c1.display();
}
// function draw() {
// background(220);
// }
class Country {
constructor(rank, name, pop, den) {
this.rank = rank;
this.name = name;
this.pop = pop;
this.den = den;
this.xPos = rank * radDen % width;
this.yPos = floor(rank * radDen / width);
this.denMod = this.den * denScl;
}
display() {
// dispDen();
push();
translate(this.xPos, this.yPos);
fill(200);
stroke(50);
circle(0, 0, radDen);
fill(100);
noStroke();
for (let i = 0; i < this.denMod; i++) {
let kx = random(-radDen / 2, radDen / 2);
let ky = random(-radDen / 2, radDen / 2);
circle(kx, ky, 3);
}
pop();
// dispPop();
}
}