{"id":503,"date":"2021-09-08T13:29:00","date_gmt":"2021-09-08T17:29:00","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/?p=503"},"modified":"2021-09-08T13:31:13","modified_gmt":"2021-09-08T17:31:13","slug":"aahdee-linewalk","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/aahdee\/09\/08\/aahdee-linewalk\/","title":{"rendered":"aahdee &#8211; LineWalk"},"content":{"rendered":"<p><a href=\"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/output-1.svg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-505\" src=\"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/output-1.svg\" alt=\"\" width=\"640\" height=\"480\" \/><\/a> <img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-506\" src=\"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Screenshot-2021-09-08-132620-507x480.png\" alt=\"\" width=\"507\" height=\"480\" srcset=\"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Screenshot-2021-09-08-132620-507x480.png 507w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Screenshot-2021-09-08-132620-768x727.png 768w, https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-content\/uploads\/2021\/09\/Screenshot-2021-09-08-132620.png 981w\" sizes=\"(max-width: 507px) 85vw, 507px\" \/><\/p>\n<p>I wanted to do a modified version of an Sierpinski diagram. It was pretty fun to mess around with beginShape(), endShape(), and for loops. I wanted to make it more complex, but I got sleepy from the trig.<\/p>\n<p>I can change the depth and size of the diagram at will, which is nice.<\/p>\n<p>Code is below the read more.<\/p>\n<p><!--more--><\/p>\n<pre>import processing.svg.*;\r\nfloat ax, ay, bx, by, cx, cy;\r\n\r\nvoid setup(){\r\n  size(1000, 1000);\r\n  surface.setLocation(50,50);\r\n  noFill();\r\n  noLoop();\r\n  beginRecord(SVG, \"output.svg\");\r\n}\r\n\r\nvoid draw(){\r\n  beginShape();\r\n  for(int i = 0; i &lt; 7; i++){\r\n    nestedTri(width\/2, height\/2+100, pow(2,i)*15,60*i);\r\n    \/\/nestedTri(width\/2, height\/2+100, pow(2,i)*100,60*i);\r\n}\r\n  vertex(width\/2,height\/2+100);\r\n  endShape();\r\n  endRecord();\r\n  \r\n}\r\n\r\n\r\nvoid nestedTri(float x, float y, float size, int angle){\r\n  \/\/x,y is midpoint location\r\n  \/\/size is side length\r\n  \/\/want to start at side, end at 1st hit vertex after drawing others\r\n  float apo = ((size\/2)*sqrt(3))\/3;\r\n  float x_, y_,a;\r\n  a = radians(angle);\r\n  \r\n  \/\/begin shape\/end shape cannot contain rotate, \r\n  \/\/so i must do all of the rotations by hand\r\n    x_ = x + (0*cos(a) - (apo)*sin(a));\r\n    y_ = y + (0*sin(a) + (apo)*cos(a));\r\n  \r\n    vertex(x_,y_);\r\n    \r\n    \r\n    x_ = x + ((size\/2)*cos(a) - (apo)*sin(a));\r\n    y_ = y + ((size\/2)*sin(a) + (apo)*cos(a));\r\n    ax = x_;\r\n    ay = y_;\r\n    \r\n    vertex(ax,ay);\r\n    vertex(x,y);\r\n    vertex(ax,ay);\r\n    \r\n    x_ = x + (0*cos(a) - (-2*apo)*sin(a));\r\n    y_ = y + (0*sin(a) + (-2*apo)*cos(a));\r\n    \r\n    bx = x_;\r\n    by = y_;\r\n    vertex(bx,by);\r\n    vertex(x,y);\r\n    vertex(bx,by);\r\n\r\n    \r\n    x_ = x+ ((-size\/2)*cos(a) - (apo)*sin(a));\r\n    y_ = y+ ((-size\/2)*sin(a) + (apo)*cos(a));\r\n    \r\n    cx = x_;\r\n    cy = y_;\r\n    vertex(cx,cy);\r\n    vertex(x,y);\r\n    vertex(cx,cy);\r\n    \r\n    \r\n    \r\n    vertex(ax,ay);\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I wanted to do a modified version of an Sierpinski diagram. It was pretty fun to mess around with beginShape(), endShape(), and for loops. I wanted to make it more complex, but I got sleepy from the trig. I can change the depth and size of the diagram at will, which is nice. Code is &hellip; <a href=\"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/aahdee\/09\/08\/aahdee-linewalk\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;aahdee &#8211; LineWalk&#8221;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/posts\/503"}],"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\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/comments?post=503"}],"version-history":[{"count":3,"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/posts\/503\/revisions"}],"predecessor-version":[{"id":521,"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/posts\/503\/revisions\/521"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/media?parent=503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/categories?post=503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/60-428\/f2021\/wp-json\/wp\/v2\/tags?post=503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}