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 길이 구하기

undo/redo command model

이번에는 undo/redo입니다.

에디터에서 Cmd+Z가 이상하면 사용자는 바로 불안해집니다. 방금 한 작업을 믿고 되돌릴 수 있어야 과감하게 편집할 수 있습니다.

undo/redo는 과거 화면으로 돌아가는 버튼이 아니라, 편집 명령의 시간 순서를 관리하는 모델입니다.

command stack

undoStack.push(command)
undo: command.undo(model)
redo: command.do(model)
drag command = startState -> finalState
undo redo preview and commit diagrampointermove previewpointerup commitMoveCommandundoStack[0]undoStack[1]many pointer events -> one user-level command
드래그 중 pointermove는 preview 상태이고, pointerup에서 사용자 의도 하나를 command로 commit합니다. 그래서 undo도 한 번이면 충분합니다.

명령은 do와 undo를 가질 수 있습니다. 또는 before/after 상태를 저장할 수도 있습니다. 어떤 방식이든 중요한 건 사용자가 기대하는 단위로 history가 쌓이는 것입니다.

드래그는 하나의 명령이다

드래그 중에는 pointermove가 수십 번 발생합니다. 이걸 전부 undo stack에 넣으면 Cmd+Z를 수십 번 눌러야 원래 위치로 돌아갑니다. 사용자가 손목 운동하러 온 건 아닙니다.

그래서 preview state와 committed command를 분리합니다.

dragging: preview only
pointerup: commit one command

연속 방향키 이동은 시간 창 안에서 merge할 수 있습니다. 반대로 import/export처럼 큰 변경은 snapshot command가 더 단순할 수 있습니다.

데모에서 볼 것

데모에서는 드래그 중간 위치가 아니라 최종 위치 하나만 undo stack에 남도록 동작을 설계합니다.

오늘의 핵심은 history가 개발자 이벤트 단위가 아니라 사용자 의도 단위로 쌓여야 한다는 점입니다. 좋은 undo는 조용하지만, 없으면 바로 티가 납니다.

Edit this page
최근 수정: 26. 5. 14. PM 5:45
Contributors: easylogic
Prev
이동, 복제, 삭제, 잠금
Next
JSON export/import