Comutare navigație
pbInfo.ro
Probleme
Probleme - clasa a IX-a
Probleme - clasa a X-a
Probleme - clasa a XI-a
Probleme din concursuri
Căutare problemă
Exerciții
Programează cu Blockly
Desenează cu Processing
Exersează SQL
Soluţii
Resurse
Resurse pentru clasa a IX-a
Resurse pentru clasa a X-a
Resurse pentru clasa a XI-a
Subiecte bacalaureat
Ajutor
Autentificare
Înregistrare
×
Autentificare
Utilizator sau email
Parola
Acest site foloseşte cookies. Navigând în continuare, vă exprimaţi acordul asupra folosirii cookie-urilor.
Îti place pbInfo? Atunci acceptă-l cu totul! Dezactivează modulul de blocare a reclamelor!
×
Lista scripturi
Script Nou
Ajutor
"Just Rain" - Processing
ID
Autor
Duplicat din
Ultima modificare
#1661
Lazar Ionut Radu (LazarIonutRadu)
-
Marti, 06 feb 2018, 16:24
var drops = [1000]; function setup() { createCanvas(400, 400); drop = new RainDrop(); for( var i=0 ; i<300 ; i++) { drops[i] = new RainDrop(); } } function draw() { background(8, 23, 45); for( var i=0 ; i<300 ; i++) { drops[i].display(); drops[i].update(); drops[i].refresh(); } } function RainDrop() { this.x = random(0,400); this.y = random(-50,-150); this.chance = random(0,100); if(this.chance > 93) this.strokeWeight = random(4.5,5.5); else if(this.change > 90) this.strokeWeight = random(4,4.5); else if(this.chance > 88) this.strokeWeight = random(3,4); else if(this.chance > 5) this.strokeWeight = random(1,2); else this.strokeWeight = random(0.5,1); this.speed = this.strokeWeight*3/2; this.lenght = this.speed*6; this.display = function() { strokeWeight(this.strokeWeight); stroke(255); line(this.x,this.y,this.x,this.y+this.lenght); } this.update = function() { this.y = this.y + this.speed; } this.refresh = function() { if(this.y > 400) { this.x = random(0,400); this.y = random(-50,-150); this.chance = random(0,100); if(this.chance > 93) this.strokeWeight = random(4.5,5.5); else if(this.change > 90) this.strokeWeight = random(4,4.5); else if(this.chance > 88) this.strokeWeight = random(3,4); else if(this.chance > 5) this.strokeWeight = random(1,2); else this.strokeWeight = random(0.5,1); this.speed = this.strokeWeight*2; this.lenght = this.strokeWeight*9; } } }
Duplicare
Executare
Cod
×
Cod HTML
<iframe sandbox="allow-scripts" src="/p5js/index.php?id=1661" style="width:408px; height:408px;border:solid 1px gray; overflow: scroll;"></iframe>
×
Duplicare script
Denumirea noului script
Du-te sus!