Metadata-Version: 2.4
Name: cadlib
Version: 0.1.0
Summary: CAD primitives to produce images and drawings in a variety of formats from a common symbolic definition.
Project-URL: Homepage, https://github.com/almargolis/cadlib
Project-URL: Repository, https://github.com/almargolis/cadlib
Project-URL: Issues, https://github.com/almargolis/cadlib/issues
Author: Al Margolis
License-Expression: MIT
License-File: LICENSE
Keywords: cad,drafting,geometry,sprocket,svg
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Manufacturing
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Requires-Dist: matplotlib>=3.5
Requires-Dist: numpy>=1.21
Requires-Dist: svgwrite>=1.4
Provides-Extra: dev
Requires-Dist: flake8>=6.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# cadlib

CAD primitives to produce images and drawings in a variety of formats from a common symbolic definition.

cadlib is a 2D CAD geometry library written in Python. It models manual drafting
workflows: constructing geometry by creating points, lines, circles, and arcs,
then using transformations (mirror, rotate) to build complex shapes.

## Installation

```bash
pip install cadlib
```

## Quick Start

```python
import cadlib

# Create geometry
center = cadlib.Point(0, 0)
circle = cadlib.Circle(center, 10)
line = cadlib.Line(cadlib.Point(-15, 5), cadlib.Point(15, 5))

# Find intersections
pt = circle.point_at_line_intersection(line, q=1)

# Use transformations
mirrored = line.mirror_x(0)
rotated = line.rotate(center, 45)
```

## Sprocket Generation

cadlib includes a sprocket generator implementing ANSI standard sprocket
geometry per the [gearseds design specification](http://gearseds.com/files/design_draw_sprocket_5.pdf).

```bash
# Generate SVG
cadlib-sprocket svg

# Display with matplotlib
cadlib-sprocket matplotlib
```

Or use it programmatically:

```python
from cadlib.sprocket import Sprocket, create_svg, create_matplotlib

sprocket = Sprocket(ansi_chain_type="25", n_number_of_teeth=8)
create_svg(sprocket)
```

## Core API

### Primitives
- `Point(x, y)` -- 2D point with mirror and rotate transformations
- `Line(p1, p2)` -- line segment between two points
- `Circle(center, radius)` -- circle with intersection and tangency methods
- `Arc(center, radius, angle1, angle2)` -- arc defined by center, radius, and angle range

### Factory Functions
- `arc_from_points_and_radius(p1, p2, r, q)` -- arc from two points and radius
- `arc_from_points_and_center(p1, p2, center)` -- arc from two points and center
- `arc_from_points_and_radius_and_height(p1, p2, height)` -- arc from chord and height
- `line_from_pt_angle_len(point, angle, length)` -- line from point, angle, length

### Layers and Drawing
- `Layer` -- groups elements for rendering control
- `Drawing` -- collection of elements with coordinate transforms for output
- `LAYER_CONSTRUCTION` -- default layer for construction guides (gray)
- `LAYER_TOOLPATH` -- layer for cutting/tool paths (red)

## License

MIT
