Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.48 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Center point on html quadratic curve
  2. x(t) = (1-t)^2 * x1 + 2 * (1-t) * t * x2 + t^2 * x3
  3. y(t) = (1-t)^2 * y1 + 2 * (1-t) * t * y2 + t^2 * y3
  4.        
  5. function _getQBezierValue(t, p1, p2, p3) {
  6.     var iT = 1 - t;
  7.     return iT * iT * p1 + 2 * iT * t * p2 + t * t * p3;
  8. }
  9.  
  10. function getQuadraticCurvePoint(startX, startY, cpX, cpY, endX, endY, position) {
  11.     return {
  12.         x:  _getQBezierValue(position, startX, cpX, endX),
  13.         y:  _getQBezierValue(position, startY, cpY, endY)
  14.     };
  15. }