Skip to content

Commit c30ba68

Browse files
cfisclaude
andcommitted
Add MkDocs documentation site
- Add mkdocs.yml with Material theme and purple color scheme - Create docs/ pages: index, installation, usage, examples, about-rice - Add GitHub Actions workflow for automatic deployment to GitHub Pages - Integrate auto-generated API docs for Bmp, Rice, and Std namespaces - Streamline README to link to full documentation site 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 21e282b commit c30ba68

33 files changed

+1046
-231
lines changed

.github/workflows/docs.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Deploy Docs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'docs/**'
8+
- 'mkdocs.yml'
9+
- '.github/workflows/docs.yml'
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
concurrency:
18+
group: pages
19+
cancel-in-progress: false
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Set up Python
28+
uses: actions/setup-python@v5
29+
with:
30+
python-version: '3.12'
31+
32+
- name: Install MkDocs and dependencies
33+
run: pip install mkdocs-material
34+
35+
- name: Build docs
36+
run: mkdocs build
37+
38+
- name: Upload artifact
39+
uses: actions/upload-pages-artifact@v3
40+
with:
41+
path: site
42+
43+
deploy:
44+
needs: build
45+
runs-on: ubuntu-latest
46+
environment:
47+
name: github-pages
48+
url: ${{ steps.deployment.outputs.page_url }}
49+
steps:
50+
- name: Deploy to GitHub Pages
51+
id: deployment
52+
uses: actions/deploy-pages@v4

README.md

