xxxxxxxxxx
55
let customFont;
let vertices = [];
function preload() {
// Load your custom font here
customFont = loadFont('thulth2.ttf');
}
function setup() {
createCanvas(800, 600);
textSize(300);
textFont(customFont);
textAlign(CENTER, CENTER);
noLoop();
// Loop through each character in "قطر"
let textString = "س";
let totalWidth = textWidth(textString);
let startX = width / 2 - totalWidth / 2; // Center the text horizontally
for (let i = 0; i < textString.length; i++) {
let char = textString.charAt(i);
let x = startX + textWidth(textString.substring(0, i)); // Calculate x position for each character
let points = customFont.textToPoints(char, x, height / 2, 300, {
sampleFactor: 0.1,
simplifyThreshold: 0
});
// Get a random number of vertices between 50 and 150
let randomCount = int(random(30, 50));
let selectedPoints = points.slice(0, randomCount);
// Offset points to center them
for (let p of selectedPoints) {
vertices.push(createVector(p.x - x + width / 2, p.y - height / 5)); // Centering points
}
}
}
function draw() {
background(255);
noStroke();
stroke(1);
//noFill();
// Draw all the vertices
beginShape();
for (let v of vertices) {
let opacity= random(50,255);
//fill(random(255),random(255),random(255),opacity);
curveVertex(v.x, v.y);
}
endShape();
}