{"id":432,"date":"2011-12-19T18:24:55","date_gmt":"2011-12-20T02:24:55","guid":{"rendered":"http:\/\/new.joyofprocessing.com\/blog\/?p=432"},"modified":"2011-12-19T18:24:55","modified_gmt":"2011-12-20T02:24:55","slug":"recursive-subdivision-landscape","status":"publish","type":"post","link":"https:\/\/joyofprocessing.com\/blog\/2011\/12\/recursive-subdivision-landscape\/","title":{"rendered":"Recursive Subdivision Landscape"},"content":{"rendered":"<p><script type=\"application\/processing\">\/\/ Recursive Subdivision Scape - Jim Bumgardner\n\nvoid setup()\n{\n  size(500,500);\n  smooth();\n}\n\nvoid recurseRect(float x, float y, float w, float h)\n{\n  float pw = min(random(min(w,h)),width\/3);\n  float ph = pw;\n  float px = random(x,x+w-pw);\n  float py = random(y,y+h-pw);\n  rect(px+.5,py+.5,pw-1,pw-1);\n\n  if (w < 3 || h < 3)\n    return;\n\n  if (h > w) {\n    recurseRect( x,y,w,py-y);\n    recurseRect( x,py,px-x,ph);\n    recurseRect( px+pw,py,x+w-(px+pw),ph);\n    recurseRect( x,py+ph,w,y+h-(py+ph));\n\n  } else {\n    recurseRect( x,y,px-x,h);\n    recurseRect( px,y,pw,py-y);\n    recurseRect( px,py+ph,pw,y+h-(py+ph));\n    recurseRect( px+pw,y,x+w-(px+pw),h);\n  }\n}\n\nvoid draw()\n{\n  float r = millis()*.0001;\n  int ri = int(r);\n  r -= ri;\n  fill(255,r*255);\n  rect(0,0,width,height);\n  fill(0,r*255);\n  randomSeed(ri);\n  recurseRect(0,0,width,height); \/\/ -width\/2,-height\/2,width*2,height*2);  \n}\n\n<\/script><\/p>\n<div class=\"ps_cap\"><a href=\"\/showexample.php?ex=recursive_scape\">source<\/a><\/div>\n<p>\n","protected":false},"excerpt":{"rendered":"<p>source<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-432","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/posts\/432","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/comments?post=432"}],"version-history":[{"count":3,"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/posts\/432\/revisions"}],"predecessor-version":[{"id":435,"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/posts\/432\/revisions\/435"}],"wp:attachment":[{"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/media?parent=432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/categories?post=432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/tags?post=432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}