{"id":1036,"date":"2021-09-21T22:16:18","date_gmt":"2021-09-22T02:16:18","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/?p=1036"},"modified":"2021-09-21T22:16:18","modified_gmt":"2021-09-22T02:16:18","slug":"grape-hatching","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/grape\/09\/21\/grape-hatching\/","title":{"rendered":"grape &#8211; Hatching"},"content":{"rendered":"<p><a href=\"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/foo_415.svg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-1038\" src=\"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-18-2021-at-18_58_52-310x480.png\" alt=\"\" width=\"310\" height=\"480\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-18-2021-at-18_58_52-310x480.png 310w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-18-2021-at-18_58_52-660x1024.png 660w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-18-2021-at-18_58_52-768x1191.png 768w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-18-2021-at-18_58_52-991x1536.png 991w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-18-2021-at-18_58_52-1321x2048.png 1321w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-18-2021-at-18_58_52-1200x1861.png 1200w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-18-2021-at-18_58_52.png 1787w\" sizes=\"(max-width: 310px) 85vw, 310px\" \/><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-1037\" src=\"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/foo_415.svg\" alt=\"\" width=\"640\" height=\"480\" \/><\/a>The first hatching method is just a bunch of smiley faces in a grid. The second is a bunch of circles in a grid. The third is some vertical lines, but I added so random lines offset by an amount ranging from 0 to the width of the square grid. The last one is a set of three bezier curves. I didn&#8217;t use any external code apart from the grid set up posted in easement 2. I think the difficulty came with trying to make sure they were all the same amount of dark. The third row was especially hard to tune because the vertical lines just appeared so much lighter than the other rows, in part because the colors still looked separate.<\/p>\n<p>Scan of the print (lol):<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-1060\" src=\"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-21-2021-at-22_13_52-480x480.png\" alt=\"\" width=\"480\" height=\"480\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-21-2021-at-22_13_52-480x480.png 480w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-21-2021-at-22_13_52-1024x1024.png 1024w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-21-2021-at-22_13_52-150x150.png 150w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-21-2021-at-22_13_52-768x768.png 768w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-21-2021-at-22_13_52-1536x1536.png 1536w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-21-2021-at-22_13_52-1200x1200.png 1200w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Scannable-Document-on-Sep-21-2021-at-22_13_52.png 1652w\" sizes=\"(max-width: 480px) 85vw, 480px\" \/><\/p>\n<p><code><\/code><\/p>\n<pre>import processing.svg.*;\r\n\r\nfloat[] percentList = {0.10, 0.30, 0.50, 0.70, 0.90};\r\nint nSquares = percentList.length;\r\n\r\nvoid setup() {\r\n  size(800, 800);\r\n}\r\n\r\nvoid draw() {\r\n  background(250);\r\n  int now = millis();\r\n  randomSeed(now);\r\n  beginRecord(SVG, \"foo_\" + now + \".svg\");\r\n  noFill();\r\n  int offset = (height\/4 - int(width\/nSquares))\/2;\r\n  grid(offset, 0);\r\n  grid(height\/4 + offset, 1);\r\n  grid(height\/2 + offset, 2);\r\n  grid(3*height\/4 + offset, 3);\r\n\r\n  endRecord();\r\n  noLoop();\r\n}\r\n\r\nvoid keyPressed() {\r\n  loop();\r\n}\r\n\r\n\r\nvoid grid(int posY, int func) {\r\n  for (int i=0; i&lt;nSquares; i++) {\r\n    float rS = width\/nSquares;\r\n    float rL = i*rS;\r\n    float rR = rL + rS;\r\n    float rT = posY;\r\n    float rB = rT + rS;\r\n\r\n    float hatchPercent = percentList[i];\r\n    float nLinesToDraw = round(hatchPercent * rS\/3.2);\r\n    if(func==0) nLinesToDraw = round(hatchPercent * rS\/2.3);\r\n    if(func==1) nLinesToDraw = round(hatchPercent * rS\/1.8);\r\n    if(func==2) nLinesToDraw = round(hatchPercent * rS\/3);\r\n    float offset = (rS\/nLinesToDraw)\/2;\r\n\r\n    \/\/ Vertical line version\r\n    for (int j=0; j&lt;nLinesToDraw; j++) {\r\n      for (int k=0; k&lt;nLinesToDraw; k++) {\r\n        float lx = map(j, 0, nLinesToDraw, rL, rR);\r\n        float ly = map(k, 0, nLinesToDraw, rT, rB);\r\n        switch(func) {\r\n        case 0:\r\n          hatch_1(lx+offset, ly+offset, offset);\r\n          break;\r\n        case 1:\r\n          hatch_2(lx, ly, offset);\r\n          break;\r\n        case 2:\r\n          hatch_3(lx+offset, map(min(k+1, nLinesToDraw), 0, nLinesToDraw, rT, rB)+ random(-0.5,0.5), map(max(k-1, 0), 0, nLinesToDraw, rT, rB)+ random(-0.5,0.5));\r\n          hatch_3(min(max(rL,lx + random(-0.5, 0.5)*offset),rR), map(min(k+1, nLinesToDraw), 0, nLinesToDraw, rT, rB)+ random(-0.5, 0.5), map(max(k-1, 0), 0, nLinesToDraw, rT, rB)+ random(-0.5,0.5));\r\n          break;\r\n        case 3:\r\n          hatch_4(lx, ly, offset);\r\n          break;\r\n        }\r\n\r\n\r\n        \/\/hatch_1(lx,ly);\r\n      }\r\n    }\r\n  }\r\n}\r\n\r\nvoid hatch_1(float posX, float posY, float rad) {\r\n  float smile_start = random(0, QUARTER_PI);\r\n  float n = random(0.3,1) * 3*PI\/4;\r\n  float radX = random(0.5,1)*rad*2;\r\n  float radY = random(0.5,1)*rad*2;\r\n  arc(posX, posY, radX, radY, smile_start, smile_start +QUARTER_PI+n);\r\n  circle(posX + random(-0.25,0)*rad,posY+ random(-0.2,0.2)*rad,1);\r\n  circle(posX + random(0,0.25)*rad,posY+ random(-0.2,0.2)*rad,1);\r\n}\r\n\r\nvoid hatch_2(float posX, float posY,float offset) {\r\n  circle(posX+offset, posY+offset, offset);\r\n}\r\n\r\nvoid hatch_3(float posX, float inc1, float inc2) {\r\n  line(posX, inc2, posX, inc1);\r\n}\r\n\r\nvoid hatch_4(float posX, float posY, float offset) {\r\n  bezier(posX,posY,posX+2*offset - random(1)*2*offset, posY+2*offset,posX+random(1)*2*offset,posY,posX+2*offset, posY+2*offset);\r\n  bezier(posX+offset,posY,posX+2*offset - random(1)*offset, posY+offset,posX+random(1)*offset,posY,posX+2*offset, posY+offset);\r\n  bezier(posX,posY+offset,posX+offset - random(1)*offset, posY+2*offset,posX+random(1)*offset,posY,posX+offset, posY+2*offset);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The first hatching method is just a bunch of smiley faces in a grid. The second is a bunch of circles in a grid. The third is some vertical lines, but I added so random lines offset by an amount ranging from 0 to the width of the square grid. The last one is a &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/grape\/09\/21\/grape-hatching\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;grape &#8211; Hatching&#8221;<\/span><\/a><\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/posts\/1036"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/comments?post=1036"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/posts\/1036\/revisions"}],"predecessor-version":[{"id":1061,"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/posts\/1036\/revisions\/1061"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/media?parent=1036"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/categories?post=1036"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/tags?post=1036"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}