https://github.com/merlinz01/pyd2d
A Python wrapper for the Windows Direct2D API
https://github.com/merlinz01/pyd2d
cython-wrapper direct2d directwrite python windows
Last synced: 7 months ago
JSON representation
A Python wrapper for the Windows Direct2D API
- Host: GitHub
- URL: https://github.com/merlinz01/pyd2d
- Owner: merlinz01
- License: mit
- Created: 2025-02-27T02:52:53.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-02-27T20:36:29.000Z (7 months ago)
- Last Synced: 2025-02-28T01:08:37.429Z (7 months ago)
- Topics: cython-wrapper, direct2d, directwrite, python, windows
- Language: Python
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# pyD2D - A Python wrapper for the Windows Direct2D API
pyD2D is a Python wrapper for the Windows Direct2D and DirectWrite APIs.
Not all of the Direct2D and DirectWrite APIs are wrapped, but the most commonly used ones are.
If you need a specific API that is not wrapped, feel free to open an issue or submit a pull request.Note: At this point pyD2D only provides wheels for Python 3.13 32-bit on Windows,
due to the headaches of Python packaging for Cython extensions.
If you need a wheel for a different version of Python, feel free to open an issue.## Installation
```bash
pip install pyd2d
```## Usage
```python
import pyd2d# Initialize COM
pyd2d.InitializeCOM()# Create a Direct2D factory
factory = pyd2d.GetD2DFactory()# Create a render target
render_target = factory.CreateHwndRenderTarget(
my_hwnd, width=800, height=600,
)# Draw a rectangle
render_target.BeginDraw()
render_target.Clear(1.0, 1.0, 1.0, 1.0)
render_target.FillRectangle(100, 100, 200, 200, render_target.CreateSolidColorBrush(0.0, 0.0, 0.0, 1.0))
render_target.EndDraw()
```## License
pyD2D is licensed under the MIT License.