{"id":210,"date":"2015-06-19T14:00:23","date_gmt":"2015-06-19T10:00:23","guid":{"rendered":"http:\/\/courses.haigarmen.com\/creativecoding\/?p=210"},"modified":"2015-06-23T09:09:59","modified_gmt":"2015-06-23T05:09:59","slug":"bonus-glitch","status":"publish","type":"post","link":"https:\/\/courses.haigarmen.com\/creativecoding\/bonus-glitch\/","title":{"rendered":"Bonus: Glitch"},"content":{"rendered":"<pre><code>\r\n\r\nPImage img;\r\nint min = 40, max = 80;\r\nint r = 10;\r\n \r\nvoid setup() {\r\n  img = loadImage(\"https:\/\/s-media-cache-ak0.pinimg.com\/736x\/2c\/f6\/a5\/2cf6a58f75b368949cf98db03b925f1b.jpg\");\r\n  size(img.width, img.height);\r\n  image(img,0,0);\r\n}\r\n \r\nvoid draw() {\r\n  int w = (int)random(min, max);\r\n  int h = int(w*3);\r\n  int x = (int)random(0, width-w);\r\n  int y = (int)random(0, height-h);\r\n  PImage tmp = createImage(w, h, RGB);\r\n  tmp.loadPixels();\r\n  float rd = random(1);\r\n  for (int px=0; px < w; px++) {\r\n    for (int py=0; py < h; py++) {\r\n      if (rd>0.1) {\r\n      tmp.pixels[py*w+px]=img.get(x+px, y+py);\r\n      } else {\r\n      tmp.pixels[py*w+px]=color(0);\r\n      }\r\n    }\r\n  }\r\n  tmp.updatePixels();\r\n  \r\n  int v = (int)random(-r, r);\r\n  fill(100,100);\r\n  noStroke();\r\n  int e = 2;\r\n  rect(x+v+1,y+v+1,w+e,h+e);\r\n  fill(255,255);  \r\n  rect(x+v-e\/2,y+v-e\/2,w+e,h+e);\r\n  \r\n  image(tmp, x+v, y+v);\r\n}\r\n \r\nvoid keyPressed() {\r\n  save(random(123456)+\".jpg\");\r\n \r\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PImage img; int min = 40, max = 80; int r = 10; void setup() { img = loadImage(&#8220;https:\/\/s-media-cache-ak0.pinimg.com\/736x\/2c\/f6\/a5\/2cf6a58f75b368949cf98db03b925f1b.jpg&#8221;); size(img.width, img.height); image(img,0,0); } void draw() { int w = (int)random(min, max); int h = int(w*3); int x = (int)random(0, width-w); int y = (int)random(0, height-h); PImage tmp = createImage(w, h, RGB); tmp.loadPixels(); float rd = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-210","post","type-post","status-publish","format-standard","hentry","category-lessons"],"_links":{"self":[{"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts\/210","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/comments?post=210"}],"version-history":[{"count":3,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts\/210\/revisions"}],"predecessor-version":[{"id":226,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/posts\/210\/revisions\/226"}],"wp:attachment":[{"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/media?parent=210"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/categories?post=210"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.haigarmen.com\/creativecoding\/wp-json\/wp\/v2\/tags?post=210"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}