Python bindings for Rust Planetarium rendering library
Project description
PyPlanetarium
Python bindings for Planetarium sub-pixel precision light spot rendering library for astronomy and video tracking applications.
Example usage
from pyplanetarium import Canvas, SpotShape, ImageFormat, Window
# Draw on a square 256x256 pixel canvas.
c = Canvas.new(256, 256)
# Define a round spot shape with diffraction radius of 2.5 pixels.
shape = SpotShape().scale(2.5)
# Add some spots at random positions with varying shape size
# and peak intensity.
spot1 = c.add_spot((100.3, 130.8), shape, 0.5)
spot2 = c.add_spot((80.6, 200.2), shape.scale(0.5), 0.9)
# Note: Out of range position coordinates and peak intensities are fine.
# The resulting spot image is clipped into the canvas rectangle.
# Peak intensity > 1.0 leads to saturation to the maximum pixel value.
spot3 = c.add_spot((256.1, 3.5), shape.scale(10.0), 1.1)
# Set the canvas background pixel value.
c.set_background(int(0.05 * Canvas.PIXEL_MAX))
# Clear the canvas and paint the light spots.
c.draw()
# Export to a 8-bit gamma-compressed grayscale PNG image.
png_8bpp_bytes = c.export_image(ImageFormat.PngGamma8Bpp)
# Export to a 16-bit linear light grayscale PNG image.
png_16bpp_bytes = c.export_image(ImageFormat.PngLinear16Bpp)
# Export a rectangular canvas window to a 8-bit gamma-compressed RAW image.
wnd = Window.new(64, 32).at(90, 120)
raw_window_8bpp_bytes = c.export_window_image(wnd, ImageFormat.PngGamma8Bpp)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyplanetarium-0.1.3.tar.gz
(13.8 kB
view hashes)
Built Distributions
Close
Hashes for pyplanetarium-0.1.3-cp37-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5688dbe5db91a376db05f9b4e8e7137b5c5e0b7c79602190ad914400f46352ab |
|
MD5 | 80f4199a47a743de1013f88e3f976159 |
|
BLAKE2b-256 | 947c538e9c45969aaa087640a0edb433b55695e3d33814485e6976666fb79bd2 |
Close
Hashes for pyplanetarium-0.1.3-cp37-abi3-manylinux_2_27_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fe2de7795d8392f817591b3ed162bbdbb6fb70ceb2e6651d33896fb68db4cdf |
|
MD5 | 4f9a45afa07186ac58b32cf60aaf6cae |
|
BLAKE2b-256 | dad444f10e6ff6b00a5846d6e028c911c72e3899eceaf3c6f505172378962a5c |