fractalkitty looking for math? fractalkitty.com

codepen challenges

The Plot of a Character

#random#trig#text#image#interactive#math#codepen-challenge

origin1originFromteen1teen2adult1adult2weapon1weapon2weapon3death1death2seriflifeEventsinitLifesetVarplotCrest

let origin1 = [];
let originFrom = [];
let teen1 = [];
let teen2 = [];
let adult1 = [];
let adult2 = [];
let weapon1 = [];
let weapon2 = [];
let weapon3 = [];
let death1 = [];
let death2 = [];
let b;
let serif;
let lifeEvents = [];
let a,b2,r;
function preload() {
  serif = loadFont("/assets/SourceSerifPro-Bold.ttf");
  b = loadImage("/assets/cardboard.JPG");
}
function setup() {
  r=random(200,300)
  a = int(random(1,9));
  b2 = int(random(2,5));
  setVar();
  cnv = createCanvas(800, 600);
  background(b);
  background(225, 225, 215, 200);
  textFont(serif);
  textSize(18);
  initLife();
  noLoop();
  stroke(60,60,40)
  fill(60,60,40)
}
function draw() {
  push()
  translate(width/2,height/2)
  plotCrest(30);
  pop()
  textSize(23)
  text('The Plot of a Character',10,40);
  push()
  translate(280,30)
  scale(0.05,0.05)

  plotCrest(250)
  pop()
  textSize(18);
  age = 0;
  text("Origin: " + lifeEvents[0], 10, 80);
  for (let i = 1; i < lifeEvents.length; i++) {
    age = age + random(5, 50);
    text(round(age) + " years : " + lifeEvents[i], 10, 80 + i * 50);
  }
}

function initLife() {
  lifeEvents[0] =
    origin1[int(random(0, origin1.length))] +
    " " +
    originFrom[int(random(0, originFrom.length))];
  n1 = int(random(0, teen1.length));
  lifeEvents[1] = teen1[n1];
  teen1.splice(n1, 1);
  n1 = int(random(0, teen1.length));
  lifeEvents[2] = teen1[n1];
  teen1.splice(n1, 1);
  n1 = int(random(0, weapon1.length));
  n2 = int(random(0, weapon2.length));
  n3 = int(random(0, weapon3.length));
  lifeEvents[3] = weapon1[n1] + " " + weapon2[n2] + weapon3[n3];
  weapon1.splice(n1, 1);
  weapon2.splice(n2, 1);
  weapon3.splice(n3, 1);
  n1 = int(random(0, teen2.length));
  lifeEvents[4] = teen2[n1];
  teen2.splice(n1, 1);
  n1 = int(random(0, teen2.length));
  lifeEvents[5] = teen2[n1];
  teen2.splice(n1, 1);
  n1 = int(random(0, adult1.length));
  lifeEvents[6] = adult1[n1];
  adult1.splice(n1, 1);
  n1 = int(random(0, adult1.length));
  lifeEvents[7] = adult1[n1];
  adult1.splice(n1, 1);
  n1 = int(random(0, weapon1.length));
  n2 = int(random(0, weapon2.length));
  n3 = int(random(0, weapon3.length));
  lifeEvents[8] = weapon1[n1] + " " + weapon2[n2] + weapon3[n3];
  weapon1.splice(n1, 1);
  weapon2.splice(n2, 1);
  weapon3.splice(n3, 1);
  n1 = int(random(0, death1.length));
  n2 = int(random(0, death2.length));
  lifeEvents[9] = death1[n1] + death2[n2];
}

function mousePressed() {
  setup();
  draw();
}

