<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-6615951333885165843</atom:id><lastBuildDate>Sat, 05 Oct 2024 02:02:42 +0000</lastBuildDate><category>js</category><category>mcpc2012</category><category>C++</category><category>Misc</category><category>problem</category><category>Blogger</category><category>InputCanvas</category><category>angular</category><category>html5</category><category>matrixify</category><category>python</category><category>sublimetext2</category><category>Ubuntu</category><category>android</category><category>canvas</category><category>php</category><title>Jaw,B</title><description></description><link>http://jawbfl.blogspot.com/</link><managingEditor>noreply@blogger.com (Anonymous)</managingEditor><generator>Blogger</generator><openSearch:totalResults>20</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-690324368881306041</guid><pubDate>Sat, 19 Apr 2014 18:00:00 +0000</pubDate><atom:updated>2014-04-20T13:13:38.812+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Misc</category><title>New era of version control systems</title><description>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&quot;&lt;i&gt;Revision control, also known as version control and source control ... is the management of changes to documents, computer programs, large web sites, and other collections of information&lt;/i&gt;&quot;. That what wikipedia says about VCS, also in the overview they define a VCS as &quot;&lt;i&gt;... any kind of practice that tracks and provides control over changes to source code.&lt;/i&gt;&quot;
&lt;br /&gt;
&lt;br /&gt;
Today, you can find many great, good, bad and ugly version control systems like Git, Mercurial, Bazzar, SVN, CVS [order is not arbitrary]... but It turns out none of them is good enough for the company, a company that a friend of mine has interned at and told me about their ultimate VCS.&lt;br /&gt;
&lt;br /&gt;
In this company - a well known multinational company that I&#39;m not going to name -, if you want to proceed with a change you don&#39;t need to fork or clone or pull. What you do is that you duplicate the lines that you are willing to change, then comment the old ones and put a comment before and after the new code where you put an ID. To get this ID you insert a record in a Microsoft Access database where you specify changes and reasons etc, then you get the ID of that record and put it back in the comment. Changes are copied manually and added to the master if they are correct and god knows what test system they have.&lt;br /&gt;
&lt;br /&gt;
Wow, amazing !! I couldn&#39;t believe this reactionary VCS, and what are the reasons behind this choice. And yes I called it a VCS because it&#39;s a &quot;&lt;i&gt;... practice that tracks and provides control over changes to source code&lt;/i&gt;&quot;.&lt;/div&gt;
</description><link>http://jawbfl.blogspot.com/2014/04/new-era-of-version-control-systems.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-5501917210832444572</guid><pubDate>Thu, 18 Jul 2013 00:31:00 +0000</pubDate><atom:updated>2013-07-18T00:36:02.430+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">angular</category><category domain="http://www.blogger.com/atom/ns#">Blogger</category><title>Blogger &amp; AngularJs - Is it a better love story than Twilight ?</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
I shared recently &lt;a href=&quot;http://jawbfl.blogspot.com/#/post/rebuilding-jawb-blog&quot;&gt;a post&lt;/a&gt; about how I got that idea to use AngularJs with Blogger using RSS as a resource and modding comments. Today, I want to share with you my impressions after two weeks since I launched the experiment.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Disclaimer:&lt;/u&gt;&lt;/b&gt; The experiment was on this blog, it&#39;s a small personal blog with minimalistic design, limited number of posts and few visitors, so my judgement will be based on those facts. Behavior on larger blogs isn&#39;t guaranteed to be the same.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;What I like about it ?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
It&#39;s very light, swift and fast, the page is visible quickly even with using a custom font and many base64 resources, not to mention that Angular for a reason that I don&#39;t understand loads resources for all posts even if they aren&#39;t rendered nor in the DOM yet !!!
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
First time load :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVsjVDGisKtg0EmC59i8g1s-iL5mghVcC7Gw-ICtpt9aOfaOQTBq0NptUUezrLdGzB6ckHT4zfv8mF91D4VMx4xvhVDPsvOE-Io3mS1_9CvRhRNWbjV1pA4VQCb3vmAtIFQcIQnRhmP_1p/s1600/refresh.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;168&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVsjVDGisKtg0EmC59i8g1s-iL5mghVcC7Gw-ICtpt9aOfaOQTBq0NptUUezrLdGzB6ckHT4zfv8mF91D4VMx4xvhVDPsvOE-Io3mS1_9CvRhRNWbjV1pA4VQCb3vmAtIFQcIQnRhmP_1p/s640/refresh.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
From cache :&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFIitkjrAk4fq81I1Ox6_53Gh-yzjL5D5lfvWUcnyi-2CKR8pv-TPWU5Yyim3o8EvMFSq5XLPcTxMxAAxz0tl1Y8btZJiFD8BllsyYkdq4GAXujKNix40DB4AK5LRIATyPKl6lhyphenhyphenMnTsyn/s1600/enter.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;166&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFIitkjrAk4fq81I1Ox6_53Gh-yzjL5D5lfvWUcnyi-2CKR8pv-TPWU5Yyim3o8EvMFSq5XLPcTxMxAAxz0tl1Y8btZJiFD8BllsyYkdq4GAXujKNix40DB4AK5LRIATyPKl6lhyphenhyphenMnTsyn/s640/enter.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
The first time load time is a bit high, but after that user can navigate almost instantly. For a blog it might not be a best practice because people usually look for a specific post so loading other posts isn&#39;t that brilliant. I&#39;m planing to solve the problem by parsing portions of the XML from the RSS feed and not the whole file at once.&lt;br /&gt;
&lt;br /&gt;
Comments are pretty too, I always hated Blogger&#39;s comment from it&#39;s an ugly thing with that terrible design and poor experience in an iframe. The wordpress inspired comments form seems like a usable one with Gravatar and URL.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;What I don&#39;t like ?&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
The worst thing about this experiment is SEO, search engines aren&#39;t able to index pages because of dynamic content that changes in run time, which makes the pre-rendered HTML -in general empty- invalid for search engines. There is &lt;a href=&quot;http://www.yearofmoo.com/2012/11/angularjs-and-seo.html&quot;&gt;this great article&lt;/a&gt; that will work for you if you have your Angular app hosted on your server. Also, preview functionality doesn&#39;t work too&lt;br /&gt;
&lt;br /&gt;
Moreover, Analytics doesn&#39;t work well with URLs with hashes, I can&#39;t get detailed analytics for a post anymore. I found a workaround that I will try later and post results.&lt;br /&gt;
&lt;br /&gt;
There is a dark side for comments as well, sometimes it will redirect you to Blogger&#39;s comment form and display the supposed to be hidden JSON object and maybe impose a Captcha test, and it will redirect you to the old URL of the post.&lt;br /&gt;
&lt;br /&gt;
It&#39;s sad that the Web still doesn&#39;t work well with hashbang URLs without fallback links, even if it&#39;s an old practice, I had a headache to make Twitter&#39;s button accept a URL with a hash !!! &amp;nbsp;The bottom line is that search engines and Analytics should provide tools to support hashbang URLs in a time that many people are relying on javascript MVC frameworks.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Conclusion&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
Blogger and AngularJs, these two sons of Google doesn&#39;t seem to like each other so much -which make them good brothers by the way- but of course It&#39;s a better love story than Twilight (everything on earth is), loading time and improved comments (when they work correctly) are a gain. But SEO and Analytics make it not the best thing to do if you really want to spread your posts while keeping an eye on your blog.&lt;br /&gt;
For me a homeless dude like me should keep good care of his spot on blogspot until I get a host :) but having blogs on blogger for 4 years makes me understand the platform and keep improving and experimenting.</description><link>http://jawbfl.blogspot.com/2013/07/blogger-angularjs-is-it-better-love.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVsjVDGisKtg0EmC59i8g1s-iL5mghVcC7Gw-ICtpt9aOfaOQTBq0NptUUezrLdGzB6ckHT4zfv8mF91D4VMx4xvhVDPsvOE-Io3mS1_9CvRhRNWbjV1pA4VQCb3vmAtIFQcIQnRhmP_1p/s72-c/refresh.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-6685513707516803425</guid><pubDate>Mon, 01 Jul 2013 23:35:00 +0000</pubDate><atom:updated>2013-07-02T00:36:42.571+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">angular</category><category domain="http://www.blogger.com/atom/ns#">html5</category><category domain="http://www.blogger.com/atom/ns#">js</category><title>Rebuilding Jaw,B blog</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Hello everyone, first of all, I think you noticed the comment&#39;s css bug, I don&#39;t know why the comments floats from the parent !! so I decided to redesign the blog and do some optimisations.&lt;br /&gt;
&lt;br /&gt;
I didn&#39;t wanted the whole experience to be just old regular web development, like I used to do. Hence I decided to apply some of the great tools that I installed a long time ago but never used. I began with setting up directories and use &lt;a href=&quot;http://bower.io/&quot;&gt;Bower&lt;/a&gt; to download libraries, then I initialized &lt;a href=&quot;http://guardgem.org/&quot;&gt;Guard&lt;/a&gt; to watch javascript files and concatenate them and do &lt;a href=&quot;http://livereload.com/&quot;&gt;Livereload&lt;/a&gt;. Also, I used &lt;a href=&quot;http://sass-lang.com/&quot;&gt;Sass&lt;/a&gt;, &lt;a href=&quot;http://compass-style.org/&quot;&gt;Compass&lt;/a&gt; and &lt;a href=&quot;http://zengrids.com/&quot;&gt;Zen-grids&lt;/a&gt; for CSS.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
I really liked the workflow, guard is terrific and did a great job keeping my finger away from F5. Sass is good too, I never liked preprocessors but Compass and Zen-grids succeeded in tempting me to try it. The workflow is surely optimized, but I&#39;m not sure if I can say the same about the CSS that still need a review. To be fair, using a preprocessor implies learning the ins and outs of the tool because nesting selectors and media queries randomly or reproducing the DOM tree can generate a terrible CSS. One more tool ,that I&#39;m not sure if I actually used it, is &lt;a href=&quot;http://git-scm.com/&quot;&gt;Git&lt;/a&gt;, I started the project doing some commits during the setup then I forgot about it till the end -_-&#39; .&lt;br /&gt;
&lt;br /&gt;
When the template was ready, fluid and responsive, I had to start making it a blogger template .. I couldn&#39;t accept the idea that I had to deal with those awkward XML tags and the &quot;b:&quot; things !! Then I had the idea to use &lt;a href=&quot;http://angularjs.org/&quot;&gt;AngularJs&lt;/a&gt; the awesome framework to manipulate &lt;a href=&quot;https://support.google.com/blogger/answer/97933?hl=en&quot;&gt;Blogger RSS feed&lt;/a&gt;, it&#39;s XML on the same domain so why not. Few hours after and it&#39;s ready, everything Blogger offers : posts, pagination, tags, displaying comments, social sharing ...&lt;br /&gt;
&lt;br /&gt;
Finally I decided to take it one step further by implementing the wordpress like comments system, the method is explained in the 2 parts tutorial that published a year ago &lt;a href=&quot;http://draft.blogger.com/#/post/blogger-custom-comment-form-wordpress&quot;&gt;part1&lt;/a&gt; , &lt;a href=&quot;http://draft.blogger.com/#/post/blogger-custom-comment-form-wordpress_20&quot;&gt;part2&lt;/a&gt; .&lt;br /&gt;
&lt;br /&gt;
So, here it is a blog on blogger totally free from Blogger&#39;s XML specification you have only to give Blogger an empty b:skin and b:section, Blogger loves b:skin and b:section; That&#39;s the idea, I don&#39;t want to dig into the code because it&#39;s javascript and code is not minified for readability. These method allow to use Blogger as a database and store any type of structured data then read it from RSS, parse it and manipulate it. So if you are homeless like me, here is a new way to live under Blogger&#39;s wings :)</description><link>http://jawbfl.blogspot.com/2013/07/rebuilding-jawb-blog.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-5851359427546622032</guid><pubDate>Sun, 19 May 2013 16:16:00 +0000</pubDate><atom:updated>2013-05-21T12:11:01.216+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">android</category><category domain="http://www.blogger.com/atom/ns#">Ubuntu</category><title>Guide : Installing Android Studio on Ubuntu</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Hi, if you watched (or assisted -if you are that lucky-) the Google I/O then you couldn&#39;t&amp;nbsp;resist installing the&amp;nbsp;new Android development environment &lt;b&gt;the early access preview&lt;/b&gt;. &lt;a href=&quot;http://developer.android.com/sdk/installing/studio.html&quot;&gt;Android Studio&lt;/a&gt; the IDE built on IntelliJ IDEA with a lot of features for Android development and debugging, making the process faster and more productive.&amp;nbsp;Coming&amp;nbsp;with extensible build tools, powerful code editing, smoother and richer GUI .. you can read these stuff&amp;nbsp;&lt;a href=&quot;http://android-developers.blogspot.com/2013/05/android-studio-ide-built-for-android.html&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
So, if you are like me, an Eclipse/ADT user you must wonder why they went with IntelliJ IDEA instead of Eclipse ? they responded with : &quot;Because when we did just Eclipse, people kept asking for IntelliJ support&quot;﻿ , &quot;We will support both Eclipse and the new IntelliJ-based Android Studio. Eclipse support is not going away&quot;. Eclipse is still supported but I&#39;m not that loyal :) to the IDE to stick with it.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Then let&#39;s talk about installing on Ubuntu (this instructions are tested on 12.10 64-bit) :&lt;br /&gt;
First you&#39;ll need to install Oracle Java JDK (now 7.21u) from the official &lt;a href=&quot;http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html&quot;&gt;website &lt;/a&gt;&amp;nbsp;For Linux 64-bit 
tar.gz , you don&#39;t need to install it if you have OpenJDK installed, so just copy it to a location :&lt;br /&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;tar xzvf ~/Downloads/jdk-7u21-linux-x64.tar.gz
sudo mv jdk1.7.0_21/ /usr/lib/jvm/&lt;/pre&gt;
Maybe you&#39;ll need to install some libs because of some issues with adb&lt;br /&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;apt-get install lib32ncurses5 ia32-libs&lt;/pre&gt;
Then you need to set JAVA_HOME to JDK location, to define it on login use .profile file if you don&#39;t have one copy the default one from /etc/profile.&lt;br /&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;cp /usr/profile ~/.profile&lt;/pre&gt;
And add the definition and logout/login to apply changes :&lt;br /&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;export JAVA_HOME=&quot;/usr/lib/jvm/jdk1.7.0_21&quot;&lt;/pre&gt;
Now download Android Studio &lt;a href=&quot;http://developer.android.com/sdk/installing/studio.html&quot;&gt;http://developer.android.com/sdk/installing/studio.html&lt;/a&gt;&amp;nbsp;and extract it :&lt;br /&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;tar xzvf ~/Downloads/android-studio-bundle-130.677228-linux.tgz&lt;/pre&gt;
then copy it to some location, I used /usr/bin&lt;br /&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;sudo mv ~/Downloads/android-studio &amp;nbsp;/usr/bin/android-studio&lt;/pre&gt;
&lt;div&gt;
I added a bigger icon to the directory to use in launcher :&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcjtxTxXJm7tr0YqZHCfpymMw5Hji39OiuL8l0jGbbekpXVcVdjfH2bJQwUhkIyLU_z7q41IGVGVv7H48s_Z7zCcAqMNk-5IXRh8-JVzKdJzthylyvT8EeV5sN_bnevo8VuiMZX2JWyzVP/s1600/AndroidStudioIcon-150x150.png&quot; /&gt;&lt;/div&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;sudo mv ~/Downloads/AndroidStudioIcon-150x150.png &amp;nbsp;/usr/bin/android-studio/icon.png&lt;/pre&gt;
&lt;br /&gt;
To add the IDE to the launcher you need to define a desktop file in /usr/share/applications name it android-studio.desktop with the following content :
&lt;br /&gt;
&lt;pre class=&quot;bash&quot; name=&quot;code&quot;&gt;[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Android Studio
Comment=Android Studio IDE
Exec=/usr/bin/android-studio/bin/studio.sh
Icon=/usr/bin/android-studio/icon.png
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
&lt;/pre&gt;
That&#39;s it, now you can start the app from the launcher on Unity or Gnome normally, also you can switch to the dark theme like the one in the I/O from &lt;b&gt;View &amp;gt; Quick Switch Scheme &amp;gt; Switch Look And Feel &amp;gt; Darcula&amp;nbsp;&lt;/b&gt;.</description><link>http://jawbfl.blogspot.com/2013/05/guide-installing-android-studio-on.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhcjtxTxXJm7tr0YqZHCfpymMw5Hji39OiuL8l0jGbbekpXVcVdjfH2bJQwUhkIyLU_z7q41IGVGVv7H48s_Z7zCcAqMNk-5IXRh8-JVzKdJzthylyvT8EeV5sN_bnevo8VuiMZX2JWyzVP/s72-c/AndroidStudioIcon-150x150.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-8086203423373514116</guid><pubDate>Sat, 09 Mar 2013 01:47:00 +0000</pubDate><atom:updated>2013-03-09T01:52:53.626+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Misc</category><title>Pepper Pyramid - (Hologram) Experiment</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Nothing nerdy this time, I just wanted to share this experiment about pyramid holograms. In fact, many people prefer to call it Pepper Pyramid, called on &lt;a href=&quot;http://en.wikipedia.org/wiki/John_Henry_Pepper&quot;&gt;John Henry Pepper&lt;/a&gt; who created the &lt;a href=&quot;http://en.wikipedia.org/wiki/Pepper&#39;s_ghost&quot;&gt;Pepper&#39;s Ghost effect&lt;/a&gt;. The principle is simple, the four sides of the pyramid are made of reflective glass or plastic so they can reflect four images taken from the sides of the object or scene, and they reflect each others which makes the object looks in a 3D way.&lt;br /&gt;
&lt;br /&gt;
So here are some not very well pics due to the poor camera and the darkness :&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyZAGTw4a-4894OcTLMWJP49JurBdxA9OVZWFAXegMunV5lpgLhojIHjNnH6mOhPuo0Ozi5k4nTBTkBuwtM3pqM3kPCnBigYfb_JQisU1IjxLDVtWO9gbuejvxIRX70h-_HOsK_BXMdyvW/s400/ball.jpg&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjNbxOWTZPM-yetjo5njiX1CXjxbzm4I6cTdhqhj98ZUWlCCCn0LO2hXEOatJJintRhO8aL2gT3IJ7RXxCTbduRr5q2cNM_mAnzE__1kU3UdvP4BUKdF2jZDz4i2_Pal4JYUNC23Ozvth1K/s400/glass.jpg&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Za1V2c7u3hHy2JaaVCQGN8WGNvc4HanM4m2qRYT-Io9hd_unkH7jFZWIueCnoa6nGXuRxz6eY3pHPwZU-KMcktMAZMA-UvOENx01oOfUz4QF8Z510NuNPXNhxinSHTzdKTpUGS_4gl9B/s400/logo.jpg&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxKrEmYRaogNYWOyew0pwJaJFZwRKIiulBwZvNbAC5xkX-SYfA72dT0T0KuzV-XtmFQum-kIoJPef0lEQUIWvCelVE4Jp113id6fuorw2rj4LoeNp9n09ZHHwdqItbPxzvNbEBGClvZyrs/s400/apple.jpg&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
My setup :&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeyy2XIUQgnJ5PdWlDAPjwX5c3XdXutQrjGi_uyM3gDxd4dqRaxyRTLaKiQ8PmDOvFN58Z8AaGEXo7fVO0uwW1dkqTRbaVA5q5ttcHiubdx7D-Ul6oHO0hDy5s7OTemfzPgaubXoQKX7GG/s400/2.jpg&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG6jnRPnyI4mCL0_B9H-5jyHaD59EMYHZBQBbTifUyWAsz0thq_emNw2vQhtrNcgu7xW3CmveAqMKzLW_ofKapRnX5CyD1VlDFP-80P0IMGB6pBByi9_uwoWKEAWzAR5fdgBwJBQoB3eSR/s400/3.jpg&quot; width=&quot;300&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgcKzEeYlMHSRygKzgPlnJYIN5okrM8BIy-qsfommOfQid-POfgb7_6x0TPIBSXklReWWiriCmlvdNSBXeZ9761efM6Op3L2lHEFYFRnCvwwgRjfbYCfDrKtknJB5DFVl71umsF6sGy6WRs/s400/4.jpg&quot; width=&quot;300&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEijiyKI8KMdZO8gdXXjxh1PB69K7asGpFTl6DzlQM3rdF0Cyi2WGxI9ZkrOr9wNyq4bxtik-I9wWqc4paIy9nVAKSKtRXt7jmkrrEH4Tdxi3JPmF9GwpGduHofihVVTm58woU4OMniFpJy8/s400/5.jpg&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6wHTnzC7dRSGBQPNjGpBjwLsEjlZb8UIFdakTaMgLl_uBFwGSeMkrY96p3CV_5zH9kMWnouuDVSHZQ5685hKIJfFvuzpI2J9iEozrnjlAx_fHfKFrDUlJHVE1nbyM4DAvxW-J8LATl_Hd/s400/6.jpg&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
You can get those images from &lt;a href=&quot;http://imageshack.us/g/528/4dcartest.jpg/&quot;&gt;here&lt;/a&gt;, and I made two videos but for some reason Youtube is throwing errors on processing them, here are the used videos : &lt;a href=&quot;http://www.youtube.com/watch?v=Tiee04XtRbA&quot;&gt;diamond&lt;/a&gt;, &lt;a href=&quot;http://www.youtube.com/watch?v=UI7mtRI1-Qg&quot;&gt;teapot&lt;/a&gt;.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
And here is a making guide :&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;iframe allowfullscreen=&#39;allowfullscreen&#39; webkitallowfullscreen=&#39;webkitallowfullscreen&#39; mozallowfullscreen=&#39;mozallowfullscreen&#39; width=&#39;320&#39; height=&#39;266&#39; src=&#39;https://www.youtube.com/embed/SIo9WVcE57Y?feature=player_embedded&#39; frameborder=&#39;0&#39;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;br /&gt;
This looks a little bit flat on pictures, but I highly recommend that you make this and see it with your own eyes, have fun !!</description><link>http://jawbfl.blogspot.com/2013/03/pepper-pyramid-hologram-experiment.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiyZAGTw4a-4894OcTLMWJP49JurBdxA9OVZWFAXegMunV5lpgLhojIHjNnH6mOhPuo0Ozi5k4nTBTkBuwtM3pqM3kPCnBigYfb_JQisU1IjxLDVtWO9gbuejvxIRX70h-_HOsK_BXMdyvW/s72-c/ball.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-2289883093298574100</guid><pubDate>Fri, 07 Dec 2012 19:49:00 +0000</pubDate><atom:updated>2012-12-07T20:01:15.986+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C++</category><category domain="http://www.blogger.com/atom/ns#">mcpc2012</category><category domain="http://www.blogger.com/atom/ns#">problem</category><title>MCPC 2012 - Problem D : Minimum bounding rectangle</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;P.S:&lt;/b&gt; This is not the original text, I rephrased and summarized the original one because I&#39;m lazy and I couldn&#39;t&amp;nbsp;type the whole text. if there is an error it&#39;s my mistake.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;[D] SCPC:&lt;/b&gt;&lt;br /&gt;
We need to build a contest hall in the shape of a cuboid (3D rectangle). for economical reasons, we need to minimize the size (area) of the rectangle. So given the coordinates of the teams, calculate the minimum rectangle area of land for a building big enough to fit all the teams.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Input :&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
T: number of cases.&lt;br /&gt;
N: number of teams.&lt;br /&gt;
Xi Yi: coordinates of each team.&lt;br /&gt;
1&amp;lt;=T,N&amp;lt;=100,&lt;br /&gt;
-10000&amp;lt;=Xi,Yi&amp;lt;=10000&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Output:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Single line starting with case number, followed by the area of the minimum rectangle rounded to 4 decimal places.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Example&amp;nbsp;:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
4&lt;br /&gt;
4&lt;br /&gt;
0 0&lt;br /&gt;
1 1&lt;br /&gt;
1 0&lt;br /&gt;
0 1&lt;br /&gt;
4&lt;br /&gt;
0 0&lt;br /&gt;
2 2&lt;br /&gt;
2 0&lt;br /&gt;
0 2&lt;br /&gt;
4&lt;br /&gt;
0 0&lt;br /&gt;
1 2&lt;br /&gt;
1 0&lt;br /&gt;
0 2&lt;br /&gt;
3&lt;br /&gt;
0 0&lt;br /&gt;
1 0&lt;br /&gt;
1 1&lt;br /&gt;
---&amp;gt;&lt;br /&gt;
Case 1: 1.0000&lt;br /&gt;
Case 2: 4.0000&lt;br /&gt;
Case 3: 2.0000&lt;br /&gt;
Case 4: 1.0000&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Contest Analysis :&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Actually&amp;nbsp;I didn&#39;t read this problem during the competition, so this solution wasn&#39;t tested against judge&#39;s inputs and therefore it&#39;s not conclusive.&lt;br /&gt;
This is a classic problem called&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Minimum_bounding_rectangle&quot;&gt;minimum bounding rectangle&lt;/a&gt;,&amp;nbsp;minimum bounding envelope and in 3D called&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Minimum_bounding_box&quot;&gt;minimum bounding box&lt;/a&gt;. To achieve this I am going to use the convex hull, because there is a &lt;a href=&quot;http://www.geometrictools.com/Documentation/MinimumAreaRectangle.pdf&quot;&gt;theorem&lt;/a&gt; that says &quot;The minimum bounding rectangle&#39;s orientations are determined by the polygon edges&quot;. So the steps are :&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Compute the convex hull of the cloud.&lt;/li&gt;
&lt;li&gt;For each edge of the convex hull :&lt;br /&gt;
  &lt;ul&gt;
&lt;li&gt;Compute the edge orientation.&lt;/li&gt;
&lt;li&gt;Rotate the convex hull using this orientation in order to compute easily the bounding rectangle area.&lt;/li&gt;
&lt;li&gt;Store the orientation corresponding to the minimum area found.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Return the rectangle corresponding to the minimum area found.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiqjM1COV52jgQNr7748H3xJdy2rEcQLEqCumTEU-GR-ZD2P2WRu3ZwpPRty6UIr9FiSEzpJWwIlH1vZreAz0XoCefP8Q-vNDtFwbGqdw1XkYYOv_RalBySGoJoc_KG20b6hmZQWW0T7aR/s1600/rerDiagBounding03.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiqjM1COV52jgQNr7748H3xJdy2rEcQLEqCumTEU-GR-ZD2P2WRu3ZwpPRty6UIr9FiSEzpJWwIlH1vZreAz0XoCefP8Q-vNDtFwbGqdw1XkYYOv_RalBySGoJoc_KG20b6hmZQWW0T7aR/s320/rerDiagBounding03.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Solution in C++:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
A very long code in C++ , during a contest this should be done in Java.&lt;br /&gt;
To find the convex hull, I translated a Javascript code&amp;nbsp;described&amp;nbsp;by&amp;nbsp;&lt;a href=&quot;http://www.blogger.com/profile/09059146951132522993&quot;&gt;Teemu Korhonen&lt;/a&gt; in &lt;a href=&quot;http://onemoresoftwareblog.blogspot.com/2011/11/finding-convex-hull-using-grahams-scan_19.html&quot;&gt;this&lt;/a&gt; blog post.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;cpp&quot; name=&quot;code&quot;&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;iomanip&amp;gt;
#include &amp;lt;fstream&amp;gt;
#include &amp;lt;vector&amp;gt;
#include &amp;lt;algorithm&amp;gt;
#define  _USE_MATH_DEFINES
#include &amp;lt;cmath&amp;gt;
#include &amp;lt;stack&amp;gt;

#define For(i,n) for(int i(0),_n(n);i&amp;lt;_n;++i)

using namespace std;

class Point {
  public:
 double x;
 double y;
 double angle;
};

bool comp(double a,double b) {return (a&amp;lt;b);}
bool compy(Point p1,Point p2) {return (p1.y&amp;lt;p2.y);}
bool compx(Point p1,Point p2) {return (p1.x&amp;lt;p2.x);}
bool compangle(Point p1,Point p2) {return (p1.angle&amp;lt;p2.angle);}

void rotate(Point &amp;amp;point, Point pivot, double angle) {
 float s = sin(angle);
 float c = cos(angle);
 point.x -= pivot.x;
 point.y -= pivot.y;
 double newx = point.x*c - point.y*s;
 double newy = point.x*s + point.y*c;
 point.x = newx + pivot.x;
 point.y = newy + pivot.y;
}

double ptdistance(Point p1,Point p2) {
 return pow(p2.x-p1.x,2) + pow(p2.y-p1.y,2);
}

double calculate_angle(Point point, Point pivot) {
 double x = point.x - pivot.x;
 double y = point.y - pivot.y;
 if(x&amp;gt;0 &amp;amp;&amp;amp; y&amp;gt;0) return atan(y/x);
 if(x&amp;lt;0 &amp;amp;&amp;amp; y&amp;gt;0) return atan(-x/y) + M_PI/2;
 if(x&amp;lt;0 &amp;amp;&amp;amp; y&amp;lt;0) return atan(y/x) + M_PI;
 if(x&amp;gt;0 &amp;amp;&amp;amp; y&amp;lt;0) return atan(-x/y) + M_PI/2 + M_PI;
 if(x==0 &amp;amp;&amp;amp; y&amp;gt;0) return M_PI/2;
 if(x&amp;lt;0 &amp;amp;&amp;amp; y==0) return M_PI;
 if(x==0 &amp;amp;&amp;amp; y&amp;lt;0) return M_PI/2 + M_PI;
 else return 0;
}

// Three points are a counter-clockwise turn if ccw &amp;gt; 0, clockwise if ccw &amp;lt; 0, and collinear if ccw = 0 
double ccw(Point p1, Point p2, Point p3) { 
 return (p2.x - p1.x)*(p3.y - p1.y) - (p2.y - p1.y)*(p3.x - p1.x); 
}

double parallelsurface(vector&amp;lt;Point&amp;gt; hull, Point point, Point pivot) {
 double angle = calculate_angle(point,pivot);
 vector&amp;lt;Point&amp;gt; newhull(hull);
 for(vector&amp;lt;Point&amp;gt;::iterator it=newhull.begin(); it!=newhull.end(); ++it) {
  if(angle &amp;lt; M_PI/2) rotate(*it,pivot,-angle);
  if(angle &amp;gt; M_PI/2 &amp;amp;&amp;amp; angle&amp;lt; M_PI) rotate(*it,pivot,-angle+M_PI/2);
  if(angle &amp;gt; M_PI &amp;amp;&amp;amp; angle&amp;lt; 3*M_PI/2) rotate(*it,pivot,-angle+M_PI);
  if(angle &amp;gt; 3*M_PI/2 &amp;amp;&amp;amp; angle&amp;lt; 2*M_PI) rotate(*it,pivot,-angle+3*M_PI/2);
 }
 double minx = (*min_element(newhull.begin(), newhull.end(), compx)).x;
 double miny = (*min_element(newhull.begin(), newhull.end(), compy)).y;
 double maxx = (*max_element(newhull.begin(), newhull.end(), compx)).x;
 double maxy = (*max_element(newhull.begin(), newhull.end(), compy)).y;
 return (maxx-minx)*(maxy-miny);
}

int main(int argc, char const *argv[]) {
 long long T;
 fstream f(&quot;scpc.in&quot;);
 f &amp;gt;&amp;gt; T;
 For(t,T) {
  long long N;
  vector&amp;lt;Point&amp;gt; points;
  vector&amp;lt;Point&amp;gt; hull;
  vector&amp;lt;double&amp;gt; surfaces;
  f &amp;gt;&amp;gt; N;
  For(i,N) {
   Point pt;
   f &amp;gt;&amp;gt; pt.x;
   f &amp;gt;&amp;gt; pt.y;
   points.push_back(pt);
  }
  // All points with positive coordinates
  int minx = (*min_element(points.begin(), points.end(), compx)).x;
  int miny = (*min_element(points.begin(), points.end(), compy)).y;
  for(vector&amp;lt;Point&amp;gt;::iterator it=points.begin(); it!=points.end(); ++it) {
   if(minx&amp;lt;0) (*it).x += abs(minx);
   if(miny&amp;lt;0) (*it).y += abs(miny);
  }

  // Get reference point C (lowest leftmost) and remove it from points
  vector&amp;lt;Point&amp;gt;::iterator ref = points.begin();
  for(vector&amp;lt;Point&amp;gt;::iterator it=points.begin(); it!=points.end(); ++it) {
   if((*it).y &amp;lt; (*ref).y) ref = it;
   if((*it).y == (*ref).y)
    if((*it).x &amp;gt; (*ref).x) ref = it;
  }
  Point C;
  C.x = (*ref).x;
  C.y = (*ref).y;
  C.angle = 0;
  points.erase(ref);
  --N;

  // Stack to use for removing points to not interfere with the loop
  stack&amp;lt;vector&amp;lt;Point&amp;gt;::iterator&amp;gt; rmpts; 

  // Fill the angle field and 
  for(vector&amp;lt;Point&amp;gt;::iterator it=points.begin(); it!=points.end(); ++it) {
   (*it).angle = calculate_angle(*it,C);
   if((*it).x == C.x &amp;amp;&amp;amp; (*it).y == C.y) {
    rmpts.push(it);
    --N;
   }
  }
  while(!rmpts.empty()) { // Effective removal
   points.erase(rmpts.top());
   rmpts.pop();
  }

  // Sort by angle
  sort(points.begin(), points.end(), compangle);

  // If two points have same angle remove the closest to C
  for(vector&amp;lt;Point&amp;gt;::iterator it=points.begin()+1, prev=points.begin(); it!=points.end(); prev=it, ++it) {
   if((*prev).angle == (*it).angle) {
    double d1 = ptdistance(C, *it);
    double d2 = ptdistance(C, *prev);
    if(d1 &amp;gt; d2) rmpts.push(prev);
    else rmpts.push(it);
    // I don&#39;t know why I keep updating N even if I&#39;m done with it !!
    --N;
   }
  }
  while(!rmpts.empty()) { // Effective removal
   points.erase(rmpts.top());
   rmpts.pop();
  }

  // Building the convex hull
  hull.push_back(C);
  hull.push_back(points[0]);
  hull.push_back(points[1]);
  for(vector&amp;lt;Point&amp;gt;::iterator it=points.begin()+2; it!=points.end(); ++it) {
   Point pi = *it;
   while(ccw(hull[hull.size()-2], hull[hull.size()-1], pi) &amp;lt;= 0) {
    hull.pop_back();
   }
   hull.push_back(pi);
  }

  // Calculate MBR area for each side
  for(vector&amp;lt;Point&amp;gt;::iterator it=hull.begin()+1, prev=hull.begin(); it!=hull.end(); prev=it, ++it) {
   surfaces.push_back(parallelsurface(hull,*it,*prev));
  }
  surfaces.push_back(parallelsurface(hull,hull[hull.size()-1],hull[0]));

  cout &amp;lt;&amp;lt; &quot;Case &quot; &amp;lt;&amp;lt; t+1 &amp;lt;&amp;lt; &quot;: &quot; &amp;lt;&amp;lt; fixed &amp;lt;&amp;lt; setprecision(4) &amp;lt;&amp;lt; (*min_element(surfaces.begin(), surfaces.end(), comp)) &amp;lt;&amp;lt; endl;
 }
 f.close();
 return 0;
}
&lt;/pre&gt;
</description><link>http://jawbfl.blogspot.com/2012/12/mcpc-2012-problem-d-minimum-bounding.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiiqjM1COV52jgQNr7748H3xJdy2rEcQLEqCumTEU-GR-ZD2P2WRu3ZwpPRty6UIr9FiSEzpJWwIlH1vZreAz0XoCefP8Q-vNDtFwbGqdw1XkYYOv_RalBySGoJoc_KG20b6hmZQWW0T7aR/s72-c/rerDiagBounding03.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-8547396920402107462</guid><pubDate>Wed, 05 Dec 2012 17:11:00 +0000</pubDate><atom:updated>2012-12-07T18:46:58.122+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C++</category><category domain="http://www.blogger.com/atom/ns#">mcpc2012</category><category domain="http://www.blogger.com/atom/ns#">problem</category><title>MCPC 2012 - Problem C : Shortest path in a grid</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;P.S:&lt;/b&gt; This is not the original text, I rephrased and summarized the original one because I&#39;m lazy and I couldn&#39;t&amp;nbsp;type the whole text. if there is an error it&#39;s my mistake.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;[C] LCPC:&lt;/b&gt;&lt;br /&gt;
Chief judge Fegla and Nicole are in a university and need to meet each other to smoke &lt;a href=&quot;http://en.wikipedia.org/wiki/Hookah&quot;&gt;Shesha&lt;/a&gt; O_o&#39; !!! the problem is that all the walkways in the&amp;nbsp;campus&amp;nbsp;form a rectangular grid that has some strange&amp;nbsp;properties&amp;nbsp;:&lt;br /&gt;
No one can walk elsewhere the cells of the grid.&lt;br /&gt;
Any person on a cell can only go the cell on his left, right, front, rear, the walk takes one second.&lt;br /&gt;
Person can&#39;t get out of the grid&#39;s boundaries.&lt;br /&gt;
If a tree is planted in a cell, no one can walk on this cell.&lt;br /&gt;
Fegla and Nicole are in two cells(not&amp;nbsp;necessarily&amp;nbsp;different and has no tree)&amp;nbsp;&amp;nbsp;they start looking for each other taking one action each second&amp;nbsp;simultaneously, your job is to find the minimum number of seconds needed to meet.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Input :&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
T: number of cases.&lt;br /&gt;
R C: number of rows,&amp;nbsp;number of columns.&lt;br /&gt;
r1 c1 r2 c2: Fegla&#39;s coordinates,&amp;nbsp;Nicole&#39;s coordinates.&lt;br /&gt;
N: number of trees.&lt;br /&gt;
N lines : TRi TCi Tree i coordinates.&lt;br /&gt;
1&amp;lt;=R,C&amp;lt;=20,&amp;nbsp;0&amp;lt;=r1,r2&amp;lt;=R,&amp;nbsp;0&amp;lt;=c1,c2&amp;lt;=C,&lt;br /&gt;
0&amp;lt;=N&amp;lt;=R*C-2,&amp;nbsp;0&amp;lt;=TRi&amp;lt;=R,&amp;nbsp;0&amp;lt;=TCi&amp;lt;=C&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Output:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Single line either the minimum number of seconds or -1 if they can never meet.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Example&amp;nbsp;:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
4&lt;br /&gt;
1 3&lt;br /&gt;
0 0 0 2&lt;br /&gt;
0&lt;br /&gt;
2 3&lt;br /&gt;
0 0 1 0&lt;br /&gt;
0&lt;br /&gt;
2 3&lt;br /&gt;
0 0 1 2&lt;br /&gt;
3&lt;br /&gt;
0 2&lt;br /&gt;
1 0&lt;br /&gt;
1 1&lt;br /&gt;
2 3&lt;br /&gt;
0 0 0 2&lt;br /&gt;
1&lt;br /&gt;
0 1&lt;br /&gt;
&lt;br /&gt;
---&amp;gt;&lt;br /&gt;
1&lt;br /&gt;
1&lt;br /&gt;
-1&lt;br /&gt;
2&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Contest Analysis :&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;Actually&amp;nbsp;I didn&#39;t read this problem during the competition, so this solution wasn&#39;t tested against judge&#39;s inputs and therefore it&#39;s not conclusive.&lt;br /&gt;
The key word is&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Breadth-first_search&quot;&gt;Breadth-first search&lt;/a&gt;, but first you should notice that Fegla and Nicole are&amp;nbsp;symmetric if&amp;nbsp;Fegla&amp;nbsp;can reach&amp;nbsp;Nicole then&amp;nbsp;Nicole can reach&amp;nbsp;Fegla. Also, if one can&#39;t, then the other can&#39;t too. So we shouldn&#39;t care about both of theme moving, we can fix one and move the other. Now we can use&amp;nbsp;Breadth-first search, but in a grid there is a derivation called the &lt;a href=&quot;http://en.wikipedia.org/wiki/Lee_algorithm&quot;&gt;Lee algorithm&lt;/a&gt;. First we start from Fegla, then mark every possible(none tree) neighbor with 1, then mark all unlabeled and possible neighbors of 1 with 2 etc...&lt;br /&gt;
We stop if we reached the&amp;nbsp;target&amp;nbsp;or we can&#39;t mark any more points. In fact, that&#39;s it, if we didn&#39;t reach the target then, they are in different&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Connected_component_(graph_theory)&quot;&gt;connected components&lt;/a&gt;&amp;nbsp;(in problem&#39;s&amp;nbsp;sense). Else, we already have the number of steps that Fegla do while Nicole is stopped. Then, if we make Nicole moves too the number will be divided by two (+1 if odd number).&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Solution in C++:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;pre class=&quot;cpp&quot; name=&quot;code&quot;&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;fstream&amp;gt;
#include &amp;lt;vector&amp;gt;

#define For(i,n) for(int i(0),_n(n);i&amp;lt;_n;++i)

using namespace std;

static const int P     = 0;
static const int EMPTY = -1;
static const int TREE  = -2;

int main(int argc, char const *argv[]) {
 long long T;
 fstream f(&quot;lcpc.in&quot;);
 f &amp;gt;&amp;gt; T;
 For(t,T) {
  long long R,C,N,r1,c1,r2,c2,r,c;
  vector&amp;lt;vector&amp;lt;int&amp;gt; &amp;gt; grid;
  f &amp;gt;&amp;gt; R;
  f &amp;gt;&amp;gt; C;
  For(i,R) {
   vector&amp;lt;int&amp;gt; row(C);
   For(j,C) row[j] = EMPTY;
   grid.push_back(row);
  }
  f &amp;gt;&amp;gt; r1;
  f &amp;gt;&amp;gt; c1;
  grid[r1][c1] = P;
  f &amp;gt;&amp;gt; r2;
  f &amp;gt;&amp;gt; c2;
  f &amp;gt;&amp;gt; N;
  For(i,N) {
   f &amp;gt;&amp;gt; r;
   f &amp;gt;&amp;gt; c;
   grid[r][c] = TREE;
  }
  int current = 0;
  bool still = true;
  bool found = false;
  while(still &amp;amp;&amp;amp; !found) {
   still = false;
   For(i,R) For(j,C) {
    if(grid[i][j] == current) {
     still = true;
     int val = grid[i][j]+1;
     if(j+1&amp;lt;C) if(grid[i][j+1]==EMPTY)
      grid[i][j+1] = val;
     if(j-1&amp;gt;=0) if(grid[i][j-1]==EMPTY)
      grid[i][j-1] = val;
     if(i+1&amp;lt;R) if(grid[i+1][j]==EMPTY)
      grid[i+1][j] = val;
     if(i-1&amp;gt;=0) if(grid[i-1][j]==EMPTY)
      grid[i-1][j] = val;
     if(i==r2 &amp;amp;&amp;amp; j==c2) {
      still = false;
      found = true;
     }
    }
   }
   ++current;
  }
  if(!found) cout &amp;lt;&amp;lt; -1 &amp;lt;&amp;lt; endl;
  else {
   if(grid[r2][c2]%2 == 0) cout &amp;lt;&amp;lt; grid[r2][c2]/2 &amp;lt;&amp;lt; endl;
   else cout &amp;lt;&amp;lt; grid[r2][c2]/2 + 1 &amp;lt;&amp;lt; endl;
  }
 }
 f.close();
 return 0;
}
&lt;/pre&gt;
</description><link>http://jawbfl.blogspot.com/2012/12/mcpc-2012-problem-c.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-1643796866490637708</guid><pubDate>Tue, 04 Dec 2012 21:40:00 +0000</pubDate><atom:updated>2012-12-07T18:48:10.422+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C++</category><category domain="http://www.blogger.com/atom/ns#">mcpc2012</category><category domain="http://www.blogger.com/atom/ns#">problem</category><title>MCPC 2012 - Problem B : Minimal and maximal rate</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;P.S:&lt;/b&gt; This is not the original text, I rephrased and summarized the original one because I&#39;m lazy and I couldn&#39;t&amp;nbsp;type the whole text. if there is an error it&#39;s my mistake.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;[B] JCPC:&lt;/b&gt;&lt;br /&gt;
Chief judge was hospitalized, he was kept in until a test (that returns a positive real number) dropped to 2.0 or less. Given the current result H and number of days D and provided that he is tested every hour and released immediately if result &amp;lt;= 2.0 print the minimum and maximum rate of decrease in this measurement to be released from the hospital after D days, but not after D+1 days.&lt;br /&gt;
1 day = 24 hours, very useful information !!!&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Input :&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
T: number of cases.&lt;br /&gt;
T lines : H(current measurement) D(number of days)&lt;br /&gt;
1&amp;lt;=T&amp;lt;=200,&amp;nbsp;3&amp;lt;=H&amp;lt;=100, 1&amp;lt;=D&amp;lt;=150&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Output:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Single line for each case in the following format : &amp;lt;maximum rate&amp;gt; &amp;lt;minimum rate&amp;gt; rounded to 5 decimal places after decimal point.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Example&amp;nbsp;:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
1&lt;br /&gt;
5 2&lt;br /&gt;
---&amp;gt;&lt;br /&gt;
0.06250 0.04225&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Contest Analysis :&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;The problem was the easiest one, for the maximum rate: H-max*24*D = 2 , so max =&amp;nbsp;(H-2)/(D*24).&lt;br /&gt;
in the minimum case the result should drop to 2.0 before D+1 days so an hour before D+1 days then&lt;br /&gt;
min=(H-2.0)/(((D+1)*24)-1).&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Solution in C++:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;pre class=&quot;cpp&quot; name=&quot;code&quot;&gt;#include &amp;amp;ltiostream&amp;amp;gt
#include &amp;amp;ltfstream&amp;amp;gt

#define For(i,n) for(int i(0),_n(n);i&amp;lt;_n;++i)

using namespace std;

int main(int argc, char const *argv[]) {
 long long T,H,D;
 double max,min;
 string gc;
 fstream f(&quot;jcpc.in&quot;);
 f &amp;amp;gt&amp;amp;gt T;
 For(i,T) {
  f &amp;amp;gt&amp;amp;gt H;
  f &amp;amp;gt&amp;amp;gt D;
  max = (H-2.0)/(D*24);
  min = (H-2.0)/(((D+1)*24)-1);
  cout.precision(5);
  cout &amp;amp;lt&amp;amp;lt fixed &amp;amp;lt&amp;amp;lt max &amp;amp;lt&amp;amp;lt &quot; &quot; &amp;amp;lt&amp;amp;lt min &amp;amp;lt&amp;amp;lt endl;
 }
 f.close();
 return 0;
}
&lt;/pre&gt;
</description><link>http://jawbfl.blogspot.com/2012/12/mcpc-2012-problem-b.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-2318606326369271063</guid><pubDate>Mon, 03 Dec 2012 17:48:00 +0000</pubDate><atom:updated>2012-12-07T18:48:59.095+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">C++</category><category domain="http://www.blogger.com/atom/ns#">mcpc2012</category><category domain="http://www.blogger.com/atom/ns#">problem</category><title>MCPC 2012 - Problem A : Pattern matching</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;P.S:&lt;/b&gt; This is not the original text, I rephrased and summarized the original one because I&#39;m lazy and I couldn&#39;t&amp;nbsp;type the whole text. if there is an error it&#39;s my mistake.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;[A] ACPC:&lt;/b&gt;&lt;br /&gt;
One of your friends spilled coffee on a form, luckily it wasn&#39;t totally destroyed. You will tell him what the fields on his form say for him to fill. You are given all the fields in your form as two strings &amp;lt;label&amp;gt;: &amp;lt;info&amp;gt; and the given questions. Each question is a string that was originally a label in the form but got some of its letters covered by coffee.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Input :&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
N: number of labels.&lt;br /&gt;
N lines : &amp;lt;lable&amp;gt;: &amp;lt;info&amp;gt;&lt;br /&gt;
M: number of questions.&lt;br /&gt;
M lines: &amp;lt;question&amp;gt;&lt;br /&gt;
1&amp;lt;=N&amp;lt;=100,&amp;nbsp;1&amp;lt;=M&amp;lt;=100, M&amp;lt;=N&lt;br /&gt;
&amp;lt;label&amp;gt;,&amp;lt;info&amp;gt; : string of lowercase &amp;amp; uppercase English letters&lt;br /&gt;
&amp;lt;question&amp;gt; :&amp;nbsp;string formed of lowercase &amp;amp; uppercase English letters and question mark &#39;?&#39;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Output:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Single line for each question in the following format : &amp;lt;original label&amp;gt;: &amp;lt;original info&amp;gt; that contains the first matching label and the info that matches it.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Example&amp;nbsp;:&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
4&lt;br /&gt;
Name: Amr Samir&lt;br /&gt;
Age: 21&lt;br /&gt;
University: Cairo Univ.&lt;br /&gt;
Smoker: no&lt;br /&gt;
2&lt;br /&gt;
?m????&lt;br /&gt;
??m?&lt;br /&gt;
---&amp;gt;&lt;br /&gt;
Smoker: no&lt;br /&gt;
Name: Amr Samir&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Contest Analysis :&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;The problem seems very simple, the first thing that comes to mind is regular&amp;nbsp;expressions. Yes that&#39;s the key, we generate a valid regex from each question by replacing &#39;?&#39; with &#39;.&#39;, then look for a match between labels. But the real problem is in treating spaces while reading so you should pay attention to the parsing step. I use a string, usually called gc (garbage collector), to contain unneeded&amp;nbsp;characters.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Solution in C++:&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;pre class=&quot;cpp&quot; name=&quot;code&quot;&gt;#include &amp;lt;iostream&amp;gt;
#include &amp;lt;fstream&amp;gt;
#include &amp;lt;string&amp;gt;
#include &amp;lt;regex&amp;gt;
#include &amp;lt;algorithm&amp;gt;

#define For(i,n) for(int i(0),_n(n);i&amp;lt;_n;++i)

using namespace std;

int main(int argc, char const *argv[]) {
 long long N,M;
 string gc,labels[100],infos[100],questions[100];
 fstream f(&quot;acpc.in&quot;);
 f &amp;gt;&amp;gt; N;
 getline(f,gc);
 For(i,N) {
  getline(f,labels[i],&#39;:&#39;);
  getline(f,gc,&#39; &#39;);
  getline(f,infos[i]);
 }
 f &amp;gt;&amp;gt; M;
 getline(f,gc);
 For(i,M) {
  getline(f,questions[i]);
 }
 For(i,M) {
  For(j,N) {
   replace(questions[i].begin(),questions[i].end(), &#39;?&#39;, &#39;.&#39;);
   if(regex_match(labels[j],regex(questions[i]))) {
    cout &amp;lt;&amp;lt; labels[j] &amp;lt;&amp;lt; &quot;: &quot; &amp;lt;&amp;lt; infos[j] &amp;lt;&amp;lt; endl;
    break;
   }
  }
 }
 f.close();
 return 0;
}
&lt;/pre&gt;
</description><link>http://jawbfl.blogspot.com/2012/12/mcpc-2012-problem-a.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-3147024269650663049</guid><pubDate>Mon, 03 Dec 2012 12:03:00 +0000</pubDate><atom:updated>2012-12-04T00:44:12.629+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">mcpc2012</category><category domain="http://www.blogger.com/atom/ns#">Misc</category><title>MCPC 2012 Just Another Wonderful Day, Briefly !! </title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Hi again, it&#39;s been a while. This time I&#39;m going to talk about another fabulous experience, the &lt;a href=&quot;http://http//morocco.acmacpc.org/&quot;&gt;ACM-MCPC 2012&lt;/a&gt; (Moroccan Collegiate Programming Contest) it&#39;s the 1st edition of the local qualification&amp;nbsp;programming contest to the &lt;a href=&quot;http://acm-acpc.org/&quot;&gt;ACM-ACPC&lt;/a&gt; (Arab Collegiate Programming. Contest).&lt;br /&gt;
First of all I&#39;ll like to thank my university &lt;a href=&quot;http://www.ensias.ma/&quot;&gt;ENSIAS&lt;/a&gt;&amp;nbsp;and the &lt;a href=&quot;http://www.acm.org/&quot;&gt;ACM&lt;/a&gt; represented by Eng. Mohamed Fouad (Deputy Regional Contest Director) and the judges. Also I&#39;ll like to thank the organizing committee for the great work, and congratulate them for organizing the event in record time.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPJ5nq2WYfCriyuScO-4buFuxKOcN9x6yWjdJ6v6gGIBfyio35VHygapDlqzXLfcvV3HDATKm9eMlgkFTT8woEA8F2LSlMm4DC6vuP-OH7dY4EIOdP4uvmgiKCLyM76rs8KBg_ih2nVI7S/s400/12577_113976058768537_1872477103_n.jpg&quot; width=&quot;520&quot; /&gt;&lt;/div&gt;
&lt;br /&gt;
About the contest,&amp;nbsp;ACM International Collegiate Programming Contest (abbreviated as &lt;a href=&quot;http://icpc.baylor.edu/&quot;&gt;ACM-ICPC&lt;/a&gt; or just ICPC) is an annual multi-tiered competitive programming competition among the universities of the world. The contest is sponsored by IBM. Headquartered at Baylor University, with autonomous regions on six continents, and operates under the auspices of the Association for Computing Machinery ACM.&amp;nbsp;During contest, the teams are given 5 hours to solve between 8 and 12 programming problems (with 8 typical for regionals and 10 for finals). They must submit solutions as programs in C, C++, or Java. Programs are then run on test data. If a program fails to give a correct answer, the team is notified and can submit another program.&lt;br /&gt;
&lt;br /&gt;
I had the chance to participate in the &lt;a href=&quot;http://code.google.com/codejam/&quot;&gt;Google CodeJam&lt;/a&gt;&amp;nbsp;, so what are the&amp;nbsp;differences&amp;nbsp;?&lt;br /&gt;
&lt;br /&gt;
The first obvious thing is the languages that you can use,&amp;nbsp;ACM-xCPC&amp;nbsp;insists on the classics C,C++ and Java whilst in CodeJam you can use any language (Assembly if you&#39;re a masochist :P). In my situation I used PHP and Python during the CodeJam it was really helpful, but in the&amp;nbsp;ACM-xCPC&amp;nbsp;I didn&#39;t know enough C++ or Java to deal with the problems so we used C (Yes it really hearts !!!). C fans hold your guns, I huge fan of C I&#39;m not doubting the power of C, but as a contestant you have constraints of time and you&#39;ll need a language with tools that would be Python else it&#39;s C++ (or Java if you are Bad luck Brian, Java fans you can shout me :/ ).&lt;br /&gt;
&lt;br /&gt;
Second thing, ... yes the &quot;No electronic documents&quot; thing !!! , for the record, they allow printed documents but let&#39;s face it who used them anymore (even the course, I only keep the&amp;nbsp;electronic&amp;nbsp;version ). I like&amp;nbsp;electronic&amp;nbsp;documents and internet at least you should be&amp;nbsp;allowed to bring your libraries, snippets and cheat sheets &amp;nbsp;with you, that makes the difference between contestants. I know it&#39;s creating equal opportunities but still !!&lt;br /&gt;
Internet is also very&amp;nbsp;useful, a good coder is the one who can solve problems using resources not only his acquired knowledge. But it&#39;s difficult to control the data and prevent cheating.&lt;br /&gt;
&lt;br /&gt;
The last thing which I couldn&#39;t tell if it&#39;s&amp;nbsp;advantage or a drawback is the *.in file. In CodeJam you can download in files to generate the *.out file, but you can use this trick to check if you&#39;re missing a case or you have a bug in a special case. In ACM-xCPC you can&#39;t do that, the in file is generated and tested on the judge&#39;s side.&lt;br /&gt;
&lt;br /&gt;
So,&amp;nbsp;ACM-xCPC is an opportunity to test your skills offline and without libraries, it&#39;s an opportunity to test your knowledge in C,C++ and Java and no kidding you should master one of them if you&#39;re calling your self a coder. Finally the results, :Drum: , my team was 5th :/ a tie between the 2nd till 6th and her comes the rule &quot;In case of a tie, the title goes to the team with the minimum penalties for that problem&quot;.&lt;br /&gt;
Ok, that was it for the day, I&#39;ll post an article for every problem with my solution as soon as possible for now here are some pics.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhODg5ZhWY_GL8H9xHnylnPpjmREqRbTs472xosDp8ix-OdtguwbDd3WS29CHkBCDSJ0NFqMTJe4z7w0OegbXFCRDfpdnNiuRKPcgTPXFgp_uQF2WgNC2iK19LRoxaa3e0Yr2IKmlz_XqT0/s400/432263_113975888768554_311785445_n.jpg&quot; width=&quot;520&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqEqZJTexdh2KkzR4DEteTLsJMhgRTLOkFeXrEXM1WszEhHHgTJsRolWhX6iezEBhp_cPqrrHVz6o89WqV_rcwdPbpTCXvqgBkmGuRaHBK7W4DYM-pZhle_Lgf2txCm-gEj3NeYpP4Y5sN/s400/530462_113977362101740_1817377025_n.jpg&quot; width=&quot;520&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoHnfc2ra-a-1WmtgQZx066ddkdtCYGsHMGCVYnphV6uIhp0RGRwCFRo_gjwHphM4PI1F4OWkq67tiJ2hJv6cLsJNAl5JGW9tYEj96mnpG6c0YnxBncghrP5ajcAt6XPmFI6llw4tA1JGN/s400/255122_113977178768425_788233520_n.jpg&quot; width=&quot;520&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTVHKn2zDbwdzFwJI9kjc5cHCA-ylyXt7gTWhTdxnjl7ufVWVmO5VDO9T_7Aon4OBwErIt7Xi6rpQhdLLsRf0OTNNGGz9pBLtgti6gu4AYgZ6PLwUDoDZ1Pl2FaqI4NmGUYjTNtYaPrEb2/s400/151009_113978132101663_1976055760_n.jpg&quot; width=&quot;520&quot; /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjuxDSSvFqltbN0Ui_nCx-D7j-3XOLR7P-YtNPm_cYWK3FX61ymA15GngeViqcmHXJ9ugThumM6VP9N3SV40Rt6-eFvPMQquP18P_9gqQ1a2q8rg1Q2tLXOMt4rIXA4S6fwUpxjMP2JJc5m/s400/530359_113978455434964_473529652_n.jpg&quot; width=&quot;520&quot; /&gt;&lt;/div&gt;
</description><link>http://jawbfl.blogspot.com/2012/12/mcpc-2012-just-another-wonderful-day.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPJ5nq2WYfCriyuScO-4buFuxKOcN9x6yWjdJ6v6gGIBfyio35VHygapDlqzXLfcvV3HDATKm9eMlgkFTT8woEA8F2LSlMm4DC6vuP-OH7dY4EIOdP4uvmgiKCLyM76rs8KBg_ih2nVI7S/s72-c/12577_113976058768537_1872477103_n.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-241685218798945272</guid><pubDate>Thu, 06 Sep 2012 17:29:00 +0000</pubDate><atom:updated>2012-09-06T18:39:13.521+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">php</category><title>PHPLogger: Debugging PHP in console</title><description>&lt;div&gt;
&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
Yesterday, I got nostalgic about PHP because recently I used too much&amp;nbsp;JavaScript&amp;nbsp;and some Python, and what these two have in common is real easy debugging beside coolness . Back to PHP days I didn&#39;t care about&amp;nbsp;debugging because I was a&amp;nbsp;beginner - and still :P - , so I was satisfied with the old tricks echo, print_r , var_dump, die ... - etc&amp;nbsp;Like if there is many :) - .&lt;br /&gt;
&lt;br /&gt;
Debugging PHP really sucks , I know that PHP fans will be furbishing their swords already and start praising their tools but additional software like Xdebug is not practical when used outside IDE. I hate to get confused by windows so I use only two : Browser/Editor or Terminal/Editor.&amp;nbsp;Therefore, using other terminal(s) to debug makes me&amp;nbsp;discomfortable.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
Browser&#39;s console is the most awesome debugging tool: No more layout destruction, no more log file which needs refresh&amp;nbsp;every time and no more unreadable output. So why not using it for PHP too, FirePHP is a good choice but I found implementations that uses PHP to output&amp;nbsp;JavaScript&amp;nbsp;code that use console to log :&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.codeforest.net/debugging-php-in-browsers-javascript-console&quot;&gt;Debugging PHP in browser’s Javascript console&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://syakh.ir/2012/03/php-debug-javascript-console/&quot;&gt;LETS DEBUG PHP IN BROWSER JS CONSOLE&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://sarfraznawaz.wordpress.com/2012/01/05/outputting-php-to-browser-console/&quot;&gt;Outputting PHP To Browser Console&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Inspired by these codes I&amp;nbsp;tried to write my own ,&amp;nbsp;actually&amp;nbsp;I didn&#39;t like the fact that all those function can log one variable at once and always need extra arguments to specify type , which means I would use the&amp;nbsp;&lt;a href=&quot;http://php.net/manual/en/function.func-get-args.php&quot;&gt;func_get_args&lt;/a&gt;&amp;nbsp;to make it multi-arguments. But first console has 4 methods : log , warn , info , error . The only difference is the name so the use of&amp;nbsp;&lt;a href=&quot;http://php.net/manual/en/language.oop5.overloading.php&quot;&gt;method&amp;nbsp;overloading&lt;/a&gt;&amp;nbsp;__call($name, $arguments) is appropriate , the&amp;nbsp;benefit is that we already got the arguments so no need to use&amp;nbsp;&lt;a href=&quot;http://php.net/manual/en/function.func-get-args.php&quot;&gt;func_get_args&lt;/a&gt;&amp;nbsp;and no need to specify type.&lt;br /&gt;
What&#39;s left is conversions :
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Strings needs quotes.&lt;/li&gt;
&lt;li&gt;Objects and arrays are&amp;nbsp;JSON&amp;nbsp;encoded.&lt;/li&gt;
&lt;li&gt;Booleans get transformed to text.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
The code :&lt;br /&gt;
&lt;pre class=&quot;php&quot; name=&quot;code&quot;&gt;&amp;lt;?php
class console {
     function __call($name, $args) {
         if(!in_array($name, array(&quot;error&quot;,&quot;log&quot;,&quot;info&quot;,&quot;warn&quot;))) return;
         echo &#39;&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&#39;;
         $log = &quot;&quot;;
         foreach($args as $var) {
             if (is_object($var) || is_array($var)) $log .= json_encode($var).&quot;,&quot;;
             elseif (is_string($var)) $log .= &#39;&quot;&#39;.$var.&#39;&quot;,&#39;;
             elseif (is_bool($var)) $log .= ($var)?&quot;true,&quot;:&quot;false,&quot;;
             else $log .= $var.&quot;,&quot;;
         }
         $log = substr($log, 0,-1);
         echo &quot;console.$name(&quot;.$log.&quot;);&quot;;
         echo &#39;&amp;lt;/script&amp;gt;&#39;;
     }
}
//Add an instance but needs &quot;global&quot; when called from functions
$console = new console();
?&amp;gt;
&lt;/pre&gt;
And here is &lt;a href=&quot;https://github.com/jawb/PHPLogger&quot;&gt;the repo on Github&lt;/a&gt;&amp;nbsp;, enjoy !!</description><link>http://jawbfl.blogspot.com/2012/09/phplogger-debugging-php-in-console.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-4627621701852293687</guid><pubDate>Wed, 22 Aug 2012 14:43:00 +0000</pubDate><atom:updated>2012-08-30T16:54:25.511+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">matrixify</category><category domain="http://www.blogger.com/atom/ns#">python</category><category domain="http://www.blogger.com/atom/ns#">sublimetext2</category><title>Matrixify 1.1</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Update :&lt;/b&gt; Matrixify now on &lt;a href=&quot;http://wbond.net/sublime_packages/package_control&quot;&gt;Sublime Package Control&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Matrixify gets it&#39;s first update .. Oh Yeah !! :P , Seriously just a little update. I am new to Python and Sublime Text 2 plugins development but I used enough plugins to make me have the hunch that the method I&#39;m using to read the format is&amp;nbsp;not the genius one !!&lt;br /&gt;
&lt;br /&gt;
I am lazy to look for solution so I asked on the&lt;a href=&quot;http://www.sublimetext.com/forum/&quot;&gt; ST2 forum&lt;/a&gt; and &lt;a href=&quot;http://www.sublimetext.com/forum/memberlist.php?mode=viewprofile&amp;amp;u=1510&quot;&gt;facelessuser&lt;/a&gt; answered : Sublime have an &lt;a href=&quot;http://www.sublimetext.com/docs/2/api_reference.html#sublime.Window&quot;&gt;input form&lt;/a&gt; that prompt so it&#39;s a logical choice.&lt;br /&gt;
&lt;br /&gt;
Another thing that come up is the&amp;nbsp;indexes that I used for my arrays to output the matrix become much easier to calculate when the lines 0 is included.
&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;output += separators[i%dim] + line + (lengths[(i%dim)] - len(line))*&quot; &quot;
if (i%dim) == dim-1:
    output += separators[dim] + &quot;\n&quot;
&lt;/pre&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;The full new code using&amp;nbsp;&lt;b&gt;show_input_panel&lt;/b&gt; :&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;import sublime, sublime_plugin

class MatrixifyCommand(sublime_plugin.TextCommand):
 def run(self, edit):
  def on_done(input):
   sels = self.view.sel()
   for sel in sels:
    lines = []
    separators = []
    lengths = []
    dim = 0
    lines = self.view.substr(sel)
    lines = lines.splitlines()
    lines = filter(None, lines)
    lines = [i.strip() for i in lines]
    separators = input.split(&#39;%&#39;)
    dim = len(separators) - 1
    lengths = [0] * dim
    for i in range(dim):
     for l in range(i,len(lines)-1,dim):
      lengths[i] = max(lengths[i] , len(lines[l]))
    output = &quot;&quot;
    for i in range(0,len(lines)):
     line = lines[i]
     output += separators[i%dim] + line + (lengths[(i%dim)] - len(line))*&quot; &quot;
     if (i%dim) == dim-1:
      output += separators[dim] + &quot;\n&quot;
    self.view.replace(edit, sel, output)

  self.view.window().show_input_panel(&quot;Enter matrix format&quot;, &quot;&quot;, on_done, None, None)
&lt;/pre&gt;
&lt;br /&gt;
&lt;a href=&quot;https://github.com/jawb/Matrixify&quot;&gt;Repository&lt;/a&gt; on github try it , fork it , develop it.</description><link>http://jawbfl.blogspot.com/2012/08/matrixify-11.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-2756135304533022434</guid><pubDate>Thu, 16 Aug 2012 17:57:00 +0000</pubDate><atom:updated>2012-08-22T15:15:31.140+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">matrixify</category><category domain="http://www.blogger.com/atom/ns#">python</category><category domain="http://www.blogger.com/atom/ns#">sublimetext2</category><title>Matrixify - a Sublime text 2 plugin</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Back to blogging ? No and yes , No because I never quit blogging and yes because I wasn&#39;t working on any exciting thing &amp;nbsp;that&amp;nbsp;worths&amp;nbsp;sharing. for the past months I spent time on Android development - just some basic stuff - , and reading some C++ books . I found C++ very interesting whatever what people said about how complex it is , it&#39;s expressive and efficient that&#39;s what matters !!&lt;br /&gt;
&lt;br /&gt;
Back to our talk for today, I was trying to build a Gameboy emulator with C++ . I am new to the experience of emulation so I decided to read a source code to understand the architecture of the device.&lt;br /&gt;
There is a lot of open source emulators but I couldn&#39;t found a simple documented one , here comes &lt;a href=&quot;http://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-CPU&quot;&gt;Imran Nazar&lt;/a&gt; he tried to write an &lt;a href=&quot;https://github.com/Two9A/jsGB&quot;&gt;emulator using javascript&lt;/a&gt;, so I&#39;am translating the code into C++.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
The implementation of the Z80 - cpu of the Gameboy - requires a set of cpu instructions each implemented as a method of the Cpu class. This set of functions is declared in the .h file of the class and that&#39;s more than 600 function prototype !!!!&lt;br /&gt;
It&#39;s a wast of space and lack of readability to put a prototype per line or all in a single line , so I thought to format the code like a matrix.&lt;br /&gt;
&lt;br /&gt;
I am using &lt;a href=&quot;http://www.sublimetext.com/2&quot;&gt;Sublime Text 2&lt;/a&gt; because it&#39;s awesome ,I am not even going to argue about that, So I think I am lazy enough to write a plugin to do that for me. Python, I started reading a book but I didn&#39;t finish it because I found out that&#39;s it&#39;s a natural language, it doesn&#39;t need a book just a cheat&amp;nbsp;sheet and internet connection !!&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://net.tutsplus.com/tutorials/python-tutorials/how-to-create-a-sublime-text-2-plugin/&quot;&gt;This article&lt;/a&gt; from &lt;a href=&quot;http://net.tutsplus.com/&quot;&gt;Nettuts+&lt;/a&gt; is the best reference on the web on building ST2 plugins. The problem that I faced is input , how can I pass an input to my plugin ? I don&#39;t have limited number of inputs to use different commands , I think there is a prompt window but even if it exists it&#39;s not a good choice because I want to support multiple selections :/ .&lt;br /&gt;
&lt;br /&gt;
My approach is to use the first line of each selection as an input and parse it to specify the format of the matrix, the code is simple :&lt;br /&gt;
&lt;pre class=&quot;python&quot; name=&quot;code&quot;&gt;import sublime, sublime_plugin

class MatrixifyCommand(sublime_plugin.TextCommand):
 def run(self, edit):
  sels = self.view.sel()
  for sel in sels:
   lines = []
   separators = []
   lengths = []
   dim = 0
   lines = self.view.substr(sel)
   lines = lines.splitlines()
   lines = filter(None, lines)
   lines = [i.strip() for i in lines]
   separators = lines[0].split(&#39;%&#39;)
   dim = len(separators) - 1
   lengths = [0] * dim
   for i in range(dim):
    for l in range(i+1,len(lines)-1,dim):
     lengths[i] = max(lengths[i] , len(lines[l]))
   output = &quot;&quot;
   for i in range(1,len(lines)):
    index = dim-1 if (i%dim)==0 else (i%dim)-1
    line = lines[i]
    output += separators[index] + line + (lengths[(i%dim) -1] - len(line))*&quot; &quot;
    if (i%dim) == 0:
     output += separators[dim] + &quot;\n&quot;
   self.view.replace(edit, sel, output)

&lt;/pre&gt;
On &lt;a href=&quot;https://github.com/jawb/Matrixify&quot;&gt;my Github repository&lt;/a&gt; you can find other files used to specify the command , the Edit menu item and the keyboard shortcut. I sent a pull request to &lt;a href=&quot;https://github.com/wbond/sublime_package_control&quot;&gt;sublime package control&lt;/a&gt; , when it&#39;s accepted I&#39;ll update.</description><link>http://jawbfl.blogspot.com/2012/08/matrixify-sublime-text-2-plugin.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-6790974216875893211</guid><pubDate>Sat, 07 Apr 2012 21:01:00 +0000</pubDate><atom:updated>2012-04-09T00:25:47.116+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">InputCanvas</category><category domain="http://www.blogger.com/atom/ns#">js</category><title>Day 2 : InputCanvas 2.0</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Hi , Last time I wrote the &lt;b&gt;BasicShape&lt;/b&gt; object , today I think that I should add some proprieties : value &amp;amp; font in order to add text to shapes&lt;b&gt;.&lt;/b&gt; Also a font&#39;s setter method :
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;/**
&amp;nbsp;&amp;nbsp; * Set font proprieties.
&amp;nbsp;&amp;nbsp; *
&amp;nbsp;&amp;nbsp; * @param int size&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; : Size of border in pixel.
&amp;nbsp;&amp;nbsp; * @param string color&amp;nbsp; : Color of border (Hex).
&amp;nbsp;&amp;nbsp; * @param string family : Font family.
&amp;nbsp;&amp;nbsp; * @return void
*/
BasicShape.prototype.Font = function (size, color, family) {
&amp;nbsp;&amp;nbsp; this.font.size&amp;nbsp;&amp;nbsp; = size&amp;nbsp;&amp;nbsp; || 14;
&amp;nbsp;&amp;nbsp; this.font.color&amp;nbsp; = color&amp;nbsp; || &#39;#000000&#39;;
&amp;nbsp;&amp;nbsp; this.font.family = family || &#39;Arial&#39;;
};
&lt;/pre&gt;
The next big thing is how to draw text on a shape while respecting border , border-radius , and padding ?!!&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
Canvas has a method called &lt;b&gt;clip()&lt;/b&gt; which allow us to define clipping regions you can read more on
&lt;u&gt;&lt;b&gt;&lt;a href=&quot;http://www.html5canvastutorials.com/tutorials/html5-canvas-clipping-region-tutorial/&quot;&gt;1.5.6 HTML5 Canvas Clipping Region Tutorial&lt;/a&gt; &lt;/b&gt;&lt;/u&gt;. we will define a region using &lt;b&gt;Mcontrols&lt;/b&gt; method :
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;/**
&amp;nbsp; &amp;nbsp; * Get mask&#39;s controls
&amp;nbsp; &amp;nbsp; *
&amp;nbsp; &amp;nbsp; * @return array
*/
BasicShape.prototype.Mcontrols = function () {
&amp;nbsp; &amp;nbsp; var Mcontrols = [];
&amp;nbsp; &amp;nbsp; Mcontrols[0] &amp;nbsp;= {x : this.x + this.padding[3] , y : this.y + this.padding[0] };
&amp;nbsp; &amp;nbsp; Mcontrols[1] &amp;nbsp;= {x : this.x + this.width - this.padding[1] , y : this.y + this.padding[0] };
&amp;nbsp; &amp;nbsp; Mcontrols[2] &amp;nbsp;= {x : this.x + this.width - this.padding[1] , y : this.y + this.height - this.padding[2]};
&amp;nbsp; &amp;nbsp; Mcontrols[3] &amp;nbsp;= {x : this.x + this.padding[3] , y : this.y + this.height - this.padding[2]};
&amp;nbsp; &amp;nbsp; return Mcontrols;
};&lt;/pre&gt;
So the draw function become :
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;BasicShape.prototype.Draw = function () {
&amp;nbsp; &amp;nbsp; ....
&amp;nbsp; &amp;nbsp; // Clipping region
&amp;nbsp; &amp;nbsp; this.context.save();
&amp;nbsp; &amp;nbsp; this.context.beginPath();
&amp;nbsp; &amp;nbsp; this.context.rect(Mcontrols[0].x, Mcontrols[0].y, Mcontrols[1].x - Mcontrols[0].x, Mcontrols[3].y - Mcontrols[0].y);
&amp;nbsp; &amp;nbsp; this.context.closePath();
&amp;nbsp; &amp;nbsp; this.context.clip();
&amp;nbsp; &amp;nbsp; // Drawing Text
&amp;nbsp; &amp;nbsp; this.context.font &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = this.font.size+&#39;px &#39;+this.font.family;
&amp;nbsp; &amp;nbsp; this.context.fillStyle &amp;nbsp; &amp;nbsp;= this.font.color;
&amp;nbsp; &amp;nbsp; this.context.textBaseline = &#39;middle&#39;;
&amp;nbsp; &amp;nbsp; this.context.fillText(this.value, Mcontrols[0].x , Mcontrols[0].y + this.height / 2);
&amp;nbsp; &amp;nbsp; this.context.restore();
};
&lt;/pre&gt;
&lt;br /&gt;
That was quick , next time we will work on FormCanvas a form that contain different inputs and .</description><link>http://jawbfl.blogspot.com/2012/04/day-2-inputcanvas-20.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-6987451963503386156</guid><pubDate>Mon, 20 Feb 2012 01:03:00 +0000</pubDate><atom:updated>2012-08-21T07:34:28.954+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Blogger</category><category domain="http://www.blogger.com/atom/ns#">js</category><title>Blogger custom comment form [Wordpress like] - Part II</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://jawbfl.blogspot.com/2012/02/blogger-custom-comment-form-wordpress.html&quot;&gt;Last time&lt;/a&gt; we transformed all inputs to a single JSON object which would be stored in a plain text comment and sent to the server , this time we will try to display those comments.&lt;br /&gt;
&lt;br /&gt;
Ok we need to get the JSON string stored in comment&#39;s body from Blogger&#39;s database using :&lt;br /&gt;
&lt;pre class=&quot;html&quot; name=&quot;code&quot;&gt;&amp;lt;b:loop values=&#39;data:post.comments&#39; var=&#39;comment&#39;&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;data:comment.body /&amp;gt;
&amp;lt;/b:loop&amp;gt;
&lt;/pre&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;But first we want to add more information that we need to display. So we will define another JSON object that contains the previous one (which is into the body text of the comment)+ time &amp;amp; id :
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;{&quot;root&quot;: {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;comments&quot;: [
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;id&quot;: &quot;&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;time&quot;: &quot;&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;text&quot; : &quot;&quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; ]
&amp;nbsp; }
}}
&lt;/pre&gt;
Using Blogger&#39;s data tags we build the JSON string :
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
var json= {&quot;root&quot;: { &quot;comments&quot;: [
&amp;lt;b:loop values=&#39;data:post.comments&#39; var=&#39;comment&#39;&amp;gt;
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;id&quot;: &amp;lt;data:comment.id /&amp;gt;,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;time&quot;: &quot;&amp;lt;data:comment.timestamp /&amp;gt;&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;text&quot; :&amp;nbsp; &amp;lt;data:comment.body /&amp;gt;
},
&amp;lt;/b:loop&amp;gt;
]}}};
&amp;lt;/script&amp;gt;
&lt;/pre&gt;
All we need to do now is to read data using a simple loop through the JSON object and fill a pre-defined HTML template :&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;for(i in json.root.comments){
&amp;nbsp;&amp;nbsp;&amp;nbsp; html=&#39;&amp;lt;dialog id=com&#39;+json.root.comments[i].id+&#39;&amp;gt;&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; html+=&#39;&amp;lt;dt&amp;gt;&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; html+=&#39;&amp;lt;h1&amp;gt;&#39;+json.root.comments[i].text.name+&#39;&amp;lt;/h1&amp;gt;&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; html+=&#39;&amp;lt;h3&amp;gt;&#39;+json.root.comments[i].text.email+&#39;&amp;lt;/h3&amp;gt;&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; html+=&#39;&amp;lt;a href=&quot;&#39;+json.root.comments[i].text.url+&#39;&amp;gt;&#39; +json.root.comments[i].text.url+&#39;&amp;lt;/a&amp;gt;&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; html+=&#39;&amp;lt;img src=&quot;&#39;+json.root.comments[i].text.avatar+&#39;&quot;/&amp;gt;&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; html+=&#39;&amp;lt;time datetime=&quot;&#39;+json.root.comments[i].time+&#39;&quot;&amp;gt;&#39;+ json.root.comments[i].time+&#39;&amp;lt;/time&amp;gt;&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; html+=&#39;&amp;lt;/dt&amp;gt;&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; html+=&#39;&amp;lt;dd&amp;gt;&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; html+=&#39;&amp;lt;p&amp;gt;&#39;+json.root.comments[i].text.text+&#39;&amp;lt;/p&amp;gt;&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; html+=&#39;&amp;lt;/dd&amp;gt;&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; html+=&#39;&amp;lt;/dialog&amp;gt;&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $(&quot;#comments&quot;).html($(&quot;#comments&quot;).html() + html );
}
&lt;/pre&gt;
You can use more effects like a loading image or anything else .. of course a CSS style is a must and HTML still need some work.&lt;br /&gt;
&lt;br /&gt;
That&#39;s it using this method you can do anything with Blogger&#39;s comment box : add more inputs , advanced features like rating , sub-comments , bb code , comment using Twitter or Facebook ... It&#39;s up to you to&amp;nbsp;innovate&amp;nbsp;:)</description><link>http://jawbfl.blogspot.com/2012/02/blogger-custom-comment-form-wordpress_20.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-1673177983169217154</guid><pubDate>Sat, 11 Feb 2012 19:39:00 +0000</pubDate><atom:updated>2012-08-21T07:28:17.407+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Blogger</category><category domain="http://www.blogger.com/atom/ns#">js</category><title>Blogger custom comment form [Wordpress like] - Part I</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
I was playing with Blogger&#39;s comment form using Firebug . If you don&#39;t know, Blogger uses an iframe to display the form , So because of the &lt;a href=&quot;http://en.wikipedia.org/wiki/Same_origin_policy&quot;&gt;Cross-domain&lt;/a&gt; we can&#39;t style the form neither apply any Javascript code on it .&lt;br /&gt;
&lt;br /&gt;
First, you need to know the major inconvenient of this method : &lt;b&gt;comments will be considered as spam&lt;/b&gt; , So you have to check &lt;b&gt;Not spam&lt;/b&gt; manually every time to make the comment visible (if you already administrating comments then you are used to).&lt;br /&gt;
&lt;br /&gt;
Let&#39;s look at the next HTML code :
&lt;br /&gt;
&lt;pre class=&quot;html&quot; name=&quot;code&quot;&gt; 
&amp;lt;form id=&quot;commentForm&quot; method=&quot;POST&quot; action=&quot;http://www.blogger.com/comment-iframe.do&quot;&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type=&quot;text&quot; id=&quot;user&quot; placeholder=&quot;User Name&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type=&quot;email&quot; id=&quot;email&quot; placeholder=&quot;email&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type=&quot;url&quot; id=&quot;url&quot; placeholder=&quot;Website&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;textarea id=&quot;text&quot;&amp;nbsp; placeholder=&quot;Text...&quot;&amp;gt;&amp;lt;/textarea&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type=&quot;hidden&quot; name=&quot;commentBody&quot; id=&quot;commentBody&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type=&quot;hidden&quot; name=&quot;security_token&quot; value=&quot;AAAAAAAAAAAAAAAAAAAAAAAAAA:***********&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type=&quot;hidden&quot; name=&quot;blogID&quot; value=&quot;**************&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type=&quot;hidden&quot; name=&quot;postID&quot; expr:value=&quot;data:post.id&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type=&quot;hidden&quot; name=&quot;identityMenu&quot; value=&quot;ANON&quot; /&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;button id=&quot;sub&quot;&amp;gt;Submit&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;&lt;/pre&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&amp;nbsp;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt; &lt;b&gt;url&lt;/b&gt; : http://www.blogger.com/comment-iframe.do&lt;/li&gt;
&lt;li&gt;&lt;b&gt;security_token&lt;/b&gt; : It&#39;s a key used by Blogger to check the source of the request you can extract it from your comment box using Firebug or similar.&lt;/li&gt;
&lt;li&gt; &lt;b&gt;blogID&lt;/b&gt; : Blog identifier (you can get it easily from the admin panel )&lt;/li&gt;
&lt;li&gt;&lt;b&gt;postID&lt;/b&gt; : Post identifier (&lt;b&gt;expr:value=&quot;data:post.id&quot;&lt;/b&gt; is a data tag in Blogger )&lt;/li&gt;
&lt;li&gt;&lt;b&gt;identityMenu&lt;/b&gt; : This is the id of the select that displays different types of identifications we choose &lt;b&gt;ANON&lt;/b&gt; which stands for &lt;b&gt;Anonymous &lt;/b&gt; (you have to set &lt;span class=&quot;GPH-SWHBPK&quot;&gt;&lt;b&gt;Who can comment?&lt;/b&gt; to &lt;/span&gt;&lt;b&gt;Anyone&lt;/b&gt;)&lt;/li&gt;
&lt;li&gt;&lt;b&gt;commentBody&lt;/b&gt; : the comment text.&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
Now you need to replace the &lt;b&gt;&amp;lt;b:include data=&#39;post&#39; name=&#39;comment-form&#39;/&amp;gt;&lt;/b&gt; by&amp;nbsp; the html code above.&lt;br /&gt;
Next step is to create a JSON object that will contains the dataset :
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt; 
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;comment&quot; :
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;user&quot; : &quot;&quot; ,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;email&quot; : &quot;&quot; ,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;url&quot; : &quot;&quot; ,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;avatar&quot; : &quot;&quot;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;text&quot; : &quot;&quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}&lt;/pre&gt;
And a function that will format the comment to be ready for saving as JSON :
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;$(&#39;#sub&#39;).click(function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var text = &#39;{&#39; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + &#39;&quot;comment&quot;:{&#39;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + &#39;&quot;user&quot;: &quot;&#39; + $(&#39;#user&#39;).val() + &#39;&quot;,&#39;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + &#39;&quot;email&quot;: &quot;&#39; + $(&#39;#email&#39;).val() + &#39;&quot;,&#39;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + &#39;&quot;url&quot;: &quot;&#39; + $(&#39;#url&#39;).val() + &#39;&quot;,&#39;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + &#39;&quot;avatar&quot;: &quot;http://www.gravatar.com/avatar/&#39; + MD5($(&#39;#url&#39;).val()) + &#39;?s=80&amp;amp;d=DEFAULT_AVATAR_URL&quot;,&#39;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; + &#39;&quot;text&quot;: &quot;&#39; + escape($(&#39;#text&#39;).val()) + &#39;&quot;}}&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(&#39;#commentBody&#39;).val(text);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(&#39;#commentForm&#39;).submit();
});&lt;/pre&gt;
I used the Gravatar URL to get avatar from the email , so we need to encode the email using MD5 , I used the implementation from &lt;b&gt;&lt;a href=&quot;http://www.webtoolkit.info/javascript-md5.html&quot;&gt;webtoolkit.info&lt;/a&gt;&lt;/b&gt; .&lt;br /&gt;
Don&#39;t forget to set the &lt;b&gt;DEFAULT_AVATAR_URL&lt;/b&gt; it&#39;s the default avatar URL , What a surprise :D !!!&lt;br /&gt;
&lt;br /&gt;
Now our comment form is ready to save comments , Next time we will create the parser that will load and display comments . See you soon !!&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Part II :&lt;/b&gt;&lt;/u&gt;&amp;nbsp;&lt;a href=&quot;http://jawbfl.blogspot.com/2012/02/blogger-custom-comment-form-wordpress_20.html&quot;&gt;http://jawbfl.blogspot.com/2012/02/blogger-custom-comment-form-wordpress_20.html&lt;/a&gt;</description><link>http://jawbfl.blogspot.com/2012/02/blogger-custom-comment-form-wordpress.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-1111735337646724497</guid><pubDate>Fri, 10 Feb 2012 16:37:00 +0000</pubDate><atom:updated>2012-02-10T21:04:00.983+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">canvas</category><category domain="http://www.blogger.com/atom/ns#">html5</category><title>Canvas : Shape + shadow</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Hi, I&#39;ve been working on &lt;b&gt;InputCanvas&lt;/b&gt; and I faced an issue , finally I got to the solution and I&#39;ll share it with you .&lt;br /&gt;
&lt;br /&gt;
I&#39;ll use this beautiful cloud from &lt;b&gt;&lt;a href=&quot;http://www.html5canvastutorials.com/tutorials/html5-canvas-shape-fill/&quot;&gt;html5canvastutorials.com&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;136&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxhEgZY3pI1D2PC76zNHoYgt574bwZ4VdwL8xPYYkUgz4lqIODGu1EfnCfFjey8upw6dAY35BlTFukj8ZFRSAbZ0S4sbSzAGIUj6BC_BcXAaf_c5Ftv3EvZpn_yHDMo4npGaNTvKB3kcTX/s400/canvas.png&quot; width=&quot;400&quot; /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;the code :
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;var canvas = document.getElementById(&quot;myCanvas&quot;);
var context = canvas.getContext(&quot;2d&quot;);
context.beginPath();
context.moveTo(170, 80);
context.bezierCurveTo(130, 100, 130, 150, 230, 150);
context.bezierCurveTo(250, 180, 320, 180, 340, 150);
context.bezierCurveTo(420, 150, 420, 120, 390, 100);
context.bezierCurveTo(430, 40, 370, 30, 340, 50);
context.bezierCurveTo(320, 5, 250, 20, 250, 50);
context.bezierCurveTo(200, 5, 150, 20, 170, 80);
context.closePath();
context.lineWidth = 5;
context.fillStyle = &quot;#8ED6FF&quot;;
context.fill();
context.strokeStyle = &quot;#0000ff&quot;;
context.stroke();
&lt;/pre&gt;
To add a shadow we have to set shadow&#39;s proprieties :
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;context.shadowColor&amp;nbsp;&amp;nbsp; = &quot;#000000&quot;;
context.shadowBlur&amp;nbsp;&amp;nbsp;&amp;nbsp; = 3;
context.shadowOffsetX = 5;
context.shadowOffsetY = 5;
&lt;/pre&gt;
Our problem is how to place the shadow ?!!

first thing I did was :
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;....
context.closePath();
context.lineWidth = 5;
context.fillStyle = &quot;#8ED6FF&quot;;
context.strokeStyle = &quot;#0000ff&quot;;
context.shadowColor = &quot;#000000&quot;;
context.shadowBlur = 2;
context.shadowOffsetX = 5;
context.shadowOffsetY = 5;
context.fill();
context.stroke();
&lt;/pre&gt;
The result :
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; height=&quot;171&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhstSQJary1ChZNPXaOzPee7NdWVM9sHX5PYVmLzCOikF7rL0hdATcXprrsE9IxBglD0GXH2IU8aOYNJG-uHJvIVru5v-Bd3_8w94dMN8YB84twwkQLuNN2Wi17b3k640U97_BvsssxoT8t/s320/1.jpg&quot; width=&quot;320&quot; /&gt;&lt;/div&gt;
I was confused I tried to try all different kind of arrangements but all I got was weird results . So I posted the question at &lt;a href=&quot;http://stackoverflow.com/questions/9229707/canvas-shape-shadow&quot;&gt;&lt;b&gt;stackoverflow&lt;/b&gt; &lt;/a&gt;, &lt;b&gt;&lt;a href=&quot;http://stackoverflow.com/users/285178/neurofluxation&quot;&gt;@Neurofluxation&lt;/a&gt;&lt;/b&gt; proposed a solution using &lt;b&gt;&lt;a href=&quot;https://developer.mozilla.org/samples/canvas-tutorial/6_1_canvas_composite.html&quot;&gt;globalCompositeOperation&lt;/a&gt;&lt;/b&gt; :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;....
context.closePath();
context.lineWidth = 5;
context.fillStyle = &quot;#8ED6FF&quot;;
context.strokeStyle = &quot;#0000ff&quot;;
context.fill();    
context.globalCompositeOperation = &quot;destination-over&quot;;
context.shadowColor = &quot;#000000&quot;;
context.shadowBlur    = 9; 
context.shadowOffsetX = 3; 
context.shadowOffsetY = 3;    
context.stroke();&lt;/pre&gt;
:D what he really did her is to increase offset to hide the white space between the shape and the shadow . because it&#39;s the stroke&#39;s shadow not the fill&#39;s !!!


&lt;b&gt;&lt;a href=&quot;http://jsfiddle.net/j8u8p/16/%20&quot;&gt;http://jsfiddle.net/j8u8p/16/ &lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
I accepted the answer -but I wasn&#39;t convinced - so I did some experiments , Then I understood the issue ; the problem is that Canvas&#39;s shadow is defined to be applied to every drawing ( fill, stroke , .. ) Therefore what I need to do is to apply shadow on the fill then remove it so it wouldn&#39;t be applied to the stroke.&lt;br /&gt;
&lt;b&gt;The Final solution :&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;a href=&quot;http://jsfiddle.net/j8u8p/18/&quot;&gt;http://jsfiddle.net/j8u8p/18/ &lt;/a&gt;&lt;/b&gt;

&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUQ_8NP4DMgtfqPIIiBTeDWznMRnqM8f0pofzS9E7XMY90mA6VVbHMzJFNr7PaoRh26hbRflDVzCy-BmA4B-fsVGChx4Pug1qP_Lg0QUSIUBXTihLf10gxb7a_sQ428ANYTJ-39vH3ktZb/s1600/2.jpg&quot; /&gt;&lt;/div&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;var canvas = document.getElementById(&quot;myCanvas&quot;);
var context = canvas.getContext(&quot;2d&quot;);
context.beginPath();
context.moveTo(170, 80);
context.bezierCurveTo(130, 100, 130, 150, 230, 150);&amp;nbsp;
context.bezierCurveTo(250, 180, 320, 180, 340, 150);
context.bezierCurveTo(420, 150, 420, 120, 390, 100);
context.bezierCurveTo(430, 40, 370, 30, 340, 50);
context.bezierCurveTo(320, 5, 250, 20, 250, 50);
context.bezierCurveTo(200, 5, 150, 20, 170, 80);
context.closePath();
context.lineWidth = 5;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
context.fillStyle = &quot;#8ED6FF&quot;;
context.strokeStyle = &quot;#0000ff&quot;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
context.shadowColor = &quot;#000000&quot;;
context.shadowBlur&amp;nbsp;&amp;nbsp;&amp;nbsp; = 5;
context.shadowOffsetX = 8;
context.shadowOffsetY = 8;
context.fill();&amp;nbsp;&amp;nbsp;&amp;nbsp; 
context.shadowColor = 0;
context.shadowBlur&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0;
context.shadowOffsetX = 0;
context.shadowOffsetY = 0;
context.stroke();
&lt;/pre&gt;</description><link>http://jawbfl.blogspot.com/2012/02/canvas-shape-shadow.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxhEgZY3pI1D2PC76zNHoYgt574bwZ4VdwL8xPYYkUgz4lqIODGu1EfnCfFjey8upw6dAY35BlTFukj8ZFRSAbZ0S4sbSzAGIUj6BC_BcXAaf_c5Ftv3EvZpn_yHDMo4npGaNTvKB3kcTX/s72-c/canvas.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-2103652504711200542</guid><pubDate>Tue, 07 Feb 2012 15:57:00 +0000</pubDate><atom:updated>2012-02-07T16:05:23.344+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">InputCanvas</category><category domain="http://www.blogger.com/atom/ns#">js</category><title>Day 1 : InputCanvas 2.0</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Today I&#39;ll start redesigning &lt;b&gt;InputCanvas&lt;/b&gt; , the old version wasn&#39;t clear and customisable. There was only 2 objects &lt;b&gt;FormCanvas&lt;/b&gt; and &lt;b&gt;InputCanvas&lt;/b&gt; , and only text input.&lt;br /&gt;
In this new version I&#39;ll try to create so match more objects that we can use separately. Also I&#39;m going to use one of the most important feature in OOP which is inheritance , the most important object is &lt;b&gt;BasicShape &lt;/b&gt;it&#39;s the parent object of all types of inputs with basic proprieties and methods.&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
First of all , I&#39;ll define a very useful function &lt;b&gt;setNumArr(arg, max)&lt;/b&gt; , this function will be used to set some proprieties with the form of a 4x array like border, padding ... etc&lt;br /&gt;
Code speaks louder than words :&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt; 
function setNumArr(arg,max)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(typeof arg === &#39;number&#39;)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var tmp = parseInt(arg);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(max &amp;amp;&amp;amp; tmp &amp;gt; max) tmp = max;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return [tmp, tmp, tmp, tmp];
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; else if(typeof arg === &#39;object&#39; &amp;amp;&amp;amp; arg.length == 4)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;4;i++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(max &amp;amp;&amp;amp; arg[i] &amp;gt; max) arg[i] = max;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return arg;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; else return [0, 0, 0, 0];
}
&lt;/pre&gt;
Now the BasicShape definition :&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;// The basic shape element

function BasicShape(canvas,x,y,width,height)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Main proprieties
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.canvas&amp;nbsp; = canvas;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // HTML canvas element
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context = canvas.getContext(&quot;2d&quot;);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Context of canvas
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.x&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = x || 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Top left corner X
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.y&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = y || 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Top left corner Y
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.id&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = &#39;&#39;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Identifier
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.mousein&amp;nbsp; = false;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Mouse Status
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.mouseinp = false;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Mouse Previous Status
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.focus&amp;nbsp;&amp;nbsp;&amp;nbsp; = false;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Focus status
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.view&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = true;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Visibility

&amp;nbsp;&amp;nbsp;&amp;nbsp; // Others
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.width&amp;nbsp;&amp;nbsp;&amp;nbsp; = width;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Width
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.height&amp;nbsp;&amp;nbsp; = height;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Height
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.padding&amp;nbsp; = [1, 1, 1, 1];&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Padding
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.border&amp;nbsp;&amp;nbsp; = {color:&#39;#000000&#39;,size:2,radius:[1, 1, 1, 1]}; // Border
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.shadow&amp;nbsp;&amp;nbsp; = {color:&#39;&#39;,blur:0,x:0,y:0};&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Shadow
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.bg&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = &#39;#FFFFFF&#39;;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Background color
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Event hundlers.
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onMouseMove = function (){};
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onMouseOver = function (){};
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onMouseOut&amp;nbsp; = function (){};
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onMouseDown = function (){};
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onMouseUp&amp;nbsp;&amp;nbsp; = function (){};
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onKeyDown&amp;nbsp;&amp;nbsp; = function (){};
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onKeyUp&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = function (){};
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onKeyPress&amp;nbsp; = function (){};
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onBlur&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = function (){};
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onFocus&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = function (){};
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onClick&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = function (){};
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.onHover&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = function (){};
}
&lt;/pre&gt;
Now we have to define some methods :&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;1- Setters :&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt; 
/**
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Set border proprieties.
&amp;nbsp;&amp;nbsp;&amp;nbsp; *
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param int size&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; : Size of border in pixel.
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param string color : Color of border (Hex).
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param int radius, array radius : Border radius [top,right,bottom,left].
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @return void
*/
BasicShape.prototype.Border = function (size, color, radius) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.border.size&amp;nbsp;&amp;nbsp; = size&amp;nbsp; || 2;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.border.color&amp;nbsp; = color || &#39;#000000&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.border.radius = setNumArr(radius,Math.min(this.width/2,this.height/2));
};

/**
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Set padding.
&amp;nbsp;&amp;nbsp;&amp;nbsp; *
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param int padding, array padding : [top,right,bottom,left].
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @return void
*/
BasicShape.prototype.Padding = function (padding) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.padding = setNumArr(padding);
};

/**
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Set shadow/light proprieties.
&amp;nbsp;&amp;nbsp;&amp;nbsp; *
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param string color : Color of border (Hex).
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param int x&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : Offset x in pixel.
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param int y&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : Offset y in pixel.
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @param int blur&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : Blur.
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @return void
*/
BasicShape.prototype.Shadow = function (color, x, y, blur) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.shadow.color&amp;nbsp; = color || &#39;#000000&#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.shadow.x&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = x || 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.shadow.y&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = y || 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.shadow.blur&amp;nbsp;&amp;nbsp; = blur || 0;
};
&lt;/pre&gt;
&lt;u&gt;&lt;b&gt;2- Correcting X, Y, Width, Height :&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;br /&gt;
Canvas&#39;s lineTo() defines a line , stroke() draws a stroke on the current sub-path using the current stroke style , which is not the desired result. The effect that we are looking for is similar to CSS&#39;s borders , so we have to translate the border by a (border&#39;s size / 2 ) offset.
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM-qI97K2O0qWWE0SSfySDwGRSg1QvtLEGo5FUjL7Y2aSRPBEQARzqEzS2kdehDiN73Y1IZMTjdC1PT_SuqbLb4PhyphenhypheneVhNKJXMKfSXnrhmKdUU7ZRV-FmtllJ9ZFtu-qUp3A-mNk-3A8Yr/s1600/Untitled-2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;165&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM-qI97K2O0qWWE0SSfySDwGRSg1QvtLEGo5FUjL7Y2aSRPBEQARzqEzS2kdehDiN73Y1IZMTjdC1PT_SuqbLb4PhyphenhypheneVhNKJXMKfSXnrhmKdUU7ZRV-FmtllJ9ZFtu-qUp3A-mNk-3A8Yr/s400/Untitled-2.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt; 
/**
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Get top left corner X.
&amp;nbsp;&amp;nbsp;&amp;nbsp; *
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @return int
*/
BasicShape.prototype.X = function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp; return this.x-this.border.size/2;
};

/**
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Get top left corner Y.
&amp;nbsp;&amp;nbsp;&amp;nbsp; *
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @return int
*/
BasicShape.prototype.Y = function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp; return this.y-this.border.size/2;
};

