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

SVG란 무엇인가

이 강의 시리즈는 SVG Graphics Geometry입니다. 첫 강의부터 viewBox나 path d를 만지기 전에, SVG가 무엇인지부터 잡고 갑니다. 좌표식이 어렵다고 느껴지는 이유는, 종종 “도형이 어떻게 그려지는지”보다 “숫자가 어디 기준인지”가 먼저 헷갈리기 때문입니다. 그래서 Part 0은 path 문법(Part 1)보다 세계관을 먼저 세웁니다.

SVG 한 줄 정의

SVG(Scalable Vector Graphics) 는 벡터 그래픽을 XML로 표현한 포맷이고, 동시에 브라우저 안에서는 <svg> DOM 요소로 살아 있습니다.

<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <circle cx="50" cy="50" r="40" fill="#2563eb"/>
</svg>

위 코드는 “이미지 파일”이면서 동시에 “문서 구조”입니다. 픽셀 격자에 색을 찍는 방식이 아니라, 원이라는 기하 정보와 파란색이라는 페인트 정보를 적어 둔 것입니다.

비트맵(PNG)과 무엇이 다른가

PNG / JPEGSVG
저장 단위픽셀 색 배열점·선·곡선·채우기 규칙
확대흐려짐(보간)선명(재계산)
편집픽셀 편집기노드·경로·속성
용량해상도에 비례복잡도에 비례

아이콘·로고·UI 일러스트·Figma export에 SVG가 쓰이는 이유는, 크기를 바꿔도 윤곽이 유지되기 때문입니다. 사진은 SVG가 아닙니다. 사진은 비트맵이 맞습니다.

Canvas와도 다르다

Canvas는 비트맵에 가깝습니다. fillRect, lineTo로 그 순간의 픽셀 버퍼에 그립니다. 확대하면 다시 그려야 하고, 객체 단위 선택·편집이 어렵습니다.

SVG는 장면 그래프(scene graph) 입니다. <circle>, <path>가 DOM 노드로 남고, 속성을 바꾸면 브라우저가 다시 래스터화합니다.

Canvas  → 그리기 명령 → 픽셀
SVG     → 요소 트리 + 속성 → (브라우저가) 픽셀

Figma·Illustrator·벡터 편집기를 만들 때는 보통 내부 모델 → SVG export 또는 SVG import 파이프라인이 있습니다. 이 강의의 svg-matrix-core는 그 중간 계층의 수학을 다룹니다.

SVG가 담는 것 (이 강의 지도)

Part 0~14에서 다루는 범위를 미리 보면:

  1. 좌표계 — user space, viewBox, transform (Part 0)
  2. path d — M/L/C/Q/A, segment graph (Part 1)
  3. stroke / fill — 거리, join, winding, hit test (Part 2–3)
  4. paint server — gradient, pattern, clip, mask (Part 5, 8)
  5. filter — blur, shadow (Part 9)
  6. Figma bridge — vector network, paint export (Part 10)
  7. 아이콘·스프라이트 — grid, symbol, simplify (Part 11)

055. SVG 한 장 지도에서 시리즈 전체와 css-matrix·webgl-webgpu-matrix 분담도 정리합니다.

SVG를 어디에 쓰나

  • 인라인 SVG — React/Vue 컴포넌트 안 <svg>, currentColor로 테마 연동
  • 스프라이트 — <symbol> + <use>, 아이콘 폰트 대체
  • 배경 — background-image: url(...svg) (css-matrix와 겹침)
  • 편집기 export — Figma, Illustrator, Inkscape
  • 애니메이션 — Part 23 SMIL·dash·motion (088–094) · Part 24 uniform speed·intersection (095–099) · Part 25 mesh·WAAPI (100–102)

편집기를 만들 때의 위치

사용자가 펜으로 그린 것 → 내부 vector network / segment → export 시 path d 문자열.

Figma vector network  →  svg-matrix-core  →  <path d="M … C … Z"/>

SVG는 “최종 파일 형식”이기도 하지만, API 계약이기도 합니다. parsePathD, pathDFromSegments, viewBoxToViewport 같은 함수는 모두 “브라우저·디자인 툴이 기대하는 SVG 의미”를 코드로 옮긴 것입니다.

이 시리즈에서 다루지 않는 것

  • HTML 레이아웃, flex, grid → css-matrix
  • GPU 셰이더, 삼각형 래스터 → webgl-webgpu-matrix
  • 타이포그래피 전체(글리프 힌팅) → 별도 주제

SVG geometry·paint·filter에 집중합니다.

데모에서 볼 것

같은 단순 도형을 비트맵(캔버스에 그린 픽셀) 과 SVG(원 요소) 로 나란히 두고 확대해 봅니다. SVG 쪽은 확대해도 윤곽이 날카롭게 유지되는 이유를 눈으로 확인합니다.

오늘의 핵심

  • SVG는 벡터 장면을 XML/DOM으로 표현한 것이다.
  • path d는 그중 가장 유연한 도형 표현이지만, Part 0·기본 도형을 거친 뒤가 안전하다.
  • 다음: 001 viewBox에서 “SVG만의 좌표계”로 들어간다.
최근 수정: 26. 5. 17. PM 4:35
Contributors: jinho.park.s3, Cursor
Next
viewBox와 user space