function setVar() {
  teen1 = [
    "Passed the trials of laminar flow",
    "Tamed the periodic sand centipedes of Planet Pi",
    "Mastered the warrior ritual of the Burnside Curve",
    "Dominated the finite beast of self",
    "Pulled the dagger from the paperweight of Professor e",
    "Developed the ability of mathemagical incantations",
    "Transformed into a congruent being",
    "Completed the square of righteousness",
  ];

  teen2 = [
    "Fell in love with a Cardioid",
    "Bonded with a botanical binomial gnome",
    "Merged with the consciousness of the empty set",
    "Became a Natural Number in the kingdom of N",
    "Courted the Count of Cardinality",
    "Chose a single pointed life of minima",
    "Became a follower of the Order of Optimization",
    "Combined assets with the Warrior of Tau",
    "Paired with the Parallelepiped of Power",
    "Dated a member of the Dihedral Group",
  ];

  adult1 = [
    "Broke free from the chain rule of a derivative King",
    "Rang the Bell Curve to ward off the Normalcy Nemesis",
    "Integrated the Cone of Ignominy for the Castle of Cross Sections",
    "Captured the Torus Tortoise of Tarantella",
    "Triumphed over the Transcendental Curves of the Coast of Counting",
    "Mastered the Mobius Maelstrom of Mortality",
    "Slayed the Snakety Snake of Sine",
    "Consumed the Potato of Partial Partitions",
    "Crowned the King of Local Maxima",
    "Defeated the Cylindrical Cyclops",
    "Pleaded for the people of the land of Prisms",
    "Obtained the Orb of Lemma",
  ];

  weapon1 = [
    "Received the",
    "Obtained the",
    "Attracted the",
    "Was bestowed the",
    "Summoned the",
    "Created the",
    "Forged the",
    "Found the",
    "Retrieved the",
    "Earned the",
    "Borrowed the",
    "Captured the",
    "Dug up the",
    "Unearthed the",
    "Manifested the",
  ];

  weapon2 = [
    "Armor",
    "Belt",
    "Battle-ax",
    "Blade",
    "Arrow",
    "Boots",
    "Bandana",
    "Cloak",
    "Cleaver",
    "Shackles",
    "Chains",
    "Crystal",
    "Sword",
    "Dagger",
    "Knife",
    "Quiver",
    "Bow",
    "Pokey Thing",
    "Net",
    "Goblet",
    "Gauntlet",
    "Shield",
    "Hat",
    "Helm",
    "Stone",
    "Lantern",
    "Potion",
    "Ring",
    "Bracelet",
    "Socks",
    "Pajamas",
    "Saddle",
    "Staff",
    "Wand",
    "Scarf",
    "Mittens",
    "Leash",
    "Anvil",
    "Whip",
    "Scythe",
  ];

  weapon3 = [
    " of Bayesian Bleeding",
    " of Solitary Sums",
    " of Axolotl Automata",
    " of Crescent Moons",
    " of the Weighted Wyverns",
    " of the Hyperbolic Hyacinths",
    " of the Quadratic Queen",
    " of the Linear Llama",
    " of the Rhombic Runes",
  ];

  origin1 = [
    "Hatched",
    "Born",
    "Originated",
    "Created",
    "Formed",
    "Molded",
    "Designed",
    "Generated",
    "Fabricated",
    "Made",
    "Shaped",
    "Manufactured",
    "Constructed",
    "Spawned",
    "Crafted",
    "Brought forth",
    "Forged",
    "Fashioned",
    "Cast",
    "Spontaneous becoming",
    "Materialized",
    "Grown",
  ];

  originFrom = [
    "from the ashes of a dragon curve",
    "from the blood of a dodecahedron",
    "from the egg sac of a butterfly curve",
    "from the pouch of a parabolic beast",
    "from the tree stump of truncation",
    "from the wand of magic squares",
    "from the logarithmic spores of moss",
    "from the infinite bowels of a crystalline klein bottle",
    "from the golden spiral of the all powerful Phi-lower",
    "from the 4th Dimension Manifold of Doom",
    "from the helix of base-13 DNA",
  ];

  death1 = [
    "Died a peaceful death at the ",
    "Was slain in the war of the ",
    "Perished at the ",
    "Disappeared in the ",
    "Vanished in the ",
    "Succumbed to game of life on the ",
    "Terminated at the ",
    "Truncated at the ",
    "Was buried at the ",
    "Vaporized at the ",
  ];

  death2 = [
    "Shores of Simplification",
    "Mountains of Mist, Maxima, and Mayhem",
    "Graphite Cliffs of Graphs",
    "Focus of Fort Fortiness",
    "Castle of Pyramid",
    "Bay of Brackets",
    "Swamp of Polar Bears",
  ];
}

function plotCrest(c){
  noFill()
  stroke(100,100,80,c)
  
  strokeWeight(10+a*a)
  beginShape()
  for(let i=0;i<20*PI;i+=0.1){
    x = r*sin(i/a)+r/2*cos(i/b2)*sin(i/b2);
    y = r*cos(i/(b2)+-r)*sin(i/a)-r/2*cos(i/a);
    vertex(x,y)
  }
  endShape()
  fill(100,100,80,20)
  stroke(100,100,80,20)
  circle(0-a*10,b2 -r/6,r/4)
  
}