본문 바로가기
HTML5/SVG

SVG pathsegType

by Jundol 2015. 6. 15.



SVG DOM 의 pathsegType 을 이용하면 각 path 의 attribute 에 따라 실행을 정의할 수 있다.

SVG Editor 에서 path point 정의를 내릴 때 pathsegType 을 이용해서 각 포인트 타입 별로 실행은 제어한다.

M , L , Z 등등 타입을 숫자로 분류해서 구분한다.

Interface SVGPathSeg

single segment 는 하나의 path data 의 설명에 부합한다.

IDL Definition


interface SVGPathSeg {
  // Path Segment Types
  const unsigned short kSVG_PATHSEG_UNKNOWN                      = 0;  // ?
  const unsigned short kSVG_PATHSEG_CLOSEPATH                    = 1;  // z
  const unsigned short kSVG_PATHSEG_MOVETO_ABS                   = 2;  // M
  const unsigned short kSVG_PATHSEG_MOVETO_REL                   = 3;  // m
  const unsigned short kSVG_PATHSEG_LINETO_ABS                   = 4;  // L
  const unsigned short kSVG_PATHSEG_LINETO_REL                   = 5;  // l
  const unsigned short kSVG_PATHSEG_CURVETO_CUBIC_ABS            = 6;  // C
  const unsigned short kSVG_PATHSEG_CURVETO_CUBIC_REL            = 7;  // c
  const unsigned short kSVG_PATHSEG_CURVETO_QUADRATIC_ABS        = 8;  // Q
  const unsigned short kSVG_PATHSEG_CURVETO_QUADRATIC_REL        = 9;  // q
  const unsigned short kSVG_PATHSEG_ARC_SWEEP_ABS                = 10; // A
  const unsigned short kSVG_PATHSEG_ARC_SWEEP_REL                = 11; // a
  const unsigned short kSVG_PATHSEG_ARC_VECTOR_ABS               = 12; // B
  const unsigned short kSVG_PATHSEG_ARC_VECTOR_REL               = 13; // b
  const unsigned short kSVG_PATHSEG_LINETO_HORIZONTAL_ABS        = 14; // H
  const unsigned short kSVG_PATHSEG_LINETO_HORIZONTAL_REL        = 15; // h
  const unsigned short kSVG_PATHSEG_LINETO_VERTICAL_ABS          = 16; // V
  const unsigned short kSVG_PATHSEG_LINETO_VERTICAL_REL          = 17; // v
  const unsigned short kSVG_PATHSEG_CURVETO_CUBIC_SMOOTH_ABS     = 18; // S
  const unsigned short kSVG_PATHSEG_CURVETO_CUBIC_SMOOTH_REL     = 19; // s
  const unsigned short kSVG_PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 20; // T
  const unsigned short kSVG_PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 21; // t

  readonly attribute  unsigned short pathsegType;
  readonly attribute  DOMString      pathsegTypeAsLetter;

  // Attribute values for a path segment.
  // Each pathseg has slots for any possible path seg type.
  // (We don't want to define 20 different subclasses to PathSeg -
      our document is long enough already.)
  attribute  double       x;   // end point for pathseg (or center for A/a/B/b)
  attribute  double       y;   // end point for pathseg (or center for A/a/B/b)
  attribute  double       x0,y0;    // for control points (start point for B/b)
  attribute  double       x1,y1;    // for control points (end point for B/b)
  attribute  double       r1,r2;    // radii for A/a/B/b
  attribute  double       a1,a2,a3; // angles for A/a

  readonly attribute  Path parentPath;
  readonly attribute  SVGDocument ownerSVGDocument;
  readonly attribute  SVGPathSeg previousSibling;
  readonly attribute  SVGPathSeg nextSibling;
};


pathsegType 이 cpp의 const(상수)로 지정되어있다.

이것은 SVG의 attribute 의 키는 pathsegType 이고 값은 각 pathType(M , L , Z ...) 에 따른 상수값으로 지정되어있다.

path 포인트 설정 혹은 path 포인트 수정시에 사용하면 될 것으로 생각된다.


참조 : w3.org

http://www.w3.org/1999/07/30/WD-SVG-19990730/svgdom.html


'HTML5 > SVG' 카테고리의 다른 글

[SVG] document.createElementNS  (0) 2015.10.05
SVG Editor 분석-3 Path 포인트 정의하기  (0) 2015.06.15
SVG Editor 분석-2 객체 추가  (0) 2015.06.12
SVG Editor 분석-1 [DOM 구조파악]  (0) 2015.06.10
SVG Radial  (0) 2015.06.09

댓글