xxxxxxxxxx
96
/**************************************************
Une évolution de https://editor.p5js.org/Anne-Laure/sketches/IZuoPHfs5
Based on ntsutae •@ntsutae
https://twitter.com/ntsutae/status/1209356755433443331?s=03
choix des couleurs https://editor.p5js.org/p5/sketches/Color:_Color_Variables
**************************************************/
var C = 0;
var D = 0;
var x = 0;
var y = 0;
var col1, col2, col3 ;
var voeuxTxt = "Bonne et heureuse année 2020 !" ;
var sig ;
function preload() {
// preload() runs once
sig = loadImage('folderA/sign-ALD-blanc.png'); // Load the image
}
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(8);
colorMode( HSB, 360, 100, 100, 100 );
textAlign(CENTER, CENTER);
textFont('Trebuchet MS', 44); // font and size
// resize signature to 1/4 of width
sig.resize(width/4, 0);
/*
col1 = color( 343, 55, 75, 100) ;
col2 = color( 103, 55, 75, 100)
col3 = color( 223, 55, 75, 100)
*/
col1 = color( random(360), 75, 75, 100) ;
// Color sets : See https://www.ethangardner.com/articles/2009/03/15/a-math-based-approach-to-color-theory-using-hue-saturation-and-brightness-hsb/
let h1 = hue( col1 );
let s1 = saturation( col1 );
col2 = color( (h1+120) % 360, s1, 75, 100) ;
col3 = color( (h1+240) % 360, s1, 75, 100) ;
// voir toString https://p5js.org/reference/#/p5.Color/toString
// print("couleur1 : ", col1.toString('#rrggbb') ) ;
print("couleur1 : ", col1.toString('hsba') ) ;
print("couleur2 : ", col2.toString('hsba') ) ;
print("couleur3 : ", col3.toString('hsba') ) ;
}
function draw() {
background(col1);
let posTxt = map( x, 0, width, 0.1*width, 0.9*width) ;
fill(col2) ;
noStroke() ;
text( voeuxTxt, posTxt, 40);
Dx = x = width / 2;
Dy = y = height/2 ;
/*
// Draw a rectangle with rounded corners, each having a radius of 20.
stroke(col3) ;
fill(col1) ;
rect(30, 100, 155, 100, 20);
fill(col2) ;
rect(30, 230, 155, 100, 20);
fill(col3) ;
rect(30, 360, 155, 100, 20);
*/
for (i = C++; i < C + 150; i++) {
x += cos(noise(i * .01) * PI * 9) * 5
Dx *= .965
Dy *= .965
strokeWeight(2) ;
stroke(col3) ;
line(x + Dx, y + Dy, x - Dx, y + Dy)
if (i % 32 == 0) {
for (j of [-Dx, Dx]) {
strokeWeight(8) ;
stroke(col2) ;
line(X = x + j * 1.5, y - Dy, X, y + Dy)
line(X, y - Dy, X - j / 2, y - Dy * 1.2)
}
}
}
// Displays the signature image
image(sig, 20, height - sig.height - 10 );
}