Back to index

lightning-sunbird  0.9+nobinonly
Classes | Typedefs | Functions
nsSVGPathElement.cpp File Reference
#include "nsSVGGraphicElement.h"
#include "nsSVGAtoms.h"
#include "nsSVGPathSegList.h"
#include "nsIDOMSVGPathElement.h"
#include "nsIDOMSVGAnimatedPathData.h"
#include "nsIDOMSVGPathSeg.h"
#include "nsSVGPathSeg.h"
#include "nsCOMPtr.h"
#include "nsISVGPathFlatten.h"
#include "nsIDocument.h"
#include "nsIFrame.h"
#include "nsISVGGlyphMetricsSource.h"
#include "nsSVGPoint.h"

Go to the source code of this file.

Classes

class  nsSVGPathElement

Typedefs

typedef nsSVGGraphicElement nsSVGPathElementBase

Functions

void NS_SVGFindPointOnPath (nsSVGPathData *data, float aX, float aY, float aAdvance, nsSVGCharacterPosition *aCP)

Typedef Documentation

Definition at line 53 of file nsSVGPathElement.cpp.


Function Documentation

void NS_SVGFindPointOnPath ( nsSVGPathData data,
float  aX,
float  aY,
float  aAdvance,
nsSVGCharacterPosition aCP 
)

Definition at line 875 of file nsSVGGlyphFrame.cpp.

{
  float x, y, length = 0;
  float midpoint = aX + aAdvance/2;
  for (PRUint32 i = 0; i < data->count; i++) {
    if (data->type[i] == NS_SVGPATHFLATTEN_LINE) {
      float dx = data->x[i] - x;
      float dy = data->y[i] - y;
      float sublength = sqrt(dx*dx + dy*dy);
      
      if (sublength != 0 && length + sublength >= midpoint) {
        float ratio = (aX - length)/sublength;
        aCP->x = x * (1.0f - ratio) + data->x[i] * ratio;
        aCP->y = y * (1.0f - ratio) + data->y[i] * ratio;

        float dx = data->x[i] - x;
        float dy = data->y[i] - y;
        aCP->angle = atan2(dy, dx);

        float normalization = 1.0/sqrt(dx*dx+dy*dy);
        aCP->x += - aY * dy * normalization;
        aCP->y +=   aY * dx * normalization;
        return;
      }
      length += sublength;
    }
    x = data->x[i];
    y = data->y[i];
  }
}

Here is the call graph for this function: