Tweak the reticle drawing some more
This commit is contained in:
parent
133bb24018
commit
56e7160ea6
1 changed files with 13 additions and 7 deletions
|
@ -2,7 +2,7 @@ class Arc {
|
||||||
constructor(radius, length, speed, weight) {
|
constructor(radius, length, speed, weight) {
|
||||||
this.size = radius * 2.0;
|
this.size = radius * 2.0;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.speed = speed / weight;
|
this.speed = speed / (length * weight);
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.offset = Math.random() * TWO_PI;
|
this.offset = Math.random() * TWO_PI;
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,15 @@ class Arc {
|
||||||
stroke('rgba(20%, 50%, 100%, 0.7)');
|
stroke('rgba(20%, 50%, 100%, 0.7)');
|
||||||
strokeWeight(this.weight);
|
strokeWeight(this.weight);
|
||||||
noFill();
|
noFill();
|
||||||
arc(200, 200, this.size, this.size, this.offset, this.offset + QUARTER_PI);
|
arc(200, 200, this.size, this.size, this.offset, this.offset + this.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
tick() {
|
tick() {
|
||||||
this.offset += this.speed;
|
this.offset += this.speed;
|
||||||
if (this.offset > TWO_PI) {
|
if (this.offset > TWO_PI) {
|
||||||
this.offset = this.offset - TWO_PI;
|
this.offset = this.offset - TWO_PI;
|
||||||
|
} else if (this.offset < 0) {
|
||||||
|
this.offset = TWO_PI + this.offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,17 +29,21 @@ let arcsToDraw = [];
|
||||||
function createArcs() {
|
function createArcs() {
|
||||||
console.log("Creating Arcs");
|
console.log("Creating Arcs");
|
||||||
|
|
||||||
const maximumLenth = PI;
|
const maximumLenth = PI / 3;
|
||||||
const minimumLength = PI / 4;
|
const minimumLength = PI / 6;
|
||||||
|
const minimumSpeed = 0.02;
|
||||||
|
const maximumSpeed = 0.08;
|
||||||
|
const maximumWeight = 12;
|
||||||
|
const minimumWeight = 8;
|
||||||
|
|
||||||
arcsToDraw = new Array();
|
arcsToDraw = new Array();
|
||||||
let radius = 25;
|
let radius = 25;
|
||||||
while (arcsToDraw.length < 20) {
|
while (arcsToDraw.length < 20) {
|
||||||
let length = Math.random() * (maximumLenth - minimumLength) + minimumLength;
|
let length = Math.random() * (maximumLenth - minimumLength) + minimumLength;
|
||||||
let speed = Math.random() * 0.05;
|
let speed = (Math.random() > 0.9 ? 1 : -1) * (Math.random() * (maximumSpeed - minimumSpeed) + minimumSpeed);
|
||||||
let weight = Math.random() * (15 - 8) + 8;
|
let weight = Math.random() * (maximumWeight - minimumWeight) + minimumWeight;
|
||||||
arcsToDraw.push(new Arc(radius, length, speed, weight));
|
arcsToDraw.push(new Arc(radius, length, speed, weight));
|
||||||
radius += 7.5;
|
radius += 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue