v1.0.0
Contributing to Colorium
Thank you for your interest in contributing to Colorium! This guide will help you get started with contributing to the project.
Code of Conduct
This project adheres to the Contributor Covenant Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to the project maintainers.
Getting Started
Prerequisites
- Python 3.8 or higher
- Git
- Basic knowledge of Python and color science
Development Setup
# Fork and clone the repository
git clone https://github.com/your-username/colorium.git
cd colorium
# Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -e ".[dev]"
# Verify installation
pytest -vProject Structure
colorium/
├── src/
│ └── colorium/
│ ├── __init__.py
│ ├── color.py # Core Color class
│ ├── core.py # Parser and factory functions
│ ├── converters.py # Color space conversions
│ ├── constants.py # Named color constants
│ ├── constants_colors.py # Pre-defined color constants
│ ├── filters.py # Color filters
│ ├── filter_base.py # Base filter classes
│ └── utils.py # Utility functions
├── tests/
│ ├── test_color.py
│ ├── test_core.py
│ ├── test_converters.py
│ ├── test_constants.py
│ ├── test_filters.py
│ ├── test_distance.py
│ ├── test_color_formats.py
│ └── test_utils.py
├── docs/ # Documentation
├── examples/ # Example scripts
├── pyproject.toml # Project configuration
├── pytest.ini # Test configuration
└── README.md # Project README
Development Workflow
Making Changes
- Create a new branch for your changes:
git checkout -b feature/your-feature-name-
Make your changes following the coding standards
-
Write or update tests for your changes
-
Run tests to verify everything works:
pytest -v- Check code coverage:
pytest --cov=colorium- Format your code:
black src/ tests/- Run linter:
flake8 src/ tests/- Run type checker:
mypy src/- Commit your changes:
git add .
git commit -m "feat: add your feature description"- Push to your fork:
git push origin feature/your-feature-name- Open a pull request
Commit Message Format
We follow conventional commits:
<type>(<scope>): <description>
[optional body]
[optional footer]
Types:
feat: New featurefix: Bug fixdocs: Documentationstyle: Code stylerefactor: Refactoringperf: Performancetest: Testingchore: Maintenance
Example:
feat(filters): add vignette filter
Adds VignetteFilter class for edge darkening effect.
Supports configurable intensity and center position.
Closes #123
Adding New Features
Adding a New Color Space
- Add conversion functions to
converters.py:
def rgb_to_newspace(r, g, b):
"""Convert RGB to new color space"""
return {'c1': ..., 'c2': ..., 'c3': ...}
def newspace_to_rgb(c1, c2, c3):
"""Convert new color space to RGB"""
return {'r': ..., 'g': ..., 'b': ...}- Add methods to
Colorclass incolor.py:
def to_newspace(self):
"""Convert to new color space"""
return rgb_to_newspace(self.red, self.green, self.blue)
@classmethod
def from_newspace(cls, c1, c2, c3, opacity=1.0):
"""Create from new color space"""
rgb = newspace_to_rgb(c1, c2, c3)
return cls(rgb['r'], rgb['g'], rgb['b'], opacity)- Add string conversion:
def to_newspace_string(self):
"""Convert to new color space string"""
values = self.to_newspace()
return f"newspace({values['c1']}, {values['c2']}, {values['c3']})"- Add tests in
tests/test_converters.py:
def test_rgb_to_newspace(self):
"""Test RGB to new space conversion"""
result = rgb_to_newspace(255, 0, 0)
assert result['c1'] == ...Adding a New Filter
- Create filter class in
filters.py:
class NewFilter(ColorFilter):
"""Apply new effect to a color"""
def __init__(self, intensity=1.0):
super().__init__(name=f"NewFilter({intensity})")
self.intensity = clamp(intensity, 0.0, 1.0)
def apply(self, color: Color) -> Color:
# Implementation
return Color(...)- Add tests in
tests/test_filters.py:
def test_new_filter(self):
"""Test new filter"""
filter = NewFilter(0.5)
color = Color(100, 150, 200)
result = filter.apply(color)
assert isinstance(result, Color)Adding a New Named Color
- Add to
COLOR_NAMESinconstants.py:
COLOR_NAMES = [
# ... existing names ...
"NewColorName",
]- Add corresponding hex to
COLOR_HEXES:
COLOR_HEXES = [
# ... existing hexes ...
"123456",
]Testing Guidelines
Writing Tests
- Place tests in
tests/directory - Name test files with
test_prefix - Name test functions with
test_prefix - Use descriptive test names
- Each test should be independent
Test Coverage
Aim for high test coverage:
pytest --cov=colorium --cov-report=html
# Open htmlcov/index.html in browserExample Test
def test_new_feature(self):
"""Test description"""
# Setup
color = Color(255, 0, 0)
# Execute
result = color.new_method()
# Assert
assert result == expected_valueDocumentation Guidelines
Docstrings
All public functions and classes must have docstrings:
def function_name(param1: type, param2: type) -> return_type:
"""
Brief description of what the function does.
More detailed description if needed.
Args:
param1: Description of first parameter.
param2: Description of second parameter.
Returns:
Description of return value.
Example:
>>> function_name(1, 2)
3
"""
passREADME Updates
Update README.md when adding new features or changing behavior.
Examples
Add examples to examples/ directory when adding new features:
# examples/new_feature.py
"""Example usage of new feature."""
from colorium import Color
# Example code herePull Request Process
Before Submitting
- Update your fork with upstream changes
- Run all tests
- Check code coverage
- Format code with Black
- Run linter
- Run type checker
- Update documentation
Pull Request Checklist
- Code follows style guidelines
- Tests pass locally
- New features have tests
- Documentation is updated
- Commit messages follow conventions
- PR description is clear and complete
- All CI checks pass
PR Template
## Description
Brief description of the changes.
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [ ] Other
## Testing
Describe how you tested your changes.
## Checklist
- [ ] I have read the CONTRIBUTING guide
- [ ] My code follows the style guidelines
- [ ] I have added tests that prove my fix/feature works
- [ ] I have updated the documentation
- [ ] All tests pass locally
## Related Issues
Closes #123Release Process
Version Numbering
Follow Semantic Versioning:
- MAJOR: Incompatible API changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes (backward compatible)
Release Steps
- Update version in
pyproject.toml - Update CHANGELOG.md
- Commit changes
- Create a GitHub release
- Build and publish to PyPI:
# Clean build
rm -rf dist/ build/ *.egg-info
# Build
python -m build
# Upload to PyPI
python -m twine upload dist/*Getting Help
- GitHub Issues: For bugs and feature requests
- Discussions: For questions and discussions
- Email: tryuzr@gmail.com
License
By contributing to Colorium, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to Colorium! 🚀