{"id":75269,"date":"2022-11-05T22:49:53","date_gmt":"2022-11-06T02:49:53","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=75269"},"modified":"2022-11-05T22:53:22","modified_gmt":"2022-11-06T02:53:22","slug":"project-9-computational-portrait-fish-and-man","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/11\/05\/project-9-computational-portrait-fish-and-man\/","title":{"rendered":"Project 9 \u2013 Computational Portrait- Fish and Man"},"content":{"rendered":"<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD HTML 4.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/REC-html40\/loose.dtd\">\n<html><body><p>It was pretty challenging to come up with original ideas on what<br>can be creative for me , while we just using the color of pixels to<br>create a blurry version of original picture. After all, I decided<br>fishes are fun to draw, and if I can make them moving, I can generate<br>the picture very quickly as shown in the canvas.<\/p>\n\n\n\n<p>It&rsquo;s very laggy to view all the posts, so here is a picture:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" width=\"601\" height=\"596\" src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/11\/image-20.png\" alt=\"\" class=\"wp-image-75275\" srcset=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/11\/image-20.png 601w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/11\/image-20-300x298.png 300w, https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/11\/image-20-150x150.png 150w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\"><figcaption>Final Work<\/figcaption><\/figure><div class=\"wp-block-file\"><a class=\"p5_sketch_link\" data-width=\"480\" data-height=\"480\" id=\"wp-block-file--media-4e242933-0439-4b2a-84c4-b01e1dccf1ee\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/11\/sketch-18.js\">sketch<\/a><a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/11\/sketch-18.js\" class=\"wp-block-file__button\" download=\"\" aria-describedby=\"wp-block-file--media-4e242933-0439-4b2a-84c4-b01e1dccf1ee\">Download<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"480\" height=\"480\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/* Jiayi Chen\n   jiayiche    Section A *\/\nvar head;\nvar fish = [] \/\/array for fish\nfunction preload(){\/\/load the image\n    head = loadImage('https:\/\/i.imgur.com\/VAEIjHv.jpeg');\n}\n\nfunction setup() {\n    createCanvas(480, 480); \n    imageMode(CENTER); \/\/exist because I don't know if it's important\n    head.loadPixels(); \/\/load pixels\n    background(220);\n    head.resize(480,480); \/\/resize head size to canvas size\n}\n\nfunction draw(){\n    var x =floor(random(0,480));\/\/a random x value\n    var y =floor(random(0,480));\/\/a random y value\n\n    fish.push(makeFish(x,y)); \/\/create more fishes\n\n    for (var i = 0; i &lt; fish.length; i++) { \/\/draw all the fishes \n        fish[i].stepFunction();\n        fish[i].drawFunction();\n    }\n    if(fish.length==1000){\n        noLoop();\n    }\n}\n\nfunction makeFish(fx,fy){\n    var f = {x: fx, y: fy,\n             stepFunction: stepFishes,\n             drawFunction: drawFishes\n         }\n    return f;\n}\n\n\/\/draw fishes according to pixel color\nfunction drawFishes(){ \n    var o=this.x\n    var p=this.y    \n    push();\n    noStroke();\n    c= head.get(o,p)\n    fill(c);\n    ellipse(o,p,20,10);\/\/body\n    line(o-2,p-5,o-2,p+5);\n    triangle(o+10,p,o+13,p+2,o+13,p-2)\/\/tail\n    eyeball(o,p);\n    pop();\n\n}\n\n\n\/\/fishes eye\n function eyeball(x,y){\n    stroke('white')\n    circle(x-5,y,1)\n    ellipse(x-5,y,3,3)\n }\n\nfunction stepFishes(){ \/\/fishes moving\n    this.x = this.x + random(-3,3)\n    this.y = this.y + random(-3,3)\n}<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>It was pretty challenging to come up with original ideas on whatcan be creative for me , while we just using the color of pixels tocreate a blurry version of original picture. After all, I decidedfishes are fun to draw, and if I can make them moving, I can generatethe picture very quickly as shown &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/11\/05\/project-9-computational-portrait-fish-and-man\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 9 \u2013 Computational Portrait- Fish and Man&#8221;<\/span><\/a><\/p>\n","protected":false},"author":710,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[111,55],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/75269"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/users\/710"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=75269"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/75269\/revisions"}],"predecessor-version":[{"id":75276,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/75269\/revisions\/75276"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=75269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=75269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=75269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}