{"id":75292,"date":"2022-11-06T00:09:47","date_gmt":"2022-11-06T04:09:47","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=75292"},"modified":"2022-11-06T00:09:47","modified_gmt":"2022-11-06T04:09:47","slug":"project-09-2","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/11\/06\/project-09-2\/","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><div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/11\/sketch-20.js\" data-width=\"300\" data-height=\"400\">sketch<\/a><iframe src=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/plugins\/p5-embedder\/p5_iframe.html\" class=\"p5_exampleFrame\" width=\"300\" height=\"400\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/Paul\n\/\/kengpul\n\/\/Section A\n\nvar img;\nvar newImg;\n\nfunction preload() {\n  img = loadImage('https:\/\/i.imgur.com\/pqOHKd9.jpg');\n}\n\nfunction setup() {\n  createCanvas(300, 400);\n    image(img,0,0,300,400);\n\n    for (var y = 0; y &lt; img.height; y++) {\n    for (var x = 0; x &lt; img.width; x++) {\n      \/\/ Read the pixel's color\n      var ogCol = img.get(x, y);\n\n      \/\/creates interesting effects with the color with inversion and similar ieffects\n      var r = red(ogCol);\n      var g = 210 - green(ogCol);\n      var b = 255 - 90 - blue(ogCol);\n\n      var newCol = color(r, g, b);\n\n      \/\/ Set the new pixel's color\n      img.set(x, y, newCol);\n    }\n  }\n  img.updatePixels();\n  \n    image(img, 0, 0, width, height);\n}\n\nfunction draw() {\n    noStroke();\n    if(mouseIsPressed){\n        randomPixels();\n    }\n  \n}\n\n\n\nfunction randomPixels(){ \/\/ creates random sized magnification \n  \/\/of wherever the mouse is on while pressed scattered across the screen\n    \n    var newImg = img.get(mouseX,mouseY,random(30,70),random(30,70));\n    img.updatePixels();\n\n    image(newImg, random(-10,width), random(-10,height), random(10,20),random(10,20));\n}\n\nfunction keyPressed(){\n    \/\/when key pressed reset\n    \/\/when key pressed reset the small square samples created wit mouse click\n  if(key == \"r\" || key == \"R\"){\n      image(img,0,0,300,400);\n      var r = 255 - 90 - red(ogCol);\n      var g = 210 - green(ogCol);\n      var b = blue(ogCol);\n  }\n\n\n\n\/\/\/!!! the program takes a whille to load between each filters so it might take a few sec.\n\n\n\n\n\n\/\/filter a\n    if(key == \"A\" || key == \"a\"){\n\n    image(img,0,0,300,400);\n\n    for (var y = 0; y &lt; img.height; y++) {\n    for (var x = 0; x &lt; img.width; x++) {\n      \/\/ Read the pixel's color\n      var ogCol = img.get(x, y);\n\n      \/\/creates interesting effects with the color with inversion and similar ieffects\n      var r = 255 - 90 - red(ogCol);\n      var g = 210 - green(ogCol);\n      var b = blue(ogCol);\n      var newCol = color(r, g, b);\n\n      \/\/ Set the new pixel's color\n      img.set(x, y, newCol);\n    }\n  }\n  img.updatePixels();\n    image(img, 0, 0, width, height);\n  \/\/filter b\n  }else if(key == \"B\" || key == \"b\"){\n    \/\/when key pressed reset\n    \/\/background(100);\n    image(img,0,0,300,400);\n\n     image(img,0,0,300,400);\n\n    for (var y = 0; y &lt; img.height; y++) {\n    for (var x = 0; x &lt; img.width; x++) {\n      \/\/ Read the pixel's color\n      var ogCol = img.get(x, y);\n\n      \/\/creates interesting effects with the color with inversion and similar ieffects\n      var r = 255 - 90 - (ogCol);\n      var g = 210 - green(ogCol);\n      var b = blue(ogCol);\n      var newCol = color(r, g, b);\n\n      \/\/ Set the new pixel's color\n      img.set(x, y, newCol);\n    }\n  }\n  img.updatePixels();\n    image(img, 0, 0, width, height);\n  \/\/filter C\n  }else if(key == \"C\" || key == \"c\"){\n    \/\/when key pressed reset\n    \/\/background(100);\n    image(img,0,0,300,400);\n\n     image(img,0,0,300,400);\n\n    for (var y = 0; y &lt; img.height; y++) {\n    for (var x = 0; x &lt; img.width; x++) {\n      \/\/ Read the pixel's color\n      var ogCol = img.get(x, y);\n\n      \/\/creates interesting effects with the color with inversion and similar ieffects\n      var r = 255 - red(ogCol);\n      var g = 0- green(ogCol);\n      var b = 50- blue(ogCol);\n      var newCol = color(r, g, b);\n\n      \/\/ Set the new pixel's color\n      img.set(x, y, newCol);\n    }\n  }\n  img.updatePixels();\n  \n    image(img, 0, 0, width, height);\n  }\n\n\n}\n\n\n\n\n\n\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>sketch \/\/Paul \/\/kengpul \/\/Section A var img; var newImg; function preload() { img = loadImage(&#8216;https:\/\/i.imgur.com\/pqOHKd9.jpg&#8217;); } function setup() { createCanvas(300, 400); image(img,0,0,300,400); for (var y = 0; y &lt; img.height; y++) { for (var x = 0; x &lt; img.width; x++) { \/\/ Read the pixel&#8217;s color var ogCol = img.get(x, y); \/\/creates interesting effects &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/11\/06\/project-09-2\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project 09&#8221;<\/span><\/a><\/p>\n","protected":false},"author":738,"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\/75292"}],"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\/738"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=75292"}],"version-history":[{"count":1,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/75292\/revisions"}],"predecessor-version":[{"id":75298,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/75292\/revisions\/75298"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=75292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=75292"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=75292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}