xxxxxxxxxx
42
var name = "Ashutosh";
var len = name.length;
var a = "a".charCodeAt();
var radius = 150;
var totalAlphabets = 26;
function setup() {
noLoop();
createCanvas(400, 400);
name = name.toLowerCase();
}
function draw() {
background(0);
noFill();
stroke(255);
strokeWeight(10);
ellipse(width / 2, height / 2, radius * 2);
var xInitial = width / 2 + radius * cos((name[0].charCodeAt() - a) * TWO_PI / totalAlphabets - PI / 2);
var yInitial = height / 2 + radius * sin((name[0].charCodeAt() - a) * TWO_PI / totalAlphabets - PI / 2);
strokeWeight(3);
for (var i = 1; i < len; i++) {
var posCurr = name[i].charCodeAt() - a;
var xCurr = width / 2 + radius * cos(posCurr * TWO_PI / totalAlphabets - PI / 2);
var yCurr = height / 2 + radius * sin(posCurr * TWO_PI / totalAlphabets - PI / 2);
bezier(xInitial, yInitial, width/2, height/2, xCurr, yCurr, xCurr, yCurr);
}
}
function keyPressed() {
console.log(key);
if (key == ' ') {
saveCanvas((name + '-' + (floor(random(100)))), 'png');
draw();
}
}