Lines changed: 11 additions & 231 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@ Ruby bindings for [BitmapPlusPlus](https://github.com/baderouaich/BitmapPlusPlus
66

77
This gem serves as both a useful library and a **practical example of using [Rice](https://github.com/ruby-rice/rice) to create Ruby bindings for C++ libraries**.
88

9-
Rice is a C++ header-only library that makes it easy to create Ruby extensions. This project demonstrates several Rice features:
10-
11-
- **Module and class definitions** - Wrapping C++ namespaces and classes
12-
- **Constructor overloading** - Multiple constructors with different signatures
13-
- **Method binding** - Direct mapping of C++ methods to Ruby
14-
- **Operator overloading** - Exposing C++ operators (`==`, `!=`, `[]`, etc.)
15-
- **Attribute access** - Binding C++ struct members as Ruby attributes
16-
- **STL integration** - Using `rice/stl.hpp` for automatic type conversions
17-
- **Iterator support** - Making C++ iterators work with Ruby's `each`
18-
- **Exception handling** - C++ exceptions converted to Ruby exceptions
19-
- **Default arguments** - Supporting optional parameters with defaults
20-
219
The binding code in `ext/bitmap_plus_plus/bitmap_plus_plus.cpp` is well-commented and can serve as a reference for your own Rice projects.
2210

2311
## Features
@@ -31,55 +19,7 @@ The binding code in `ext/bitmap_plus_plus/bitmap_plus_plus.cpp` is well-commente
3119
- 32 predefined colors
3220
- Iterator support for pixel enumeration
3321

34-
## Installation
35-
36-
### Prerequisites
37-
38-
- Ruby 3.0 or higher
39-
- A C++17 compatible compiler
40-
- Rice gem (automatically installed as a dependency)
41-
42-
### Install from RubyGems
43-
44-
```bash
45-
gem install bitmap_plus_plus
46-
```
47-
48-
### Install from source
49-
50-
```bash
51-
git clone https://github.com/cfis/bitmap_plus_plus-ruby.git
52-
cd bitmap_plus_plus-ruby
53-
bundle install
54-
rake compile
55-
rake install
56-
```
57-
58-
### Build with CMake
59-
60-
For development, you can also build using CMake with presets:
61-
62-
```bash
63-
# Linux
64-
cmake --preset linux-release
65-
cmake --build --preset linux-release
66-
67-
# macOS
68-
cmake --preset macos-release
69-
cmake --build --preset macos-release
70-
71-
# Windows (MSVC)
72-
cmake --preset msvc-release
73-
cmake --build --preset msvc-release
74-
75-
# Windows (MinGW)
76-
cmake --preset mingw-release
77-
cmake --build --preset mingw-release
78-
```
79-
80-
## Usage
81-
82-
### Basic Example
22+
## Quick Start
8323

8424
```ruby
8525
require 'bitmap_plus_plus'
@@ -100,182 +40,22 @@ image.fill_circle(200, 200, 50, Bmp::Blue)
10040
image.save("output.bmp")
10141
```
10242

103-
### Creating Pixels
104-
105-
```ruby
106-
# Create a pixel from RGB values (0-255)
107-
pixel = Bmp::Pixel.new(255, 128, 0) # Orange
108-
109-
# Create a pixel from a hex value
110-
pixel = Bmp::Pixel.new(0xFF8000) # Also orange
111-
112-
# Access RGB components
113-
puts pixel.r # => 255
114-
puts pixel.g # => 128
115-
puts pixel.b # => 0
116-
```
117-
118-
### Drawing Primitives
119-
120-
```ruby
121-
image = Bmp::Bitmap.new(512, 512)
122-
123-
# Draw a line from (x1, y1) to (x2, y2)
124-
image.draw_line(0, 0, 511, 511, Bmp::Yellow)
125-
126-
# Draw a rectangle (outline only)
127-
image.draw_rect(50, 50, 100, 75, Bmp::Red)
128-
129-
# Draw a filled rectangle
130-
image.fill_rect(200, 50, 100, 75, Bmp::Green)
131-
132-
# Draw a triangle (outline only)
133-
image.draw_triangle(300, 100, 250, 200, 350, 200, Bmp::Cyan)
134-
135-
# Draw a filled triangle
136-
image.fill_triangle(400, 100, 350, 200, 450, 200, Bmp::Magenta)
137-
138-
# Draw a circle (outline only)
139-
image.draw_circle(100, 300, 50, Bmp::Gray)
140-
141-
# Draw a filled circle
142-
image.fill_circle(250, 300, 50, Bmp::Lime)
143-
```
144-
145-
### Pixel Access
146-
147-
```ruby
148-
image = Bmp::Bitmap.new(100, 100)
149-
150-
# Set a pixel at (x, y)
151-
image.set(50, 50, Bmp::Red)
152-
153-
# Get a pixel at (x, y)
154-
pixel = image.get(50, 50)
155-
156-
# Access via index (row-major order)
157-
pixel = image[5050] # Same as get(50, 50) for 100-width image
158-
image[5050] = Bmp::Blue
159-
```
160-
161-
### Image Transformations
162-
163-
```ruby
164-
image = Bmp::Bitmap.new("input.bmp")
165-
166-
# Flip vertically (returns new bitmap)
167-
flipped_v = image.flip_v
168-
169-
# Flip horizontally (returns new bitmap)
170-
flipped_h = image.flip_h
171-
172-
# Rotate 90 degrees left (returns new bitmap)
173-
rotated_left = image.rotate_90_left
174-
175-
# Rotate 90 degrees right (returns new bitmap)
176-
rotated_right = image.rotate_90_right
177-
```
178-
179-
### Iterating Over Pixels
180-
181-
```ruby
182-
image = Bmp::Bitmap.new(100, 100)
183-
184-
# Iterate over all pixels
185-
image.each do |pixel|
186-
pixel.r = 255 # Set red channel
187-
end
188-
189-
# Reverse iteration
190-
image.each_reverse do |pixel|
191-
# Process pixels in reverse order
192-
end
193-
```
194-
195-
### Predefined Colors
196-
197-
The following colors are available as constants under the `Bmp` module:
198-
199-
```
200-
Aqua, Beige, Black, Blue, Brown, Chocolate, Coral, Crimson, Cyan,
201-
Firebrick, Gold, Gray, Green, Indigo, Lavender, Lime, Magenta, Maroon,
202-
Navy, Olive, Orange, Pink, Purple, Red, Salmon, Silver, Snow, Teal,
203-
Tomato, Turquoise, Violet, White, Wheat, Yellow
204-
```
205-
206-
### Loading and Saving
207-
208-
```ruby
209-
# Load from file
210-
image = Bmp::Bitmap.new("photo.bmp")
211-
212-
# Or load into existing bitmap
213-
image = Bmp::Bitmap.new
214-
image.load("photo.bmp")
43+
## Installation
21544

216-
# Save to file
217-
image.save("output.bmp")
45+
```bash
46+
gem install bitmap_plus_plus
21847
```
21948

220-
## API Reference
221-
222-
### Bmp::Bitmap
223-
224-
| Method | Description |
225-
|--------|-------------|
226-
| `new()` | Create an empty bitmap |
227-
| `new(width, height)` | Create a bitmap with dimensions |
228-
| `new(filename)` | Load a bitmap from file |
229-
| `new(other)` | Copy constructor |
230-
| `width` | Get image width |
231-
| `height` | Get image height |
232-
| `clear(color = Black)` | Fill entire image with color |
233-
| `get(x, y)` | Get pixel at coordinates |
234-
| `set(x, y, color)` | Set pixel at coordinates |
235-
| `[index]` | Get pixel by linear index |
236-
| `[index]=` | Set pixel by linear index |
237-
| `draw_line(x1, y1, x2, y2, color)` | Draw a line |
238-
| `draw_rect(x, y, w, h, color)` | Draw rectangle outline |
239-
| `fill_rect(x, y, w, h, color)` | Draw filled rectangle |
240-
| `draw_triangle(x1, y1, x2, y2, x3, y3, color)` | Draw triangle outline |
241-
| `fill_triangle(x1, y1, x2, y2, x3, y3, color)` | Draw filled triangle |
242-
| `draw_circle(cx, cy, radius, color)` | Draw circle outline |
243-
| `fill_circle(cx, cy, radius, color)` | Draw filled circle |
244-
| `flip_v` | Return vertically flipped copy |
245-
| `flip_h` | Return horizontally flipped copy |
246-
| `rotate_90_left` | Return 90-degree left rotated copy |
247-
| `rotate_90_right` | Return 90-degree right rotated copy |
248-
| `save(filename)` | Save to BMP file |
249-
| `load(filename)` | Load from BMP file |
250-
| `each` | Iterate over pixels |
251-
| `each_reverse` | Iterate in reverse |
49+
For detailed installation options including building from source and CMake builds, see the [Installation Guide](https://cfis.github.io/bitmap_plus_plus-ruby/installation/).
25250

253-
### Bmp::Pixel
51+
## Documentation
25452

255-
| Method | Description |
256-
|--------|-------------|
257-
| `new()` | Create black pixel (0, 0, 0) |
258-
| `new(rgb)` | Create from hex value (0xRRGGBB) |
259-
| `new(r, g, b)` | Create from RGB components |
260-
| `r`, `g`, `b` | Access color components |
261-
| `r=`, `g=`, `b=` | Set color components |
262-
| `==`, `!=` | Comparison operators |
53+
Full documentation is available at **[https://cfis.github.io/bitmap_plus_plus-ruby/](https://cfis.github.io/bitmap_plus_plus-ruby/)**
26354

264-
## Examples
265-
266-
See the `examples/` directory for runnable examples:
267-
268-
- `draw_primitives.rb` - Drawing shapes (lines, rectangles, triangles, circles)
269-
- `mandelbrot.rb` - Mandelbrot set fractal generator
270-
- `julia.rb` - Julia set fractal generator
271-
- `random_colors.rb` - Random pixel colors using iterators
272-
- `transformations.rb` - Image flip and rotate operations
273-
274-
Run an example:
275-
```bash
276-
cd examples
277-
ruby draw_primitives.rb
278-
```
55+
- [Usage Guide](https://cfis.github.io/bitmap_plus_plus-ruby/usage/) - Complete usage documentation
56+
- [Examples](https://cfis.github.io/bitmap_plus_plus-ruby/examples/) - Runnable example scripts
57+
- [API Reference](https://cfis.github.io/bitmap_plus_plus-ruby/api/Bmp/Bitmap/) - Detailed API documentation
58+
- [About Rice](https://cfis.github.io/bitmap_plus_plus-ruby/about-rice/) - Rice features demonstrated in this project
27959

28060
## License
28161

0 commit comments

Comments
 (0)