The problem is the following, my canvas width and height is relative to its parents. In css, its width and height is set to 95%. That causes my getMousePosition function to not work properly, meaning that when I click on a canvas point, the actual point where say a rectangle is drawn is far from the observed clicked point.  Here is the html stuff  &lt;div class="Container"&gt;             &lt;div id = 'left-div'&gt;                 &lt;canvas class = "Blackboard" id = "blackboard-canvas" &gt;                  &lt;/canvas&gt;             &lt;/div&gt;                               &lt;div id='right-div'&gt;                 &lt;div id = 'tools-div'&gt;                     &lt;ul&gt;                         &lt;li&gt;&lt;a href='#colorOption'&gt;Color Options&lt;/a&gt;&lt;/li&gt;                         &lt;li&gt;&lt;a href='#toolbar-option'&gt;Tool Bar&lt;/a&gt;&lt;/li&gt;                     &lt;/ul&gt;                     &lt;div id='colorOption'&gt;                         &lt;canvas id='color-option-canvas' &gt;                          &lt;/canvas&gt;                     &lt;/div&gt;                     &lt;div id='toolbar-option'&gt;                         Tool bar options goes here                     &lt;/div&gt;                 &lt;/div&gt;             &lt;/div&gt;              &lt;br style="clear:both;"/&gt;         &lt;/div&gt;     and the relavent css  .Blackboard{  border-style: ridge; border-color: gray; border-width: 5px;  width: 96%; height: 96%; cursor: crosshair; position: relative; -webkit-border-radius: 16px; -webkit-box-shadow: 0px 6px 7px #0a0505;   };   .Blackboard:active{ cursor: crosshair;   }   .Container{ border-color: #666; border-width: 10px; border-style: inset; background-color: gray; width: 700px; height: 400px;  }   #right-div, #left-div{ height: 100%;  }  #left-div{ float: left; width: 60%;  }  #right-div{ float: right; background-color: black; width: 40%;  }   Is there a way to 'normalize' it or or something?  EDIT:  here is a the jfiddle
What's the simplest way to add a click event handler to a canvas element that will return the x and y coordinates of the click (relative to the canvas element)?  No legacy browser compatibility required, Safari, Opera and Firefox will do.
We're trying to debug some applications performing broadcast.  What is the difference between the broadcast address 255.255.255.255 and as e.g. reported by ifconfig,  Bcast:192.168.1.255 What software can I use to view epub documents? What software can I use to view .epub documents? Let $A \in {M_n}$ is nonsingular and each eigenvalue of $A$ is either $+1$ or $-1$.Why $A$ is similar to ${A^{ - 1}}$? Why is there free space at the end of NTFS Partitioned Drives? I've been wondering this for a while, why is there free space at the end of a drive that was formatted to NTFS in windows?  You can only see the unallocated space in Linux. So why is it there? Does it serve a purpose? Suppose that $U_n=\frac{1}{\sqrt{2n\sigma^2}}\left(\Sigma X_j-\Sigma Y_j\right)$,  where $X_1,X_2,\ldots$ and $Y_i,Y_2, \ldots$ are i.i.d. sequences of random variables with mean $\mu$ and variance $\sigma^2$ and the sequences $\{X_i\}$ and $\{Y_i\}$ are independent.  Then, for all real numbers $x$, show that, as $n\to \infty$,  $$\mathbb{P}(U_n\leq x) \to  \int_{-\infty}^{x} \frac{1}{(\sqrt(2\pi))} \:e^{-\frac 12{u^2}}\mathrm du $$ Approach  I tried to carry out the integration on the right, but this does not integrate nicely. It ends up involving an error function, so I figured this was the wrong was to go.  Should I be looking at convergence in probability to answer this question? Is Chebyshev's inequality relevant here? If so, how and how does that relate to the integral? In cricket, in UDRS screen, if the ball hits the wicket, then why is not out still given? In cricket, in UDRS screen, if the ball hits the wicket, then why is not out still given?  I saw this situation so many times happened; bowler appealed for UDRS for LBW, in UDRS it shows ball hits the wicket, but still not out is given sometimes. Why won't closing the lid sleep my MacBook Pro with external monitor attached after upgrading to Lion? Letter O with vertical line: operator null How can I install the most used plugins like flash player and mp3 in Ubuntu? How to enumerate an enum How can you enumerate an enum in C#?  E.g. the following code does not compile:  public enum Suit {     Spades,     Hearts,     Clubs,     Diamonds }  public void EnumerateAllSuitsDemoMethod() {     foreach (Suit suit in Suit)     {         DoSomething(suit);     } }   And it gives the following compile-time error:     'Suit' is a 'type' but is used like a 'variable'   It fails on the Suit keyword, the second one. Charge controller for Li-ion or Li-Polymer battery I am trying to work out the good charger for Mobile phones, which can serve as good performer for various smart phones out there in market these days &amp; mostly using Li-ion battery. Charging has 4 stages -- "the initial trickle-charging, then constant current charging, then constant voltage charging &amp; finaly Top-up charge" -- all this is controlled &amp; monitored by a control circuit/IC of charger. So, my concern is if such circuit/module/IC is already there in Mobile phones &amp; taking care of all protections to battery/phone including overheating during charge OR The charger designer have to incorporate these circuits in Charger itself? If former case, that means we just need to make a charging source giving ample current &amp; 4.75V-5.25V voltage, like a high-powered USB output port would gives. My feeling is such stages-wise charging &amp; control/monitor circuitry is already within the phone set, i just want to reconfirm. Is it possible to associate non-blend files with Blender? Is there a way to make Blender auto import files that are not .blend when you open them?  For example if you open a .fbx file by double clicking on it, and you have Blender set as default application, then import it to a new .blend.  Is it possible to make Blender import this .fbx file just like you would do it manually by using File > Import > FBX?  By default, Blender just opens up and loads default new scene when you open anything that is not .blend file. Is there a word to describe a person who likes chaos? I am wondering if there is a word to describe a person who likes chaos. By this I mean a few specific things:   The person is pleased to hear when chaos is created, or confusion emerges The person will take opportunities to create chaos or confusion The person enjoys taking part in chaotic or disorganized situations.   I can't seem to think of a word to describe the type of person who would act in this way.  I hope this question is clear.  EDIT: Below gbutters sums up nicely:     What I wonder is if there is a word for a generally good-natured person who just likes some good old-fashioned chaos. It seems like any person that thrives on chaos would have to have some extra baggage. How can I SELECT rows with MAX(Column value), PARTITION by another column in MYSQL? My table is:     id home datetime player resource     1 10 04/03/2009 john 399   2 11 04/03/2009 juliet 244   5 12 04/03/2009 borat 555   3 10 03/03/2009 john 300   4 11 03/03/2009 juliet 200   6 12 03/03/2009 borat 500   7 13 24/12/2008 borat 600   8 13 01/01/2009 borat 700     I need to select each distinct home holding the maximum value of datetime. Result would be:     id home datetime player resource     1 10 04/03/2009 john 399   2 11 04/03/2009 juliet 244   5 12 04/03/2009 borat 555   8 13 01/01/2009 borat 700     I have tried: -- 1 ..by the MySQL manual:   SELECT DISTINCT   home,   id,   datetime AS dt,   player,   resource FROM topten t1 WHERE datetime = (SELECT   MAX(t2.datetime) FROM topten t2 GROUP BY home) GROUP BY datetime ORDER BY datetime DESC  Doesn't work. Result-set has 130 rows although database holds 187. Result includes some duplicates of home. -- 2 ..join  SELECT   s1.id,   s1.home,   s1.datetime,   s1.player,   s1.resource FROM topten s1 JOIN (SELECT   id,   MAX(datetime) AS dt FROM topten GROUP BY id) AS s2   ON s1.id = s2.id ORDER BY datetime   Nope. Gives all the records. -- 3 ..something exotic:   With various results. How do you turn off developer mode on an s5? I turned developer options 'off', but is there anything else that needs to be done? Not my phone so don't want to mess anything up :-) Show alert popup on standard page layout on click of standard button "Save" How can I find unused functions in a PHP project Why can Naruto still use Rasenshuriken? When Naruto first used Rasenshuriken against Kakuzu the effect was massive. He destroyed   two of Kakuzu's hearts, but there were a huge after effect to him. If I'm not mistaken, Tsunade advised Kakashi to ask Naruto never to use the technique again due to the huge risk. So why is Naruto still able to use the technique and have no side effects after that battle? I may have missed out on something. C99 stdint.h header and MS Visual Studio how to create a histogram in java