/**
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Get top right corner X.
&amp;nbsp;&amp;nbsp;&amp;nbsp; *
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @return int
*/
BasicShape.prototype.WidthX = function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp; return this.x+this.border.size/2+this.width;
};

/**
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Get top right corner Y.
&amp;nbsp;&amp;nbsp;&amp;nbsp; *
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @return int
*/
BasicShape.prototype.HeightY = function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp; return this.y+this.border.size/2+this.height;
};
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;3- Lines coordinates&lt;/b&gt; ( To create the border radius effect ):&lt;/u&gt;&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt; 
/**
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Get lines start.
&amp;nbsp;&amp;nbsp;&amp;nbsp; *
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @return array
*/
BasicShape.prototype.LineStart = function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var linestart = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; linestart[0]&amp;nbsp; = {x : this.X() + this.border.radius[0] , y : this.Y()};
&amp;nbsp;&amp;nbsp;&amp;nbsp; linestart[1]&amp;nbsp; = {x : this.WidthX() , y : this.Y() + this.border.radius[1]};
&amp;nbsp;&amp;nbsp;&amp;nbsp; linestart[2]&amp;nbsp; = {x : this.X() - this.border.radius[2], y : this.HeightY()};
&amp;nbsp;&amp;nbsp;&amp;nbsp; linestart[3]&amp;nbsp; = {x : this.X(), y : this.HeightY() - this.border.radius[3]};
&amp;nbsp;&amp;nbsp;&amp;nbsp; return linestart;
};

