SVG Graphics Geometry
Guide
css-matrix
Guide
css-matrix
  • Part 0. SVG 기초

    • SVG란 무엇인가
    • viewBox와 user space
    • transform attribute와 matrix
    • SVG 문서 구조와 기본 도형
  • Part 1. Path grammar

    • path d 명령어 — M, L, Z
    • H, V — 축 정렬 직선
    • C — cubic Bézier
    • Q — quadratic Bézier
    • S, T — smooth continuation
    • A — elliptical arc
    • path bounding box
  • Part 2. Stroke geometry

    • 점에서 stroke까지의 거리
    • join, cap, miter limit
    • stroke align과 outline 개념
    • miter length 공식
  • Part 3. Fill rules

    • nonzero vs evenodd
    • fill hit testing
  • Part 4. Path sampling

    • flatten tolerance
    • path length
    • point at length와 tangent
  • Part 5. Paint servers

    • linearGradient 좌표
    • clipPath와 mask 개념
  • Part 6. Path editor capstone

    • path handle 모델
    • handle hit testing
    • handle drag로 segment 갱신
    • mini path editor — SVG round-trip
  • Part 7. Fill & winding deep dive

    • winding vs ray casting
    • compound path — 여러 subpath
    • self-intersection
    • path boolean
    • fill vs stroke hit 우선순위
    • scanline parity
  • Part 8. Pattern & gradient

    • radialGradient
    • pattern tile
    • gradientUnits와 spreadMethod
  • Part 9. SVG filter & Figma effects

    • Figma DROP_SHADOW → SVG filter
    • filter chain 개요
    • blur · offset · merge
    • inner shadow
    • layer blur vs background blur
    • Figma effect 매핑표 전체
  • Part 10. Figma ↔ SVG bridge

    • vector network vs path d
    • fill · stroke export
    • boolean operations export
    • mask · clip export
  • Part 11. Icon design

    • pixel grid · optical alignment
    • fill vs stroke icons
    • symbol · sprite · currentColor
    • path simplification
  • Appendix A. SVG in CSS

    • currentColor · CSS theming
    • sprite data URI
    • SVG optimization pipeline
  • Appendix B. Engine extras

    • dash offset animation
    • adaptive flatten
    • arc → cubic 변환
    • multi-subpath editing
  • Part 12. Foundations primer

    • capability map
    • coordinate stack
  • Part 13. Figma ↔ SVG (deep)

    • Figma paint gap map
    • radial · angular gradient export
    • image · pattern fill
    • stroke align export
    • blend mode · layer opacity
  • Part 14. SVG spec breadth

    • markers — 화살표와 dash 끝
    • text · textPath
    • paint-order · opacity · filters
    • arc flatten 통합
  • Part 15. Curve calculus

    • de Casteljau subdivision
    • flatness와 chord error
    • 곡률 κ와 법선
    • arc center parameterization
    • G¹ smooth — S와 T
    • shoelace signed area
  • Part 16. Intersection & proximity

    • segment intersection
    • line ∩ cubic · curve ∩ curve
    • closest point on curve
  • Part 17. Offset curves

    • normal offset sampling
    • offset cusps
  • Part 18. Transform algebra

    • affine inverse & decompose
    • transform path vs group
  • Part 19. Rational curves

    • circle as cubic — κ constant
    • rational curves & exact arcs
  • Part 20. Tessellation & pixels

    • convex triangulation · ear clipping
    • evenodd parity → pixels
  • Part 21. Compositing math

    • Gaussian blur kernel
    • Porter–Duff & premultiplied α
  • Part 22. Math topic map

    • SVG 수학 주제 지도
  • Part 23. SVG animation

    • SMIL — animate 속성
    • SMIL — animateTransform
    • SMIL — animateMotion
    • stroke dash draw-on
    • CSS offset-path motion
    • path morph
    • JS motion along path
  • Part 24. Motion precision

    • uniform speed along path
    • cubic–cubic intersection
    • SVGPathElement length API
    • SMIL keyTimes & keySplines
    • degree elevation Q→C
  • Part 25. GPU mesh & WAAPI

    • triangulation with holes
    • WAAPI + SVG attributes
    • evenodd fill + triangle mesh

