xxxxxxxxxx
//the custom font we'll use
let font;
//an array of objects with x and y properties, outlining some text
let points;
function preload() {
font = loadFont("Avara-Bold.otf");
}
function setup() {
createCanvas(windowWidth, windowHeight,SVG);
let chosenWord = random(["INNOVANT", "ÉTHIQUE", "COLLABORATIF", "PARTICIPATIF", "INCLUSIF", "DURABLE", "ÉCOLOGIQUE", "ÉDUCATIF"]);
points = getFontOutlinePointsForWord(chosenWord);
//noLoop();
}
function draw() {
background(255);
stroke('black');
noFill();
//points is an array of objects with x, y properties
//let's loop over each point and draw a circle at that point.
for (let i = 0; i < points.length; i++) {
let p = points[i];
let radius = random(5, 10);
// circle(p.x, p.y, radius);
//rect(p.x, p.y, radius, radius);
line(p.x, p.y, p.x+radius, p.y*(radius));
//Let's also move the point around a little
p.x += random(-0.3, 0.3);
}
}
//you can ignore this initially
function getFontOutlinePointsForWord(word) {
return font.textToPoints(word, 50, height/2, 280, {
sampleFactor: 0.3,
simplifyThreshold: 0
});
}
function keyTyped() {
if (key == "s") {
save("image" + ".svg");
}
}