/**
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Get lines end.
&amp;nbsp;&amp;nbsp;&amp;nbsp; *
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @return array
*/
BasicShape.prototype.LineEnd = function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var lineend&amp;nbsp;&amp;nbsp; = [];
&amp;nbsp;&amp;nbsp;&amp;nbsp; lineend[0]&amp;nbsp;&amp;nbsp;&amp;nbsp; = {x : this.WidthX() - this.border.radius[1] , y : this.Y()};
&amp;nbsp;&amp;nbsp;&amp;nbsp; lineend[1]&amp;nbsp;&amp;nbsp;&amp;nbsp; = {x : this.WidthX() , y : this.HeightY() - this.border.radius[2]};
&amp;nbsp;&amp;nbsp;&amp;nbsp; lineend[2]&amp;nbsp;&amp;nbsp;&amp;nbsp; = {x : this.X() + this.border.radius[3], y : this.HeightY()};
&amp;nbsp;&amp;nbsp;&amp;nbsp; lineend[3]&amp;nbsp;&amp;nbsp;&amp;nbsp; = {x : this.X() , y : this.Y() + this.border.radius[0]};
&amp;nbsp;&amp;nbsp;&amp;nbsp; return lineend;
};
&lt;/pre&gt;
4- Draw :&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt; 
/**
&amp;nbsp;&amp;nbsp;&amp;nbsp; * Draw input&#39;s shape.
&amp;nbsp;&amp;nbsp;&amp;nbsp; *
&amp;nbsp;&amp;nbsp;&amp;nbsp; * @return array
*/
BasicShape.prototype.Draw = function () {
&amp;nbsp;&amp;nbsp;&amp;nbsp; var linestart = this.LineStart();
&amp;nbsp;&amp;nbsp;&amp;nbsp; var lineend&amp;nbsp;&amp;nbsp; = this.LineEnd();
&amp;nbsp;&amp;nbsp;&amp;nbsp; var controls&amp;nbsp; = this.Controls();
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.beginPath();
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.moveTo(linestart[0].x, linestart[0].y);
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.lineTo(lineend[0].x, lineend[0].y);
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.arcTo(controls[1].x,controls[1].y,linestart[1].x, linestart[1].y,this.border.radius[1]);
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.lineTo(lineend[1].x, lineend[1].y);
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.arcTo(controls[2].x,controls[2].y,linestart[2].x, linestart[2].y,this.border.radius[2]);
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.lineTo(lineend[2].x, lineend[2].y);
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.arcTo(controls[3].x,controls[3].y,linestart[3].x, linestart[3].y,this.border.radius[3]);
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.lineTo(lineend[3].x, lineend[3].y);
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.arcTo(controls[0].x,controls[0].y,linestart[0].x, linestart[0].y,this.border.radius[0]);
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.shadowColor&amp;nbsp;&amp;nbsp; = this.shadow.color;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.shadowBlur&amp;nbsp;&amp;nbsp;&amp;nbsp; = this.shadow.blur;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.shadowOffsetX = this.shadow.x;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.shadowOffsetY = this.shadow.y;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.fillStyle&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = this.bg;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.fill();
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.lineWidth&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = this.border.size;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.strokeStyle&amp;nbsp;&amp;nbsp; = this.border.color;
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.stroke();
&amp;nbsp;&amp;nbsp;&amp;nbsp; this.context.closePath();
};
&lt;/pre&gt;
&lt;br /&gt;
That&#39;s all for today , next time we will create the FormCanvas object .</description><link>http://jawbfl.blogspot.com/2012/02/day-1-inputcanvas-20.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiM-qI97K2O0qWWE0SSfySDwGRSg1QvtLEGo5FUjL7Y2aSRPBEQARzqEzS2kdehDiN73Y1IZMTjdC1PT_SuqbLb4PhyphenhypheneVhNKJXMKfSXnrhmKdUU7ZRV-FmtllJ9ZFtu-qUp3A-mNk-3A8Yr/s72-c/Untitled-2.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-4204062376660175506</guid><pubDate>Mon, 06 Feb 2012 14:23:00 +0000</pubDate><atom:updated>2012-02-06T15:00:29.560+00:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">InputCanvas</category><category domain="http://www.blogger.com/atom/ns#">js</category><title>InputCanvas 2.0</title><description>&lt;b&gt;May Allah`s peace , mercy and blessing be upon you&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Hi, I have been developing &lt;b&gt;InputCanvas.js&lt;/b&gt; in the open (on &lt;b&gt;&lt;a href=&quot;https://github.com/jawb/InputCanvas&quot;&gt;github.com&lt;/a&gt;&lt;/b&gt;), It&#39;s the first Javascript Library to create real forms and inputs on the Canvas element . It&#39;s not HTML&#39;s native inputs and no CSS positioning .&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;What can I do with InputCanvas?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
You can create forms and inputs that work exactly like usual html fields on canvas , with events and style support.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How can I use it ?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Using InputCanvas is really simple . just follow the steps :&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1-Include the library in your page :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;html&quot; name=&quot;code&quot;&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;inputcanvas.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&lt;/pre&gt;
&lt;b&gt;2-Create a new instance of the FormCanvas object&lt;/b&gt; (a canvas should have one form).&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;var canvas = document.getElementById(&#39;myCanvas&#39;);
var form = new FormCanvas(canvas);
form.Init();
&lt;/pre&gt;
&lt;b&gt;3-Add inputs to your form :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;var inp = form.addInput(100,100,250,40);
var inp2 = form.addInput(100,200,200,30);
&lt;/pre&gt;
&lt;b&gt;4-Styling :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;inp.border.radius = [10,0,20,0];
inp.border.color = &#39;#FF0000&#39;;
inp.border.size = 10;
&lt;/pre&gt;
Or
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;inp.Border(10,&#39;#FF0000&#39;,[10,0,20,0]);&lt;/pre&gt;
&lt;b&gt;5-Add Event Handlers :&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;inp.onFocus = function(){inp.border.color = &#39;#DD0125&#39;;};&lt;/pre&gt;
&lt;br /&gt;
That&#39;s the old documentation you can try the Demo of InputCanvas 1.1 on &lt;b&gt;&lt;a href=&quot;http://jsfiddle.net/QGY5y/&quot;&gt;Jsfiddle&lt;/a&gt;&lt;/b&gt; , now I am working on redesigning the whole library &lt;b&gt;InputCanvas2.0.js &lt;/b&gt;is going to be too different , I&#39;ll post changes and major differences. Wish me luck !!</description><link>http://jawbfl.blogspot.com/2012/02/inputcanvas-20.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-6615951333885165843.post-8671177731971859942</guid><pubDate>Sun, 05 Feb 2012 14:32:00 +0000</pubDate><atom:updated>2012-08-21T07:38:56.708+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Misc</category><title>Why english ??</title><description>&lt;div style=&quot;color: black; text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-family: Book Antiqua;&quot;&gt;May Allah`s peace , mercy and blessing be upon you&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: black; text-align: center;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Book Antiqua;&quot;&gt;Ok, for a long time I was blogging in Arabic - I don&#39;t know yet but may be I&#39;ll continue - , for the moment I am trying to start blogging in English . Why? that&#39;s a good question.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Book Antiqua;&quot;&gt;First of all , I am working on some open source projects. So you guessed I need to write documentations, instructions , tutorials and so on . Writing those things in Arabic or French is against Freedom of information . English is international , that&#39;s a fact specially in technical domains ,&amp;nbsp; people all over the world can read and understand what I am writing : &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Book Antiqua;&quot;&gt;Africa , &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Book Antiqua;&quot;&gt;ME , &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Book Antiqua;&quot;&gt;US , UK , China , India , Japan ...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;stream _p _pl1 _pd692060&quot; id=&quot;view&quot; style=&quot;color: black; font-size: small;&quot;&gt;&lt;span class=&quot;mtxt&quot;&gt;Secondly&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;color: black; font-family: Book Antiqua;&quot;&gt;,&lt;/span&gt; I should switch my blogging efforts to English articles, in order to reach a wider audience , get more feedback and to have&amp;nbsp;interesting&amp;nbsp;discussions.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;In the third place , Blogging and Tweeting are my only activities that needs writing :) , So I want to improve my English by writing articles .&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;I hope this blog will be good enough for you . Enjoy reading and reacting . &lt;/span&gt;&lt;/div&gt;
</description><link>http://jawbfl.blogspot.com/2012/02/why-english.html</link><author>noreply@blogger.com (Anonymous)</author><thr:total>0</thr:total></item></channel></rss>