xxxxxxxxxx
59
let PSE = [];
let counter = 0;
function preload() {
xml = loadXML("elements.xml");
}
function setup() {
let elements = xml.getChildren("element");
for (let i = 0; i < 112; i++) {
let name = elements[i].getChild("name").getContent();
let symbol = elements[i].getChild("symbol").getContent();
let mass = elements[i].getChild("mass").getContent();
let nr = elements[i].getChild("number").getContent();
let state = elements[i].getChild("standardState").getContent();
PSE.push([symbol, name, nr, mass, state]);
}
for (let elem of PSE) {
elem[3] = round(elem[3],3);
}
}
function draw() {}
function mousePressed() {
pg = createGraphics(110, 120);
pg.textFont("Helvetica");
pg.textAlign(CENTER);
pg.fill(40);
pg.textSize(70);
if (PSE[counter][4] == "gas") {
pg.fill(244,41,65);
}
if (PSE[counter][4] == "liquid") {
pg.fill("#1AA7EC");
}
if (PSE[counter][0] == "Am") {
pg.textSize(68);
}
pg.textStyle(BOLD);
pg.text(PSE[counter][0], pg.width / 2, 82);
pg.fill(40);
pg.textSize(15);
pg.textStyle(NORMAL);
pg.text(PSE[counter][1], pg.width / 2, 111);
pg.textAlign(LEFT);
pg.textStyle(BOLD);
pg.textSize(17);
pg.text(PSE[counter][2], 6, 22);
pg.textAlign(RIGHT);
pg.text(PSE[counter][3], 104, 22);
save(pg,str(PSE[counter][2]));
counter++;
}