CODICE CORSO ARTE GENERATIVA
AIUTO 1: RIGA SCRIPT P5 NEL FILE HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js"></script>
AIUTO 2: CODICE COMPLETO FILE index.html
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js"></script>
<script src="caricadisegno.js"></script>
</head>
<body>
<h1 align=center>La scuola del saper fare</h1>
<p align=center> Corso di arte generativa del prof. Maurizio D'Andrea <center> </p>
</body>
</html>
AIUTO 3: CODICE COMPLETO FILE caricadisegno.js
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
}
AIUTO 4: DISEGNAMO UNA LINEA
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
line(100,200, 200, 200);
strokeWeight(23);
stroke(255,204,0);
}
AIUTO 5: DISEGNIAMO UN'ELLISSE
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
ellipse(200,200, 100, 200);
strokeWeight(23);
stroke(255,204,0);
}
AIUTO 6: LAVORIAMO CON IL MOUSE
function setup() {
createCanvas(400, 400);
}
function draw() {
if(mouseIsPressed) {
fill(0);
} else {
fill(255);
}
ellipse(mouseX, mouseY, 80, 80);
}
AIUTO 7: COSTRUIAMO LA FIGURA DI UN ATLETA
function setup() {
createCanvas(400, 400);
}
function draw() {
background("yellow")
fill(204, 101, 192);
stroke(127, 63, 120);
strokeWeight(1);
rect(230, 50, 50, 150);
ellipse(180, 200, 80, 80);
triangle(78, 370, 370, 300, 55, 400);
point(300, 200);
line(55, 400, 375, 80);
quad(100, 100, 350, 45, 380, 50, 78, 370);
arc(350, 45, 100, 200, radians(0), radians(200));
square(350, 150, 34);
circle(350, 45, 56);
}
AIUTO 8: RITORNIAMO AL PUNTO
function setup() {
createCanvas(400, 400);
}
function draw() {
background("yellow");
strokeWeight(10);
point(50, 50);
point(150, 50);
point(50, 150);
point(150, 150);
}
AIUTO 9: SCRIVIAMO IL NOSTRO NOME CON IL MOUSE
function setup() {
createCanvas(400, 400);
background("black")
}
function draw() {
stroke(255);
strokeWeight(10);
if (mouseIsPressed ===true) {
line(mouseX, mouseY, pmouseX, pmouseY);
}
}
AIUTO 10: TRASLIAMO, RUOTIAMO
function setup() {
createCanvas(400, 400);
angleMode(DEGREES);
}
function draw() {
background(220);
strokeWeight(12);
rotate(30);
translate(100, 12);
scale(0.5);
textSize(30);
textFont("Georgia");
fill(0, 102, 153);
text("Corso di arte generativa", 0, 30);
}
AIUTO 11: VARIABILI
function setup() {
createCanvas(400, 400);
}
function draw() {
let scatola1=12;
let scatola2="parola";
text("il valore di scatola1: " + scatola1, 5, 25);
text("il valore di scatola2: " + scatola2, 5, 50);
}
AIUTO 12: CICLI
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
for(let i=0; i <= 5; i++) {
line(100,0,i*20, 100)
}
}
AIUTO 13: CODICE FINALE
//Codice scritto da Maurizio D'Andrea
let numerocerchi = 20;
let opacità = 200;
let colorecerchi;
function setup() {
createCanvas(900, 900);
noFill();
colorecerchi = color(121, 0, 0, opacità);
}
function draw() {
background(255);
stroke(colorecerchi);
strokeWeight(mouseY / mouseX);
for (let gridY = 0; gridY < numerocerchi; gridY++) {
for (let gridX = 0; gridX < numerocerchi; gridX++) {
let posX = (width / numerocerchi) * gridX;
let posY = (height / numerocerchi) * gridY;
let spostax = mouseX / 20;
let spostay = mouseY / 20;
ellipse(posX + spostax, posY + spostay, mouseY / 12, mouseY / 12);
}
}
}
function keyPressed() {
if (key == "a" || key == "A") save("disegnoperscrivania.png");
}
MAURIZIO D'ANDREA INTERNATIONAL CONTEMPORARY ARTIST