Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Public Attributes | Private Attributes
nsSVGPathData Class Reference

#include <nsISVGPathFlatten.h>

List of all members.

Public Member Functions

 nsSVGPathData ()
 ~nsSVGPathData ()
void AddPoint (float aX, float aY, PRUint8 aType)
float Length ()

Public Attributes

PRUint32 count
float * x
float * y
PRUint8type

Private Attributes

PRUint32 arraysize

Detailed Description

Definition at line 53 of file nsISVGPathFlatten.h.


Constructor & Destructor Documentation

Definition at line 64 of file nsISVGPathFlatten.h.

: arraysize(0), count(0), x(nsnull), y(nsnull), type(nsnull) {}

Definition at line 65 of file nsISVGPathFlatten.h.

                   {
    if (x) free(x);
    if (y) free(y);
    if (type) free(type);
  }

Member Function Documentation

void nsSVGPathData::AddPoint ( float  aX,
float  aY,
PRUint8  aType 
) [inline]

Definition at line 71 of file nsISVGPathFlatten.h.

                                                   {
    if (count + 1 > arraysize) {
      if (!arraysize)
        arraysize = 16;
      x = (float *) realloc(x, 2*arraysize*sizeof(float));
      y = (float *) realloc(y, 2*arraysize*sizeof(float));
      type = (PRUint8 *) realloc(type, 2*arraysize*sizeof(PRUint8));
      arraysize *= 2;
    }
    x[count] = aX;
    y[count] = aY;
    type[count] = aType;
    count++;
  }

Here is the call graph for this function:

float nsSVGPathData::Length ( ) [inline]

Definition at line 86 of file nsISVGPathFlatten.h.

                 {
    float length = 0;
    if (count > 0) {
      // Must initialize xx and yy before they're used in the loop below
      float xx = x[0];
      float yy = y[0];
      // Loop from i=1 because dx and dy would always be zero for i==0 since xx
      // and yy would then *be* x[0] and y[0]. Also the first segment *must*
      // be a moveto (M) command, which also results in a dx and dy of zero.
      for (PRUint32 i = 1; i < count; i++) {
        if (type[i] == NS_SVGPATHFLATTEN_LINE) {
          float dx = x[i] - xx;
          float dy = y[i] - yy;
          length += sqrt(dx*dx + dy*dy);
        }
        xx = x[i];
        yy = y[i];
      }
    }
    return length;
  }

Here is the caller graph for this function:


Member Data Documentation

Definition at line 56 of file nsISVGPathFlatten.h.

Definition at line 59 of file nsISVGPathFlatten.h.

Definition at line 62 of file nsISVGPathFlatten.h.

Definition at line 60 of file nsISVGPathFlatten.h.

Definition at line 61 of file nsISVGPathFlatten.h.


The documentation for this class was generated from the following file: