{"id":68155,"date":"2021-10-25T00:02:19","date_gmt":"2021-10-25T04:02:19","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/?p=68155"},"modified":"2021-10-25T00:02:19","modified_gmt":"2021-10-25T04:02:19","slug":"assignment-08-a-mixies","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/10\/25\/assignment-08-a-mixies\/","title":{"rendered":"Assignment-08-A: Mixies"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<html><body><div class=\"wp-block-file\"><a class=\"p5_sketch_link\" data-height=\"450\" data-width=\"600\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/uploads\/2021\/10\/sketch-130.js\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"600\" height=\"450\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/Brandon Yi\n\/\/btyi@andrew.cmu.edu\n\/\/Section A\n\n\/\/ loading all links\nvar bodyLinks = [\n    \"http:\/\/i.imgur.com\/5YM2aPE.jpg\",\n    \"http:\/\/i.imgur.com\/oKtGXfd.jpg\",\n    \"http:\/\/i.imgur.com\/Kvg75bG.jpg\",\n    \"http:\/\/i.imgur.com\/0FGzErn.jpg\",\n    \"http:\/\/i.imgur.com\/MJmlPt5.jpg\",\n    \"http:\/\/i.imgur.com\/VvX0k8e.jpg\",\n    \"http:\/\/i.imgur.com\/rLIOBoG.jpg\",\n    \"http:\/\/i.imgur.com\/q03Gko3.jpg\",\n    \"http:\/\/i.imgur.com\/BWpN5SP.jpg\",\n    \"http:\/\/i.imgur.com\/ft10TV3.jpg\",\n    \"http:\/\/i.imgur.com\/CGCZliN.jpg\",\n    \"http:\/\/i.imgur.com\/qrlc4dK.jpg\"]\n    \nvar feetLinks = [\n    \"http:\/\/i.imgur.com\/oNSO0T6.jpg\",\n    \"http:\/\/i.imgur.com\/OWGETX7.jpg\",\n    \"http:\/\/i.imgur.com\/Zp29aVg.jpg\",\n    \"http:\/\/i.imgur.com\/AXLWZRR.jpg\",\n    \"http:\/\/i.imgur.com\/wgZq717.jpg\",\n    \"http:\/\/i.imgur.com\/sGVMEMw.jpg\",\n    \"http:\/\/i.imgur.com\/hfbrynH.jpg\",\n    \"http:\/\/i.imgur.com\/OOASUMM.jpg\",\n    \"http:\/\/i.imgur.com\/aqtIXi0.jpg\",\n    \"http:\/\/i.imgur.com\/Eu6ruPo.jpg\",\n    \"http:\/\/i.imgur.com\/mTSipwg.jpg\",\n    \"http:\/\/i.imgur.com\/1GzC4Zz.jpg\"]\n    \nvar headLinks = [\n    \"http:\/\/i.imgur.com\/gBCZVuM.jpg\",\n    \"http:\/\/i.imgur.com\/YLOXAdH.jpg\",\n    \"http:\/\/i.imgur.com\/my3TqY7.jpg\",\n    \"http:\/\/i.imgur.com\/lvtIB9s.jpg\",\n    \"http:\/\/i.imgur.com\/gvDBfhO.jpg\",\n    \"http:\/\/i.imgur.com\/JEuJ2ER.jpg\",\n    \"http:\/\/i.imgur.com\/SbBOG1V.jpg\",\n    \"http:\/\/i.imgur.com\/cuJ5Ao1.jpg\",\n    \"http:\/\/i.imgur.com\/dqHjjig.jpg\",\n    \"http:\/\/i.imgur.com\/mcFUcHf.jpg\",\n    \"http:\/\/i.imgur.com\/0XKU9Dx.jpg\",\n    \"http:\/\/i.imgur.com\/sD1ArAR.jpg\"]\n\n\n\/\/initializing arrays in problem\n\nvar headImages = [];\nvar bodyImages = [];\nvar feetImages = [];\n\nvar head = [];\nvar body = [];\nvar feet = [];\n\n\/\/loading links into images array \nfunction preload() {\n    for (var i = 0; i &lt;= 11; i++) {\n        img = loadImage(headLinks[i]);\n        headImages.push(img);\n        img = loadImage(bodyLinks[i]);\n        bodyImages.push(img);\n        img = loadImage(feetLinks[i]);\n        feetImages.push(img);\n    }\n}\n\n\nfunction GenerateRandoms() {\n    \/\/loop for different \"people\"\n\n    for (var i = 0; i &lt;= 2; i++) {\n\n        \/\/generate random head image \n        r = int(random(0,11));\n        head.push(headImages[r]);\n\n        \/\/check for repeats\n        while (head[i] == head[i-1] || head[i] == head[i-2]) {\n            head.pop();\n            head.push(headImages[int(random(0,11))]);\n        }\n\n        \/\/generate random body image\n        r = int(random(0,11));\n        body.push(bodyImages[r]);\n\n        \/\/check for repeats\n        while (body[i] == body[i-1] || body[i] == body[i-2]) {\n            body.pop();\n            body.push(bodyImages[int(random(0,11))]);\n        }\n\n        \/\/generate random feet image\n        r = int(random(0,11));\n        feet.push(feetImages[r]);\n\n        \/\/check for repeats\n        while (feet[i] == feet[i-1] || feet[i] == feet[i-2]) {\n            feet.pop();\n            feet.push(feetImages[int(random(0,11))]);\n        } \n    }\n\n}\n\n\/\/setup canvas\nfunction setup() {\n    createCanvas(600, 450);\n    background(220);\n    GenerateRandoms();\n}\n\nfunction mousePressed() {\n\n    \/\/clearing different arrays based on different mouseY positions\n    \/\/generating new images for particular position\n    if (mouseY&lt;(height\/3)) {\n        head = [];\n        GenerateRandoms();\n    }\n    else if (mouseY&gt;=(height\/3) & mouseY <=(2*height\/3)) {\n        body = [];\n        GenerateRandoms();\n    }\n    else {\n        feet = [];\n        GenerateRandoms();\n    }\n\n    \n}\n\n\n\/\/display new images in positions based on i\nfunction draw() {\n    for (var i = 0; i &lt;= 2; i++) {\n        image(head[i],i*200,0,200,150);\n        image(body[i],i*200,150,200,150);\n        image(feet[i],i*200,300,200,150);\n    }\n}\n\n<\/code><\/pre><\/div>\n\n\n\n<p><\/p><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>sketch \/\/Brandon Yi \/\/btyi@andrew.cmu.edu \/\/Section A \/\/ loading all links var bodyLinks = [ &#8220;http:\/\/i.imgur.com\/5YM2aPE.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/oKtGXfd.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/Kvg75bG.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/0FGzErn.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/MJmlPt5.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/VvX0k8e.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/rLIOBoG.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/q03Gko3.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/BWpN5SP.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/ft10TV3.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/CGCZliN.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/qrlc4dK.jpg&#8221;] var feetLinks = [ &#8220;http:\/\/i.imgur.com\/oNSO0T6.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/OWGETX7.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/Zp29aVg.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/AXLWZRR.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/wgZq717.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/sGVMEMw.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/hfbrynH.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/OOASUMM.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/aqtIXi0.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/Eu6ruPo.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/mTSipwg.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/1GzC4Zz.jpg&#8221;] var headLinks = [ &#8220;http:\/\/i.imgur.com\/gBCZVuM.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/YLOXAdH.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/my3TqY7.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/lvtIB9s.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/gvDBfhO.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/JEuJ2ER.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/SbBOG1V.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/cuJ5Ao1.jpg&#8221;, &#8220;http:\/\/i.imgur.com\/dqHjjig.jpg&#8221;, &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/2021\/10\/25\/assignment-08-a-mixies\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Assignment-08-A: Mixies&#8221;<\/span><\/a><\/p>\n","protected":false},"author":679,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[55],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/68155"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/users\/679"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/comments?post=68155"}],"version-history":[{"count":1,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/68155\/revisions"}],"predecessor-version":[{"id":68157,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/posts\/68155\/revisions\/68157"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/media?parent=68155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/categories?post=68155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2021\/wp-json\/wp\/v2\/tags?post=68155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}