H, V — 축 정렬 직선

H / V는 한 축만 바꾸는 직선의 문법 설탕입니다. 003 L과 같은 L segment로 그려지며, parsePathD가 파싱 시점에 정규화합니다. 편집기·hit test·bbox는 H/V를 몰라도 됩니다.

데모 path

M 80 80 H 520 V 320 h -120 v -80 Z

mountPathCommandDemo — readout에 segment 리스트와 pathDFromSegments rebuild.

  • H 520 — y=80 유지, x만 520
  • V 320 — x=520 유지, y=320
  • h -120 — 상대, x -= 120
  • v -80 — 상대, y -= 80
  • Z — (80,80)으로 닫기

파서 출력에는 H/V 문자열이 없고 { type: "L", from, to }만 보입니다.

명령 정리

명령절대상대
가로H xh dx
세로V yv dy
L x yH / V
표현두 축 동시한 축만
segmentLL (동일)
용도일반와이어프레임·그리드·손코딩

파서 동작

// index.js — 개념
if (upper === "H") {
  pushLine({ x: relative ? current.x + x : x, y: current.y });
}
if (upper === "V") {
  pushLine({ x: current.x, y: relative ? current.y + y : y });
}

pushLine이 from: current, to: 목표인 L segment를 push하고 current를 갱신합니다.

import { parsePathD, pathDFromSegments } from "svg-matrix-core";

const segments = parsePathD("M 10 20 H 100 V 80");
// [
//   { type: "M", point: { x: 10, y: 20 } },
//   { type: "L", from: { x: 10, y: 20 }, to: { x: 100, y: 20 } },
//   { type: "L", from: { x: 100, y: 20 }, to: { x: 100, y: 80 } }
// ]

pathDFromSegments(segments);
// 보통 "M 10 20 L 100 20 L 100 80" — H/V로 다시보내지 않음

implicit L after M

M 다음 토큰이 좌표만 오면 SVG는 **암시적 L**로 이어집니다. H/V도 같은 규칙 안에서 동작합니다 (003).

왜 정규화하나

레이어H/V
import / d 문자열있을 수 있음
segment graphL만
stroke hitdistancePointToSegment on L (004)
bboxL 끝점 min/max (012)
path editoranchor 이동 → L (024)

H/V 전용 편집 분기를 없애면 C/Q/A와 같은 파이프라인을 재사용합니다.

export · 손코딩

다시 H/V로 줄이는 역변환은 선택 사항입니다 (파일 크기·가독성). core pathDFromSegments는 기본 L 출력.

M 0 0 H 100 V 50   ← 사람이 읽기 쉬움
M 0 0 L 100 0 L 100 50   ← 엔진 내부

Figma·Illustrator export가 H/V를 쓰면 import → parsePathD → 편집 → pathDFromSegments.

테스트 예

parsePathD("M 0 0 H 100 V 50 h -20 v -10");
// M + 4개의 L — 상대 h/v 포함

Core API

  • parsePathD — H/V → L 정규화
  • pathDFromSegments, pathFromD
  • parsePathMoveLine — parsePathD 별칭 (이름만 M/L/Z 용도)

관련

  • 003 M/L/Z · 008 C · 010 S/T (다른 sugar)

오늘의 핵심

H/V는 저장·가독성용 sugar, segment graph는 L로 충분합니다. 파서 한곳에서 정규화하면 hit·bbox·편집기가 곡선 명령과 같은 코드 경로를 탑니다.

최근 수정: 26. 5. 17. PM 4:35
Contributors: jinho.park.s3, Cursor
Prev
path d 명령어 — M, L, Z
Next
C — cubic Bézier