{"id":13133,"date":"2010-08-17T07:00:00","date_gmt":"2010-08-17T07:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2010\/08\/17\/what-was-that-story-about-the-winhelp-pen-writing-in-book-animation\/"},"modified":"2010-08-17T07:00:00","modified_gmt":"2010-08-17T07:00:00","slug":"what-was-that-story-about-the-winhelp-pen-writing-in-book-animation","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20100817-00\/?p=13133","title":{"rendered":"What was that story about the WinHelp pen-writing-in-book animation?"},"content":{"rendered":"<p>\nThe first time you open a WinHelp file,\nyou get this pen-writing-in-book animation while WinHelp\ndoes um <i>something<\/i> which it passes off as\n<i>preparing Help file for first use<\/i> or something\nsimilarly vague.\n<\/p>\n<p>\nI remember a conversation about that animation.\nThe Windows shell team suggested to the author of WinHelp that\nthe program use the shell common animation control to display\nthat animation.\nAfter all, it&#8217;s a short animation and it met\n<a HREF=\"http:\/\/blogs.msdn.com\/oldnewthing\/archive\/2005\/02\/16\/374397.aspx\">\nthe requirements for the animation common control<\/a>.\nBut the author of WinHelp rejected the notion.\n<\/p>\n<p>\n(Pre-emptive &#8220;I can&#8217;t believe I had to write this&#8221;:\nThis conversation has been exaggerated for effect.)\n<\/p>\n<p>\n&#8220;Your animation control is so huge and bloated.\nI can do it much smaller and faster myself.\nThe RLE animation format generates frames by\nre-rendering the pixels that have changed,\nwhich means that at each frame of the animation,\na new pen image would be recorded in the AVI file.\nThe pen cycles through three different orientations at each location,\nthere are ten locations on each row,\nand there are four rows.\nIf I used an RLE animation, that&#8217;d be\n3&nbsp;&times;&nbsp;10&nbsp;&times;&nbsp;4&nbsp;=&nbsp;120\ncopies of the pen bitmap.\nInstead, I have just three pen bitmaps, and I manually draw\nthem at the appropriate location for each frame.\nSomething like this:\n<\/p>\n<pre>\n\/\/ NOTE: For simplicity, I'm ignoring the \"turn the page\" animation\nvoid DrawFrame(int frame)\n{\n  \/\/ Calculate our position in the animation\n  int penframe = frame % 3; \/\/ 3 pen images per location\n  int column = (frame \/ 3) % 10; \/\/ 10 columns per row\n  int row = (frame \/ 30) % 4; \/\/ 4 rows\n  int i;\n  POINT pt;\n  DrawBlankPage(0, 0); \/\/ start with a blank sheet of paper\n  \/\/ Draw the \"text\" that the pen \"wrote\" in earlier rows\n  for (i = 0; i &lt; row; i++) {\n    DrawTextScribble(i, 0, 9);\n  }\n  \/\/ Draw the partially-completed row that the pen is on now\n  DrawTextScribble(row, 0, column);\n  \/\/ Position the pen image so the pen tip hits the &quot;draw&quot; point\n  GetTextScribblePoint(column, row, &amp;pt);\n  DrawPenBitmap(penBitmaps[penframe], pt.x - 1, pt.y - 5);\n}\n<\/pre>\n<p>\n&#8220;See?\nIn just a few lines of code, I have a complete animation.\nAll I needed was the three pen images and a background bitmap\nshowing a book opened to a blank page.\nThis is way more efficient both in terms of memory and execution time\nthan your stupid animation common control.\nYou shell guys could learn a thing or two about programming.&#8221;\n<\/p>\n<p>\n&#8220;Okay, fine, don&#8217;t need to get all defensive about it.\nWe were just making a suggestion, that&#8217;s all.&#8221;\n<\/p>\n<p>\nTime passes,\nand\nWindows&nbsp;95 is sent off for translation into the however\nmany languages it is localized for.\nA message comes in from some of the localization teams.\nIt seems that some locales need to change the animation.\nFor example, the Arabic version of Windows needs\nthe pen to write on the left-hand pages,\nthe pen motion should be right to left,\nand the pages need to flip from left to right.\nPerhaps the Japanese translators are okay with the pen motion,\nbut they want the pages to flip from left to right.\n<\/p>\n<p>\nThe localization team contacted the WinHelp author.\n&#8220;We&#8217;re trying to change the animation, but we can&#8217;t find the AVI file\nin the resources.\nCan you advise us on how we should localize the animation?&#8221;\n<\/p>\n<p>\nUnfortunately, the WinHelp author had to tell the localization team\nthat the direction of pen motion,\nand the locations of the ink marks\nare hard-coded into the program.\nSince the product had already passed code lockdown,\nthere was nothing that could be done.\nWinHelp shipped with a pen that moved\nin the wrong direction in some locales.\n<\/p>\n<p>\nMoral of the story:\nThere&#8217;s more to software development than programming for performance.\nToday we learned about localizability.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The first time you open a WinHelp file, you get this pen-writing-in-book animation while WinHelp does um something which it passes off as preparing Help file for first use or something similarly vague. I remember a conversation about that animation. The Windows shell team suggested to the author of WinHelp that the program use the [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-13133","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>The first time you open a WinHelp file, you get this pen-writing-in-book animation while WinHelp does um something which it passes off as preparing Help file for first use or something similarly vague. I remember a conversation about that animation. The Windows shell team suggested to the author of WinHelp that the program use the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/13133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=13133"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/13133\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=13133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=13133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=13133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}