CSS Graphics Geometry
Guide
Reference
GitHub
Guide
Reference
GitHub
  • Part 0. Math foundations

    • 좌표계와 CSS pixel
    • 점, 벡터, 거리와 기본 용어
    • 각도, 라디안, atan2
  • Part 1. Transform linear algebra

    • translate, scale, rotate
    • CSS matrix(a,b,c,d,e,f)
    • 변환 순서와 transform-origin
    • local, world, screen 좌표계
    • inverse matrix와 포인터 입력
    • 좌표와 transform 디버깅
  • Part 2. Infinite canvas math and architecture

    • viewport와 camera 모델
    • cursor anchored zoom
    • ruler와 tick 계산
    • 주기 함수와 grid step
    • content, overlay, controls layer
    • scene graph와 nested transform
  • Part 3. Editor tool math

    • Pointer Events와 드래그
    • DOMRect와 getBoundingClientRect
    • hit testing과 bounding box
    • selection rectangle과 marquee
    • selection bounds와 handles
    • resize와 rotation handle
    • snapping과 smart guides
    • group, frame, clipping
  • Part 4. CSS graphics properties as math

    • CSS box로 도형 만들기
    • clip-path, radius, shadow
    • 선형보간과 linear-gradient
    • 거리 함수와 radial/conic-gradient
    • stacking context와 합성
    • layout, paint, composite
  • Part 5. Editor state and persistence

    • 레이어 모델과 z-index
    • 이동, 복제, 삭제, 잠금
    • undo/redo command model
    • JSON export/import
  • Part 6. SVG overlay and vector editing

    • SVG viewBox와 좌표계
    • getScreenCTM과 inverse
    • SVG pointer-events와 stroke hit testing
    • cubic bezier path editing
    • mask, clipPath, marker
  • Part 7. Figma to CSS translation

    • Figma node와 CSS DOM 모델
    • Frame constraints와 Auto Layout
    • Fills, strokes, effects를 CSS로
    • Vector와 text 변환
    • gradient 밖의 CSS 수학
    • Figma gradient를 CSS gradient로 변환하기
    • 수학이 필요한 Figma to CSS 속성들
    • Figma VectorNetwork 정리
  • Appendix A. Canvas renderer transition

    • Canvas로 넘어가는 기준
  • Appendix B. Motion and timing

    • 모션 수학과 timing 함수
    • Keyframe timeline 엔진
    • Motion path 수학
    • Bezier curve 길이 구하기

cubic bezier path editing

이번에는 cubic bezier입니다.

벡터 편집기에서 곡선을 다루려면 언젠가 이 친구를 만나게 됩니다. cubic bezier는 시작점, 끝점, 그리고 두 control point로 곡선을 만듭니다.

처음엔 control point가 곡선 위에 있지 않아서 조금 얄밉게 느껴질 수 있습니다. 하지만 이 점들이 tangent 방향과 곡률을 조절합니다.

네 점으로 곡선을 만든다

B(t) = (1-t)^3 P0 + 3(1-t)^2 t P1 + 3(1-t)t^2 P2 + t^3 P3
tangent at start = P1 - P0
tangent at end = P3 - P2
cubic bezier control point tangent diagramB(t) = cubic(P0, P1, P2, P3), start tangent = P1 - P0, end tangent = P3 - P2
cubic bezier의 control point는 곡선 위 점이 아니라 tangent를 조절하는 손잡이입니다. 핸들을 움직이면 시작/끝 방향이 바뀝니다.

P0는 시작점, P3는 끝점입니다. P1, P2는 control point입니다. path editor에서 보이는 handle이 바로 이 control point를 조작합니다.

시작 tangent는 P1 - P0, 끝 tangent는 P3 - P2입니다. 그래서 handle 방향을 바꾸면 곡선이 시작하거나 끝나는 방향이 바뀝니다.

SVG path로 표현하기

SVG에서는 C 명령으로 cubic bezier를 씁니다.

M P0.x P0.y C P1.x P1.y, P2.x P2.y, P3.x P3.y

control handle을 움직이면 path d 문자열의 C 명령을 갱신합니다.

de Casteljau 알고리즘은 곡선 위의 점을 시각적으로 설명하기 좋고, 곡선을 split할 때도 쓸 수 있습니다. smooth point는 양쪽 tangent를 같은 직선 위에 두는 제약입니다.

데모에서 볼 것

데모에서는 control point를 움직이며 tangent 방향과 곡선 시작/끝 방향이 어떻게 연결되는지 확인합니다.

오늘의 핵심은 bezier handle이 장식이 아니라 tangent를 조절하는 수학적 도구라는 점입니다. 곡선은 감성적으로 보이지만, 안쪽은 꽤 정확합니다.

Edit this page
최근 수정: 26. 5. 14. PM 5:45
Contributors: easylogic
Prev
SVG pointer-events와 stroke hit testing
Next
mask, clipPath, marker