{"id":72941,"date":"2022-09-24T22:43:28","date_gmt":"2022-09-25T02:43:28","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/?p=72941"},"modified":"2022-09-24T22:55:16","modified_gmt":"2022-09-25T02:55:16","slug":"project-04-string-art-pineapple","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/24\/project-04-string-art-pineapple\/","title":{"rendered":"Project-04:\u00a0String Art-Pineapple"},"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>Although it&rsquo;s a bit abstract, but it is a pineapple. Everything is made by &ldquo;string&rdquo;.<\/p>\n\n\n\n<div class=\"wp-block-file\"><a class=\"p5_sketch_link\" data-width=\"300\" data-height=\"400\" id=\"wp-block-file--media-bb32cd5c-a089-4c3f-a083-15f1452fdb16\" href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/sketch-374.js\">sketch<\/a><a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-content\/uploads\/2022\/09\/sketch-374.js\" class=\"wp-block-file__button\" download aria-describedby=\"wp-block-file--media-bb32cd5c-a089-4c3f-a083-15f1452fdb16\">Download<\/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\">\/* Jiayi Chen\n   jiayiche    Section A *\/\nfunction setup() {\n    createCanvas(300, 400);\n    background('yellow');\n}\n\nvar numLines = 50;\nvar dx1;\nvar dy1;\nvar dx2;\nvar dy2;\n\nfunction draw() {\n    \/\/ percentize width and height\n    var w= width\/100;\n    var h= height\/100;\n\n    \/\/body of pinapple\n    \/\/diagonals(*w,*h,*w,*h,*w,*h,*w,*h) general formula\n    diagonals(0*w,0*h,0*w,100*h,0*w,100*h,100*w,100*h); \/\/left outside\n    diagonals(100*w,0*h,100*w,100*h,100*w,100*h,0*w,100*h); \/\/right outside\n    diagonals(0*w,100*h,0*w,30*h,0*w,30*h,100*w,30*h); \/\/left inside\n    diagonals(100*w,100*h,100*w,30*h,100*w,30*h,0*w,30*h); \/\/right inside\n     \/\/smooth the vertexes of pinnaple\n    diagonals(10*w,80*h,50*w,95*h,50*w,95*h,90*w,80*h); \/\/bottom\n    diagonals(10*w,50*h,50*w,35*h,50*w,35*h,90*w,50*h); \/\/top\n    diagonals(40*w,30*h,10*w,60*h,10*w,60*h,40*w,90*h); \/\/left\n    diagonals(60*w,30*h,90*w,60*h,90*w,60*h,60*w,90*h); \/\/right\n    \/\/Green Hair\n    push();\n    stroke('green');\n    strokeWeight(2);\n    diagonals3(15*w,20*h,30*w,45*h,70*w,45*h,80*w,20*h);\/\/sides\n    diagonals3(30*w,45*h,50*w,15*h,70*w,45*h,50*w,15*h);\/\/middle\n    diagonals3(30*w,45*h,50*w,15*h,50*w,15*h,70*w,45*h);\/\/upper middle \n    pop();\n    \/\/background\n    diagonals3(0*w,0*h,0*w,30*h,100*w,0*h,100*w,30*h);\n    \/\/texture\n    diagonals2(25*w,60*h,40*w,58*h,40*w,58*h,50*w,45*h);\/\/left\n    diagonals2(25*w,60*h,40*w,58*h,40*w,58*h,50*w,75*h);\n    diagonals2(75*w,60*h,60*w,58*h,60*w,58*h,50*w,45*h);\/\/right\n    diagonals2(75*w,60*h,60*w,58*h,60*w,58*h,50*w,75*h);\n    diagonals2(50*w,75*h,30*w,80*h,30*w,80*h,35*w,85*h);\/\/bottom left\n    diagonals2(50*w,75*h,70*w,80*h,70*w,80*h,65*w,85*h);\/\/bottom right\n    noLoop();\n\n}\n\n\nfunction diagonals(x1,y1,x2,y2,x3,y3,x4,y4){ \/\/diagonal\/straight lines between 2 lines\n    line(x1,y1,x2,y2);\n    line(x3,y3,x4,y4);\n    dx1=(x2-x1)\/numLines;\n    dy1=(y2-y1)\/numLines;\n    dx3=(x3-x4)\/numLines;\n    dy3=(y3-y4)\/numLines;\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1,y1,x3,y3);\n        x1 += dx1;\n        y1 += dy1;\n        x3 -= dx3;\n        y3 -= dy3; \n    }\n}\n\nfunction diagonals2(x1,y1,x2,y2,x3,y3,x4,y4){ \/\/less lines\n    line(x1,y1,x2,y2);\n    line(x3,y3,x4,y4);\n    numLines=20;\n    dx1=(x2-x1)\/numLines;\n    dy1=(y2-y1)\/numLines;\n    dx3=(x3-x4)\/numLines;\n    dy3=(y3-y4)\/numLines;\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1,y1,x3,y3);\n        x1 += dx1;\n        y1 += dy1;\n        x3 -= dx3;\n        y3 -= dy3; \n    }\n}\n\nfunction diagonals3(x1,y1,x2,y2,x3,y3,x4,y4){ \/\/less lines second version\n    line(x1,y1,x2,y2);\n    line(x3,y3,x4,y4);\n    numLines=30;\n    dx1=(x2-x1)\/numLines;\n    dy1=(y2-y1)\/numLines;\n    dx3=(x3-x4)\/numLines;\n    dy3=(y3-y4)\/numLines;\n    for (var i = 0; i &lt;= numLines; i += 1) {\n        line(x1,y1,x3,y3);\n        x1 += dx1;\n        y1 += dy1;\n        x3 -= dx3;\n        y3 -= dy3; \n    }\n}\n<\/code><\/pre><\/div><\/body><\/html>\n","protected":false},"excerpt":{"rendered":"<p>Although it&rsquo;s a bit abstract, but it is a pineapple. Everything is made by &ldquo;string&rdquo;. sketchDownload \/* Jiayi Chen jiayiche Section A *\/ function setup() { createCanvas(300, 400); background(&#8216;yellow&#8217;); } var numLines = 50; var dx1; var dy1; var dx2; var dy2; function draw() { \/\/ percentize width and height var w= width\/100; var h= &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/2022\/09\/24\/project-04-string-art-pineapple\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Project-04:\u00a0String Art-Pineapple&#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":[102,55],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72941"}],"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=72941"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72941\/revisions"}],"predecessor-version":[{"id":72956,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/posts\/72941\/revisions\/72956"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/media?parent=72941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/categories?post=72941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/15-104\/f2022\/wp-json\/wp\/v2\/tags?post=72941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}