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
"Script Nou" - Processing
ID
Autor
Duplicat din
Ultima modificare
#2892
Python 3.4 (Python)
-
Miercuri, 17 apr 2019, 17:34
function setup() { createCanvas(400, 400); } function draw() { } var main = function(){ smooth(); noStroke(); var time = 0, time2 = 0; var blockSize = 750, row = 25, Height, Speed = 6; var Block = function(x, y, l, w, h, th, f){ this.ax = x; this.ay = y; this.x = x * pow(3, 0.5) / 2 + y * pow(3, 0.5) / 2; this.y = - y * 1 / 2 + x * 1 / 2; this.l = l; this.w = w; this.h = h; this.xFactor = pow(3, 0.5) / 2; this.yFactor = 1 / 2; this.f = f; this.origf = f; this.targetHeight = th; }; Block.prototype.display = function() { noStroke(); fill(blendColor(blendColor(this.f, color(0, 0, 0), SOFT_LIGHT), color(0, 0, 0), SOFT_LIGHT)); quad(this.x, this.y, this.x, this.y - this.h, this.x + this.l * this.xFactor, this.y - this.h - this.l * this.yFactor, this.x + this.l * this.xFactor, this.y - this.l * this.yFactor); fill(blendColor(this.f, color(0, 0, 0), SOFT_LIGHT)); quad(this.x, this.y, this.x, this.y - this.h, this.x - this.w * this.xFactor, this.y - this.h - this.w * this.yFactor, this.x - this.w * this.xFactor, this.y - this.w * this.yFactor); fill(this.f); quad(this.x - this.w * this.xFactor, this.y - this.h - this.w * this.yFactor, this.x, this.y - this.h, this.x + this.l * this.xFactor, this.y - this.h - this.l * this.yFactor, this.x - this.w * this.xFactor + this.l * this.xFactor, this.y - this.h - this.w * this.yFactor - this.l * this.yFactor); }; Block.prototype.animate = function() { this.h -= (this.h - this.targetHeight) / 10; this.f = lerpColor(color(0), this.origf, constrain(this.h / this.targetHeight + 0.5, 0, 1)); this.x = this.ax * pow(3, 0.5) / 2 + this.ay * pow(3, 0.5) / 2; this.y = - this.ay * 1 / 2 + this.ax * 1 / 2; this.ay -= Speed; }; var blocks = []; draw = function() { background(0, 0, 0); pushMatrix(); translate(width / 2, height / 2); for(var i = blocks.length - 1; i >= 0; i--){ blocks[i].display(); blocks[i].animate(); if(blocks[i].ay < -450){ blocks[i].targetHeight = 0; } if(round(blocks[i].h) === 0 && blocks[i].ay < -400){ blocks.splice(i, 1); } } popMatrix(); if(time % round(blockSize / Speed / row) === 0){ for(var i = 0; i < row; i++){ Height = constrain(noise(time / blockSize * 2, i / row / 2) * 600 - 200, 1, 255); blocks.push(new Block(blockSize - i * blockSize / row - 300, 275, blockSize / row, blockSize / row, 0, Height, color(Height * Height / 50, Height * Height / 100, 255 - Height * 2))); } time2 += Speed / 3; } time += Speed / 3; }; }; main();
Duplicare
Executare
Cod
×
Cod HTML
<iframe sandbox="allow-scripts" src="/p5js/index.php?id=2892" style="width:408px; height:408px;border:solid 1px gray; overflow: scroll;"></iframe>
×
Duplicare script
Denumirea noului script
Du-te sus!