title: Android - How to center Path on Canvas to screen with a given X and Y coordinate as the center
body: <p>I have the following code to draw a path to a Canvas:</p>
  
  <pre><code>if (mPointArray.size() &gt; 1) {
      mPath.moveTo(mPointArray.get(0).x * scaleX, mPointArray.get(0).y * scaleY);
      for (int x = 1; x &lt; mPointArray.size(); x++) {
          mPath.lineTo(mPointArray.get(x).x * scaleX, mPointArray.get(x).y * scaleY);
      }
      canvas.drawPath(mPath, mPaint);    
      canvas.drawPoint(mPointArray.get(mPointArray.size() - 1).x * scaleX, mPointArray.get(mPointArray.size() - 1).y * scaleY, pointPaint);
  }
  </code></pre>
  
  <p>Say I were to have an arbitrary X and Y coordinate as a designated center, how would I apply that X and Y coordinate to the center of the screen?  The reason why I am asking is because I am developing an app where you stand on a sensor where you stand on a specific location, and I would like my path to be centered around that initial point before drawing the path.  I have two float values, <code>centerX</code> and <code>centerY</code> that I would somehow like to apply to my path. Unfortunately, if I apply them before multiplying by <code>scaleX</code> and <code>scaleY</code>, the translation is too large, while if I do it afterwards, the translation is too small.</p>
  
  <p>Here is the declaration for <code>scaleX</code>:</p>
  
  <p><code>scaleX = ((screenW / sensorWidth) * 1.1f) - ((screenW / sensorWidth) * 0.1f);</code></p>
  
  <p><code>scaleY</code> is definied similarly in terms of <code>screenH</code> and <code>sensorLength</code>.</p>
  
  <p>How would I apply the new center coordinates of the sensor, with the new center being centered on the screen?</p>