{"id":18169,"date":"2014-01-31T16:57:26","date_gmt":"2014-01-31T16:57:26","guid":{"rendered":"http:\/\/rafaelfajardo.com\/portfolio\/notational-hamoid-minimal-drawing-program\/"},"modified":"2018-12-05T19:50:07","modified_gmt":"2018-12-06T02:50:07","slug":"notational-hamoid-minimal-drawing-program","status":"publish","type":"post","link":"https:\/\/rafaelfajardo.com\/portfolio\/notational-hamoid-minimal-drawing-program\/","title":{"rendered":""},"content":{"rendered":"<div id='gallery-1' class='gallery galleryid-18169 gallery-columns-3 gallery-size-thumbnail'><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/rafaelfajardo.com\/portfolio\/notational-hamoid-minimal-drawing-program\/attachment\/18170\/'><img loading=\"lazy\" decoding=\"async\" width=\"100\" height=\"100\" src=\"https:\/\/rafaelfajardo.com\/portfolio\/wp-content\/uploads\/tumblr_n09oddYOt21qz62bdo1_500-100x100.png\" class=\"attachment-thumbnail size-thumbnail\" alt=\"\" srcset=\"https:\/\/rafaelfajardo.com\/portfolio\/wp-content\/uploads\/tumblr_n09oddYOt21qz62bdo1_500-100x100.png 100w, https:\/\/rafaelfajardo.com\/portfolio\/wp-content\/uploads\/tumblr_n09oddYOt21qz62bdo1_500-300x300.png 300w, https:\/\/rafaelfajardo.com\/portfolio\/wp-content\/uploads\/tumblr_n09oddYOt21qz62bdo1_500.png 500w\" sizes=\"auto, (max-width: 100px) 100vw, 100px\" \/><\/a>\n\t\t\t<\/div><\/figure>\n\t\t<\/div>\n\n<p><a class=\"tumblr_blog\" href=\"http:\/\/notational.tumblr.com\/post\/75157693369\/hamoid-minimal-drawing-program-with-undo\">notational<\/a>:<\/p>\n<blockquote>\n<p><a class=\"tumblr_blog\" href=\"http:\/\/hamoid.tumblr.com\/post\/75146464526\/minimal-drawing-program-with-undo-press-z\">hamoid<\/a>:<\/p>\n<blockquote>\n<pre>\/\/ Minimal drawing program with undo\n\/\/ Press 'z' to undo<br \/><br \/>\/\/ Note: there is a bug affecting Chrome 32 and Processing.js 1.4.1<br \/>\/\/ <a href=\"http:\/\/processing-js.lighthouseapp.com\/projects\/41284-processingjs\/tickets\/2066\"><\/a><a href=\"http:\/\/processing-js.lighthouseapp.com\/projects\/41284-processingjs\/tickets\/2066\">http:\/\/processing-js.lighthouseapp.com\/projects\/41284-processingjs\/tickets\/2066<\/a><br \/>\/\/ In Chrome 32, open this post alone and scroll to the top.\n\nint levelsOfUndo = 10;\nint currImageId = 0;\n\/\/ circular array of images where to store undo levels\nPImage[] images = new PImage[levelsOfUndo];\n\nvoid setup() {\n  size(500, 500);\n  background(255);\n  \/\/ Initialize all undo levels\n  for(int i=0; i&lt;levelsOfUndo; i++) {\n    images[i] = createImage(width, height, RGB);\n    \/\/ undo levels are initialized as copies of the blank screen\n    images[i] = get();\n  }\n}\nvoid draw() {\n  if(mousePressed) {\n    line(mouseX, mouseY, pmouseX, pmouseY);\n  }\n}\nvoid mousePressed() {\n  \/\/ increase the pointer of a circular array\n  currImageId = (currImageId + 1) % levelsOfUndo;\n}\nvoid mouseReleased() {\n  \/\/ save a copy of the display\n  images[currImageId] = get();\n}\nvoid keyPressed() {\n  if(key=='z') {\n    \/\/ decrease the pointer of a circular array\n    currImageId = (currImageId - 1 + levelsOfUndo) % levelsOfUndo;\n    \/\/ bring back an old image\n    image(images[currImageId], 0, 0);\n  }\n  if(key=='s') {\n    saveFrame(\"image####.png\");\n  }\n}\n<\/pre>\n<\/blockquote>\n<p>Wow. Great! As per request on <a href=\"http:\/\/fyprocessing.tumblr.com%20\" title=\"fyprocessing.tumblr.com\">fyprocessing.tumblr.com<\/a> earlier this week\u2026..drawing with undo. Hamoid makes it look easy. Wonderful work. What a wonderful person and a wonderful sharing community of coders.<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>notational: hamoid: \/\/ Minimal drawing program with undo \/\/ Press &#8216;z&#8217; to undo\/\/ Note: there is a bug affecting Chrome 32 and Processing.js 1.4.1\/\/ http:\/\/processing-js.lighthouseapp.com\/projects\/41284-processingjs\/tickets\/2066\/\/ In Chrome 32, open this post alone and scroll to the top. int levelsOfUndo = 10; int currImageId = 0; \/\/ circular array of images where to store undo levels [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"gallery","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[10],"tags":[],"class_list":["post-18169","post","type-post","status-publish","format-gallery","hentry","category-words","post_format-post-format-gallery"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p6PWot-4J3","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/posts\/18169","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/comments?post=18169"}],"version-history":[{"count":1,"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/posts\/18169\/revisions"}],"predecessor-version":[{"id":18171,"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/posts\/18169\/revisions\/18171"}],"wp:attachment":[{"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/media?parent=18169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/categories?post=18169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rafaelfajardo.com\/portfolio\/wp-json\/wp\/v2\/tags?post=18169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}