Professional Documents
Culture Documents
Lucru Individual GC
Lucru Individual GC
RAPORT
Lucru idividual
Disciplina: „ Grafica pe calculator ”
Tema: Transformări geometrice și de vizualizare
asupra obiectelor 2D. Elemente de animație
Chișinău 2022
Tema: Procesarea imaginilor 2D.
Listingul programului:
let topColor;
let bottomColor;
let sun;
let mountainRanges = [];
let maxMountainRanges = 6;
function setup() {
createCanvas(1024, 600);
colorMode(HSB, 255);
function draw() {
drawBackground(topColor, bottomColor);
sun.draw();
class Shape {
constructor(x, y, width, height, strokeColor, fillColor) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.strokeColor = strokeColor;
this.fillColor = fillColor;
this.strokeWeight = 1;
}
getLeft() {
return this.x;
}
getRight() {
return this.x + this.width;
}
getBottom() {
return this.y;
}
getTop() {
return this.y + this.height;
}
contains(x, y) {
return x >= this.x &&
x <= (this.x + this.width) &&
y >= this.y &&
y <= (this.y + this.height);
}
}
class Sun extends Shape {
constructor(baseColor) {
let size = 150;
let xLoc = width * random();
let yLoc = size * random(-0.2, 0.5);
super(xLoc, yLoc, size, size);
}
draw() {
push()
noStroke();
fill(hue(topColor), saturation(topColor) * 0.9, brightness(topColor) * 1.6)
translate(0, frameCount/10)
ellipse(this.x, this.y, this.width, this.height);
pop()
}
}
draw() {
fill(this.fillColor);
noStroke();
beginShape();
vertex(-20, height);
for (var x = 1; x < width + 20; x++) {
let nx = map(x, 0, width, this.startNoise, this.endNoise);
let y = this.height * noise(nx);
vertex(x, height - y);
}
vertex(width + 21, height);
endShape();
}
}