{"id":75363,"date":"2022-11-06T16:27:11","date_gmt":"2022-11-06T21:27:11","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=75363"},"modified":"2022-11-06T16:27:11","modified_gmt":"2022-11-06T21:27:11","slug":"project-09-3","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/11\/06\/project-09-3\/","title":{"rendered":"Project-09"},"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>I tried to use random&nbsp;quadrangles and words to construct a self portrait. And the words I use are the place I was born, grown up and the place i&rsquo;m staying.<\/p>\n<div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/11\/sketch-28.js\" data-width=\"400\" data-height=\"480\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"400\" height=\"480\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">var img;\nvar words = ['Beijing', 'Kunming', 'Pittsburgh','Alice']\nvar number = 1;\n\n\/\/preload image\nfunction preload() {\n    img = loadImage('https:\/\/i.imgur.com\/QwF6omd.jpeg');\n}\n\nfunction setup() {\n    createCanvas(400, 480);\n    \/\/resize image to fit canvas\n    img.resize(width, height);\n    frameRate(400);\n\n    imageMode(CENTER);\n    noStroke();\n    background(255);\n    img.loadPixels();\n}\n\n\/\/draw image\nfunction draw() {\n    if(number==1) {\n        drawWord();\n    } else {\n        drawPolygon(); \n    }\n  \n} \n\nfunction drawPolygon() {\n    var x = floor(random(img.width));\n    var y = floor(random(img.height));\n\n    \/\/picking color\n    var pix = img.get(x, y);\n    fill(pix, 128);\n\n    \/\/draw the random shape\n    beginShape();\n    vertex(x,y);\n    vertex(x-(random(4,7)), y+(random(10, 25)));\n    vertex(x-(random(4,7)), y+(random(25, 40)));\n    vertex(x,y+(random(40, 60)));\n    vertex(x+(random(4,7)), y+(random(25, 40)));\n    vertex(x+(random(4,7)), y+(random(10, 25)));\n    endShape();\n    \n}\n\nfunction drawWord() {\n    var x = floor(random(img.width));\n    var y = floor(random(img.height));\n\n    var pix = img.get(x, y);\n    fill(pix, 128);\n    textSize(random(3,15))\n\n    \/\/randomly pick words to draw\n    text(words[int(random(0,4))], x, y)\n}\n\nfunction mousePressed() {\n    \/\/changing between two options\n    number++;\n    if(number &gt; 2) {\n      number = 1\n    }\n    background(255)\n}<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>I tried to use random&nbsp;quadrangles and words to construct a self portrait. And the words I use are the place I was born, grown up and the place i&rsquo;m staying. sketch var img; var words = [&#8216;Beijing&#8217;, &#8216;Kunming&#8217;, &#8216;Pittsburgh&#8217;,&#8217;Alice&#8217;] var number = 1; \/\/preload image function preload() { img = loadImage(&#8216;https:\/\/i.imgur.com\/QwF6omd.jpeg&#8217;); } function setup() { &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/11\/06\/project-09-3\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project-09&#8221;<\/span><\/a><\/p>\n","protected":false},"author":777,"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\/75363"}],"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\/777"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=75363"}],"version-history":[{"count":2,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/75363\/revisions"}],"predecessor-version":[{"id":75365,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/75363\/revisions\/75365"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=75363"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=75363"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=75363"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}