{"id":73008,"date":"2022-09-25T11:16:58","date_gmt":"2022-09-25T15:16:58","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=73008"},"modified":"2022-09-25T11:16:58","modified_gmt":"2022-09-25T15:16:58","slug":"project-04-string-art-12","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/25\/project-04-string-art-12\/","title":{"rendered":"Project-04 String Art"},"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><\/p>\n\n\n\n<p>This is my string art. I wanted to make an eye out of strings and the eye follows the x-coordinate of the mouse. Each layer of the eye is remapped to create a 3-dimensional effect. The spiral further extends the mystical feeling the eye gives off. <\/p>\n<div><a class=\"p5_sketch_link\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/sketch-382.js\" data-width=\"400\" data-height=\"600\">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=\"600\"><\/iframe><pre class=\"language-javascript\"><code class=\"p5_editor language-javascript\">\/\/Michael Li\n\/\/Section C \nvar dx1;\nvar dy1;\nvar dx2;\nvar dy2;\nvar numLines = 70;\n\nfunction setup() {\n    createCanvas(400, 300);\n    background(200);\n    \n\n}\n\nfunction draw() {\n    background(\"darkred\");\n    \/\/remapped values for eyeball translation\n    var tranX1 = constrain(map(mouseX, 0, 400, 120, 280), 120, 280)\n    var tranX2 = constrain(map(mouseX, 0, 400, 130, 270), 130, 270)\n    var tranX3 = constrain(map(mouseX, 0, 400, 140, 260), 140, 260)\n    var tranX4 = constrain(map(mouseX, 0, 400, 150, 250), 150, 250)\n    \/\/set variable for rotation\n    var rot = 90\n    \/\/eye white\n    stroke(255);\n    \/\/two lines bottom left and top right\n    line(0, 150, 250, 400); \n    line(150, -100, 400, 150)\n\n    \/\/calculate the line length and divide by number of lines \n    \/\/for gap between each line\n    dx1 = (250-0)\/numLines;\n    dy1 = (400-150)\/numLines;\n    dx2 = (400-150)\/numLines;\n    dy2 = (150+100)\/numLines;\n\n    \/\/set initial points for line\n    var x1 = 0;\n    var y1 = 150;\n    var x2 = 150;\n    var y2 = -100;\n    \/\/for loop, i = number of lines drawn\n    \/\/line position + gap width to drawn each line \n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1, y1, x2, y2);\n        x1 += dx1;\n        y1 += dy1;\n        x2 += dx2;\n        y2 += dy2;\n    }\n    \/\/repeat the process diagnally. \n    \/\/draw line top right and bottom left\n    line(150, 400, 400, 150);\n    line(0, 150, 250, -100)\n\n    \/\/calculate the line length and divide by number of lines \n    \/\/for gap between each line\n    dx1 = (400-150)\/numLines;\n    dy1 = (150-400)\/numLines;\n    dx2 = (250-0)\/numLines;\n    dy2 = (-100-150)\/numLines;\n\n    \/\/set initial points for line\n    x1 = 150;\n    y1 = 400;\n    x2 = 0;\n    y2 = 150;\n\n    \/\/for loop, i = number of lines drawn\n    \/\/line position + gap width to drawn each line \n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1, y1, x2, y2);\n        x1 += dx1;\n        y1 += dy1;\n        x2 += dx2;\n        y2 += dy2;\n    }\n    \/\/ spiral controlled by the mouseY position\n\n    \/\/use push and pop to limit the conditions inside\n    push()\n    \/\/tranlsate origin to the middle of the canvas\n    translate(200, 150)\n    \/\/set variables for the line positions\n    var x =100\n    var y = 100\n    var dist = 50 \/\/distance between each line\n    var rot2 = 5 \/\/set value for rotation degree\n    var rotation = constrain(map(mouseY, 0, 300, -500, 100), -500, 100)\n    \/\/sets value of y, the loops repeats for 200 times\n    for (y = 100; y &lt;= 300; y += 1){\n        rotate (radians(rot2)) \/\/rotation of the line around the origin\n        stroke(\"lightyellow\") \/\/stroke color\n        \/\/draw line to form the spiral\n        line(rotation, y, x+dist, y+dist)\n        rot2 += 0 \/\/constant rotation\n    }\n\n    pop()\n\n    \/\/eyeball formation\n    \/\/use written function eyeBall below to draw the eyeball formation\n\n    \/\/Innermost DarkRed\n    push()\n    stroke(\"darkred\")\n    \/\/translate the position based on the mouseX position\n    \/\/use tranX variables for remapped values\n    translate(tranX1, 150); \n    \/\/use for loop to repeat the Eyeball Function\n    for (var spin = 0; spin &lt;=6; spin += 1){\n        \/\/written function to draw components of the eyeballs\n        eyeBall(30, 30, 30, 30)\n        rotate(radians(rot))\n        \/\/rot adds 90 degrees each time the loop runs \n        rot += 90\n    }\n    pop()\n\n    \/\/2nd layer lightblue\n    push()\n    stroke(\"lightblue\")\n    \/\/use remapped value for translation based on mouseX\n    translate(tranX2, 150);\n    \/\/rotate 45 degrees for variation from the last component\n    rotate(radians(45))\n    \/\/for loop to repeat the eyeBall function\n    for (var spin = 0; spin &lt;=6; spin += 1){\n        \/\/Eyeball function decrease value to increase size\n        eyeBall(20, 20, 20, 20)\n        rotate(radians(rot))\n        \/\/rot adds 90 degrees each time the loop runs \n        rot += 90\n    }\n    pop()\n\n    \/\/3rd layer light green\n    push()\n    \/\/use remapped value for translation based on mouseX\n    translate(tranX3, 150);\n    \/\/rotate 90 degrees for variation from the last compone nt\n    rotate(radians(90))\n    stroke(\"lightgreen\")\n    \/\/use for loop to repeat the eyeBall function\n    for (var spin = 0; spin &lt;=6; spin += 1){\n        \/\/eyeBall function increases component size\n        eyeBall(10, 10, 10, 10)\n        rotate(radians(rot))\n        \/\/addes rotation value for the circular shape\n        rot += 90\n    }\n    pop()\n\n    \/\/4th layer dark grey\n    push()\n    \/\/use remapped value for tranlsation based on mouseX\n    translate(tranX4, 150);\n    \/\/rotate 45 degrees for variation\n    rotate(radians(45))\n    stroke(30) \/\/dark grey\n    for (var spin = 0; spin &lt;=12; spin += 1){\n        \/\/increase in size\n        eyeBall(-10, -10, -10, -10)\n        rotate(radians(rot))\n        \/\/adds 45 degrees for circular form\n        rot += 45\n    }\n    pop()\n   \n    \/\/eye lids\n    stroke(\"orange\");\n    \/\/draw two lines\n    line(0, 150, 250, 400);\n    line(150, 400, 400, 150);\n    \/\/calculate length of the line and divide by number of lines to draw\n    dx1 = (250-0)\/numLines;\n    dy1 = (400-150)\/numLines;\n    dx2 = (400-150)\/numLines;\n    dy2 = (150-400)\/numLines;\n\n    \/\/set variables for the initial positions of the line\n    var x1 = 0;\n    var y1 = 150;\n    var x2 = 150;\n    var y2 = 400;\n    \/\/use for loop to continously draw the lines\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1, y1, x2, y2);\n        x1 += dx1;\n        y1 += dy1;\n        x2 += dx2;\n        y2 += dy2;\n    }\n    \/\/draw two lines\n    line(0, 150, 250, -100)\n    line(150, -100, 400, 150)\n    \/\/calculate length of the lines and divide by number of lines to draw\n    dx1 = (250-0)\/numLines;\n    dy1 = (-100-150)\/numLines;\n    dx2 = (400-150)\/numLines;\n    dy2 = (150+100)\/numLines;\n\n    \/\/set variables for the initial positions of the line\n    var x1 = 0;\n    var y1 = 150;\n    var x2 = 150;\n    var y2 = -100;\n    \/\/use for loop to continously draw the lines\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1, y1, x2, y2);\n        x1 += dx1;\n        y1 += dy1;\n        x2 += dx2;\n        y2 += dy2;\n    }\n}\n\n\/\/set function to draw the eyeball components\nfunction eyeBall (a, b, c, d){\n \n    \/\/set two lines\n    line(a-40, b-120, c-100, d+40)\n    line(a+40, b-120, c-120, d-40)\n\n    \/\/find the length of the lines divided by the number of lines\n    dx1 = (c-100-(a-40))\/numLines;\n    dy1 = (d+40-(b-120))\/numLines;\n    dx2 = (c-120-(a+40))\/numLines;\n    dy2 = (d-40-(b-120))\/numLines;\n\n    \/\/set values for inital position\n    var x1 = a-40;\n    var y1 = b-120;\n    var x2 = c+40;\n    var y2 = d-120;\n    \/\/use for loops to continously draw the lines.\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1, y1, x2, y2);\n        x1 += dx1;\n        y1 += dy1;\n        x2 += dx2;\n        y2 += dy2;\n    }\n\n}<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>This is my string art. I wanted to make an eye out of strings and the eye follows the x-coordinate of the mouse. Each layer of the eye is remapped to create a 3-dimensional effect. The spiral further extends the mystical feeling the eye gives off. sketch \/\/Michael Li \/\/Section C var dx1; var dy1; &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/25\/project-04-string-art-12\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project-04 String Art&#8221;<\/span><\/a><\/p>\n","protected":false},"author":739,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[102,57],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/73008"}],"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\/739"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/comments?post=73008"}],"version-history":[{"count":2,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/73008\/revisions"}],"predecessor-version":[{"id":73010,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/73008\/revisions\/73010"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=73008"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=73008"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=73008"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}