Skip to content

Commit b255c4e

Browse files
committed
chore: Add namespace infrastructure for remaining SVG2 chapters
Create namespace infrastructure (without implementations) for: - Chapter 6: Styling (CSS and presentation) - Chapter 7: Geometry (Positioning and sizing) - Chapter 8: Coordinates (Coordinate systems and transforms) - Chapter 9: Paths (Path elements and data) - Chapter 11: Text (Text content elements) - Chapter 12: Embedded (Embedded content) - Chapter 13: Painting (Fill, stroke, markers) - Chapter 15: Scripting (Interactivity and events) - Chapter 16: Linking (Hyperlinks and views) Each namespace includes: - Complete chapter documentation - W3C spec references - Overview of planned elements - Cross-references to related namespaces Infrastructure allows for systematic implementation of remaining SVG2 specification chapters. Updated README to show implementation status: - ✓ Fully implemented (4 chapters) - Infrastructure ready (8 chapters) Build verified: All 50 tests passing
1 parent 95e6f5f commit b255c4e

10 files changed

+419
-13
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,27 @@ Foundation-free Swift implementation of W3C SVG 2 specification.
1414
This package implements the [W3C SVG 2 specification](https://www.w3.org/TR/SVG2/) with namespaced types that directly map to SVG 2 chapters:
1515

1616
### Foundational
17-
- **Types** (Chapter 4): Basic data types - Length, Color, Transform, ViewBox
18-
- **Document** (Chapter 5): Document structure elements (coming soon)
19-
- **Styling** (Chapter 6): CSS and presentation (coming soon)
17+
- **Types** (Chapter 4): Basic data types - Length, Color, Transform, ViewBox
18+
- **Document** (Chapter 5): SVG, Group, Defs, Symbol, Use ✓
19+
- **Styling** (Chapter 6): CSS and presentation (infrastructure ready)
2020

2121
### Geometry & Coordinates
22-
- **Geometry** (Chapter 7): Positioning and sizing properties (coming soon)
23-
- **Coordinates** (Chapter 8): Coordinate systems and transforms (coming soon)
22+
- **Geometry** (Chapter 7): Positioning and sizing properties (infrastructure ready)
23+
- **Coordinates** (Chapter 8): Coordinate systems and transforms (infrastructure ready)
2424

2525
### Graphics Elements
26-
- **Paths** (Chapter 9): Path elements and data (coming soon)
27-
- **Shapes** (Chapter 10): Circle, Rectangle, Ellipse, Line
28-
- **Text** (Chapter 11): Text content elements (coming soon)
29-
- **Embedded** (Chapter 12): Embedded content (coming soon)
26+
- **Paths** (Chapter 9): Path elements and data (infrastructure ready)
27+
- **Shapes** (Chapter 10): Circle, Rectangle, Ellipse, Line, Polyline, Polygon ✓
28+
- **Text** (Chapter 11): Text content elements (infrastructure ready)
29+
- **Embedded** (Chapter 12): Embedded content (infrastructure ready)
3030

3131
### Rendering
32-
- **Painting** (Chapter 13): Fill, stroke, markers (coming soon)
33-
- **PaintServers** (Chapter 14): Gradients and patterns (coming soon)
32+
- **Painting** (Chapter 13): Fill, stroke, markers (infrastructure ready)
33+
- **PaintServers** (Chapter 14): LinearGradient, RadialGradient, Stop, Pattern ✓
3434

3535
### Interactivity
36-
- **Scripting** (Chapter 15): Interactivity and events (coming soon)
37-
- **Linking** (Chapter 16): Hyperlinks and views (coming soon)
36+
- **Scripting** (Chapter 15): Interactivity and events (infrastructure ready)
37+
- **Linking** (Chapter 16): Hyperlinks and views (infrastructure ready)
3838

3939
## Installation
4040

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// W3C_SVG2.Coordinates.swift
3+
// swift-w3c-svg
4+
//
5+
// Chapter 8: Coordinate Systems, Transformations and Units
6+
//
7+
8+
extension W3C_SVG2 {
9+
/// Chapter 8: Coordinate Systems, Transformations and Units
10+
///
11+
/// W3C SVG 2 Chapter 8
12+
/// https://www.w3.org/TR/SVG2/coords.html
13+
///
14+
/// The Coordinates namespace contains additional coordinate system utilities
15+
/// and transformation helpers beyond the basic Transform type.
16+
///
17+
/// ## Overview
18+
///
19+
/// This namespace provides:
20+
/// - Advanced transformation matrices
21+
/// - Coordinate space conversions
22+
/// - Unit conversion utilities
23+
/// - Bounding box computations
24+
///
25+
/// ## Topics (To Be Implemented)
26+
///
27+
/// - CTM (Current Transformation Matrix) calculations
28+
/// - Screen CTM computations
29+
/// - Point and matrix transformations
30+
/// - Unit-aware measurements
31+
///
32+
/// ## See Also
33+
///
34+
/// - ``Types.Transform``: Basic transform type (Chapter 4)
35+
/// - ``Geometry``: Geometry properties (Chapter 7)
36+
public enum Coordinates {}
37+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//
2+
// W3C_SVG2.Embedded.swift
3+
// swift-w3c-svg
4+
//
5+
// Chapter 12: Embedded Content
6+
//
7+
8+
extension W3C_SVG2 {
9+
/// Chapter 12: Embedded Content
10+
///
11+
/// W3C SVG 2 Chapter 12
12+
/// https://www.w3.org/TR/SVG2/embedded.html
13+
///
14+
/// The Embedded namespace contains elements for embedding external content
15+
/// within SVG documents, including raster images and foreign objects.
16+
///
17+
/// ## Overview
18+
///
19+
/// SVG supports embedding:
20+
/// - Raster images (PNG, JPEG, etc.) via image element
21+
/// - Arbitrary XML/HTML content via foreignObject
22+
/// - Other SVG documents via image or nested svg
23+
///
24+
/// ## Elements (To Be Implemented)
25+
///
26+
/// - Image element for raster images
27+
/// - ForeignObject element for HTML/XML content
28+
///
29+
/// ## Image Element
30+
///
31+
/// The image element embeds raster images:
32+
/// - Supports common formats (PNG, JPEG, SVG)
33+
/// - Position and size via x, y, width, height
34+
/// - preserveAspectRatio for scaling control
35+
///
36+
/// ## ForeignObject Element
37+
///
38+
/// The foreignObject element embeds non-SVG content:
39+
/// - HTML elements and CSS styling
40+
/// - MathML for mathematical notation
41+
/// - Custom XML namespaces
42+
///
43+
/// ## See Also
44+
///
45+
/// - ``Document``: Document structure (Chapter 5)
46+
/// - ``Shapes``: Basic shapes (Chapter 10)
47+
public enum Embedded {}
48+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// W3C_SVG2.Geometry.swift
3+
// swift-w3c-svg
4+
//
5+
// Chapter 7: Coordinate Systems, Transformations and Units
6+
//
7+
8+
extension W3C_SVG2 {
9+
/// Chapter 7: Coordinate Systems, Transformations and Units
10+
///
11+
/// W3C SVG 2 Chapter 7
12+
/// https://www.w3.org/TR/SVG2/coords.html
13+
///
14+
/// The Geometry namespace contains types and properties related to coordinate
15+
/// systems, transformations, and unit specifications in SVG.
16+
///
17+
/// ## Overview
18+
///
19+
/// SVG uses coordinate systems for positioning and sizing:
20+
/// - User coordinate system
21+
/// - Viewport coordinate system
22+
/// - Object bounding box units
23+
/// - Nested coordinate systems via viewBox
24+
///
25+
/// ## Topics (To Be Implemented)
26+
///
27+
/// - Coordinate system transformations
28+
/// - Units (px, em, ex, pt, pc, cm, mm, in, %)
29+
/// - Bounding box calculations
30+
/// - Nested viewport establishment
31+
///
32+
/// ## See Also
33+
///
34+
/// - ``Types``: Basic data types (Chapter 4)
35+
/// - ``Document``: Document structure (Chapter 5)
36+
public enum Geometry {}
37+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//
2+
// W3C_SVG2.Linking.swift
3+
// swift-w3c-svg
4+
//
5+
// Chapter 16: Linking
6+
//
7+
8+
extension W3C_SVG2 {
9+
/// Chapter 16: Linking
10+
///
11+
/// W3C SVG 2 Chapter 16
12+
/// https://www.w3.org/TR/SVG2/linking.html
13+
///
14+
/// The Linking namespace contains elements for creating hyperlinks and
15+
/// references within and between SVG documents.
16+
///
17+
/// ## Overview
18+
///
19+
/// SVG linking supports:
20+
/// - Hyperlinks to external resources via anchor (a) element
21+
/// - Fragment identifiers for internal navigation
22+
/// - View specifications for zooming and panning
23+
/// - IRI references for resource linking
24+
///
25+
/// ## Elements (To Be Implemented)
26+
///
27+
/// - Anchor (a) element for hyperlinks
28+
/// - View element for view specifications
29+
///
30+
/// ## Link Properties (To Be Implemented)
31+
///
32+
/// - href: Target URL or IRI
33+
/// - target: Browsing context
34+
/// - download: Download hint
35+
///
36+
/// ## View Specifications (To Be Implemented)
37+
///
38+
/// - viewBox for view definition
39+
/// - preserveAspectRatio for scaling
40+
/// - zoomAndPan for user interaction
41+
///
42+
/// ## IRI References
43+
///
44+
/// SVG uses IRIs (Internationalized Resource Identifiers) for:
45+
/// - Paint servers (url(#gradient))
46+
/// - Clip paths and masks
47+
/// - Filters and effects
48+
/// - Text paths and use elements
49+
///
50+
/// ## See Also
51+
///
52+
/// - ``Document``: Document structure (Chapter 5)
53+
/// - ``Scripting``: Interactivity (Chapter 15)
54+
public enum Linking {}
55+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// W3C_SVG2.Painting.swift
3+
// swift-w3c-svg
4+
//
5+
// Chapter 13: Painting — Filling, Stroking and Marker Symbols
6+
//
7+
8+
extension W3C_SVG2 {
9+
/// Chapter 13: Painting — Filling, Stroking and Marker Symbols
10+
///
11+
/// W3C SVG 2 Chapter 13
12+
/// https://www.w3.org/TR/SVG2/painting.html
13+
///
14+
/// The Painting namespace contains elements and types related to how SVG
15+
/// graphics are painted, including fill and stroke properties, and markers
16+
/// for path vertices.
17+
///
18+
/// ## Overview
19+
///
20+
/// SVG painting encompasses:
21+
/// - Fill properties (color, opacity, fill-rule)
22+
/// - Stroke properties (color, width, linecap, linejoin, dasharray)
23+
/// - Marker symbols for path vertices
24+
/// - Paint order control
25+
///
26+
/// ## Fill Properties (To Be Implemented)
27+
///
28+
/// - fill: Paint server or color
29+
/// - fill-opacity: Opacity of fill
30+
/// - fill-rule: evenodd or nonzero winding
31+
///
32+
/// ## Stroke Properties (To Be Implemented)
33+
///
34+
/// - stroke: Paint server or color
35+
/// - stroke-width: Width of stroke
36+
/// - stroke-linecap: butt, round, or square
37+
/// - stroke-linejoin: miter, round, or bevel
38+
/// - stroke-dasharray: Dash pattern
39+
/// - stroke-dashoffset: Dash pattern offset
40+
/// - stroke-opacity: Opacity of stroke
41+
///
42+
/// ## Markers (To Be Implemented)
43+
///
44+
/// - Marker element for vertex symbols
45+
/// - marker-start, marker-mid, marker-end properties
46+
/// - Auto-orientation and scaling
47+
///
48+
/// ## See Also
49+
///
50+
/// - ``PaintServers``: Gradients and patterns (Chapter 14)
51+
/// - ``Types.Color``: Color values (Chapter 4)
52+
public enum Painting {}
53+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// W3C_SVG2.Paths.swift
3+
// swift-w3c-svg
4+
//
5+
// Chapter 9: Paths
6+
//
7+
8+
extension W3C_SVG2 {
9+
/// Chapter 9: Paths
10+
///
11+
/// W3C SVG 2 Chapter 9
12+
/// https://www.w3.org/TR/SVG2/paths.html
13+
///
14+
/// The Paths namespace contains the path element and path data specification
15+
/// for creating complex vector graphics with lines, curves, and arcs.
16+
///
17+
/// ## Overview
18+
///
19+
/// Paths are the most powerful drawing primitive in SVG, enabling:
20+
/// - Arbitrary line segments (moveto, lineto)
21+
/// - Cubic and quadratic Bézier curves
22+
/// - Elliptical arc curves
23+
/// - Closed subpaths
24+
///
25+
/// ## Elements (To Be Implemented)
26+
///
27+
/// - Path element
28+
/// - Path data command types (M, L, H, V, C, S, Q, T, A, Z)
29+
/// - Path data parsing and generation
30+
///
31+
/// ## Path Commands
32+
///
33+
/// - M/m: moveto
34+
/// - L/l: lineto
35+
/// - H/h: horizontal lineto
36+
/// - V/v: vertical lineto
37+
/// - C/c: cubic Bézier curve
38+
/// - S/s: smooth cubic Bézier curve
39+
/// - Q/q: quadratic Bézier curve
40+
/// - T/t: smooth quadratic Bézier curve
41+
/// - A/a: elliptical arc
42+
/// - Z/z: closepath
43+
///
44+
/// ## See Also
45+
///
46+
/// - ``Shapes``: Basic shapes (Chapter 10)
47+
/// - ``Types``: Basic data types (Chapter 4)
48+
public enum Paths {}
49+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// W3C_SVG2.Scripting.swift
3+
// swift-w3c-svg
4+
//
5+
// Chapter 15: Scripting and Interactivity
6+
//
7+
8+
extension W3C_SVG2 {
9+
/// Chapter 15: Scripting and Interactivity
10+
///
11+
/// W3C SVG 2 Chapter 15
12+
/// https://www.w3.org/TR/SVG2/interact.html
13+
///
14+
/// The Scripting namespace contains elements and interfaces related to
15+
/// interactivity, event handling, and scripting in SVG documents.
16+
///
17+
/// ## Overview
18+
///
19+
/// SVG interactivity includes:
20+
/// - Event attributes (onclick, onmouseover, etc.)
21+
/// - Script element for embedded scripts
22+
/// - DOM interfaces for programmatic access
23+
/// - Cursor and pointer-events control
24+
///
25+
/// ## Elements (To Be Implemented)
26+
///
27+
/// - Script element for JavaScript/ECMAScript
28+
///
29+
/// ## Event Handling (To Be Implemented)
30+
///
31+
/// - Mouse events (click, mousedown, mouseup, mousemove, etc.)
32+
/// - Focus events (focusin, focusout)
33+
/// - Keyboard events (keydown, keyup, keypress)
34+
/// - Document events (load, unload, abort, error, resize, scroll)
35+
///
36+
/// ## Pointer Events (To Be Implemented)
37+
///
38+
/// - pointer-events property
39+
/// - Touch and pen input handling
40+
///
41+
/// ## See Also
42+
///
43+
/// - ``Document``: Document structure (Chapter 5)
44+
/// - ``Linking``: Hyperlinks (Chapter 16)
45+
public enum Scripting {}
46+
}

0 commit comments

Comments
 (0)