Metadata-Version: 2.4
Name: pyvvisf
Version: 0.4.3
Summary: Pure Python ISF shader renderer with PyOpenGL and json5
Author-email: Jim Cortez <gitstuff@jimcortez.com>
License: MIT License
        
        Copyright (c) 2024 pyvvisf contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE. 
Project-URL: Homepage, https://github.com/jimcortez/pyvvisf
Project-URL: Repository, https://github.com/jimcortez/pyvvisf
Project-URL: Documentation, https://github.com/jimcortez/pyvvisf#readme
Project-URL: Issues, https://github.com/jimcortez/pyvvisf/issues
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: glfw>=2.5.0
Requires-Dist: PyOpenGL>=3.1.0
Requires-Dist: PyOpenGL-accelerate>=3.1.0
Requires-Dist: json5>=0.9.0
Requires-Dist: pillow>=9.0.0
Requires-Dist: numpy>=1.21.0
Requires-Dist: pydantic>=1.8.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=22.0.0; extra == "dev"
Requires-Dist: isort>=5.0.0; extra == "dev"
Requires-Dist: flake8>=5.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: pre-commit>=2.20.0; extra == "dev"
Requires-Dist: cibuildwheel>=3.0.0; extra == "dev"
Requires-Dist: build>=0.10.0; extra == "dev"
Dynamic: license-file

# pyvvisf

Pure Python ISF shader renderer with PyOpenGL and json5.

## Overview

pyvvisf is a pure Python implementation for parsing and rendering ISF (Interactive Shader Format) shaders. It provides a modern, maintainable alternative to the C++ VVISF-GL library with enhanced error reporting and cross-platform compatibility.

## Features

- **Pure Python**: No C++ compilation required
- **Robust JSON parsing**: Uses json5 for comment support and trailing commas
- **Modern OpenGL**: PyOpenGL with GLFW for cross-platform context management
- **Enhanced error reporting**: Detailed Python-native error messages with context
- **Type safety**: Pydantic models for metadata validation
- **Auto-coercion**: Automatic type conversion for shader inputs
- **Context management**: Automatic resource cleanup

## Installation

```bash
pip install pyvvisf
```

### Development Installation

```bash
git clone https://github.com/jimcortez/pyvvisf.git
cd pyvvisf
pip install -e .
```

## Quick Start

```python
from pyvvisf import ISFRenderer, ISFColor, ISFPoint2D

# Create a simple test shader
test_shader = """
/*{
    "NAME": "Test Shader",
    "INPUTS": [
        {
            "NAME": "color",
            "TYPE": "color",
            "DEFAULT": [1.0, 0.0, 0.0, 1.0]
        },
        {
            "NAME": "scale",
            "TYPE": "float",
            "DEFAULT": 1.0
        }
    ]
}*/

uniform vec2 RENDERSIZE;
uniform vec4 color;
uniform float scale;

out vec4 fragColor;

void main() {
    vec2 uv = gl_FragCoord.xy / RENDERSIZE.xy;
    vec2 pos = (uv - 0.5) * scale;
    float dist = length(pos);
    float circle = smoothstep(0.5, 0.4, dist);
    fragColor = color * circle;
}
"""

# Render the shader
with ISFRenderer() as renderer:
    # Load shader
    metadata = renderer.load_shader_content(test_shader)
    
    # Render with default parameters
    image_array = renderer.render(width=512, height=512)
    
    # Render with custom parameters
    custom_inputs = {
        'color': [0.0, 1.0, 0.0, 1.0],  # Green
        'scale': 2.0
    }
    
    image_array = renderer.render(
        width=512, height=512,
        inputs=custom_inputs,
        metadata=metadata
    )
    
    # Save to file
    renderer.save_render("output.png", width=512, height=512)
```

## Examples

See the `examples/` directory for complete examples:

- `pure_python_demo.py`: Basic usage demonstration
- `isf_renderer_demo.py`: Advanced rendering examples

## Development

### Building

```bash
# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Format code
black src/ tests/
isort src/ tests/

# Type checking
mypy src/
```

### Project Structure

```
pyvvisf/
├── src/pyvvisf/
│   ├── core/
│   │   ├── __init__.py
│   │   ├── renderer.py      # Main renderer
│   │   ├── parser.py        # ISF parser with json5
│   │   ├── types.py         # Value types
│   │   └── errors.py        # Error handling
│   ├── __init__.py
│   └── _version.py
├── examples/
├── tests/
└── docs/
```

## License

MIT License - see LICENSE file for details.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request. 
