{"id":16110727,"url":"https://github.com/ravenexp/planetarium","last_synced_at":"2025-03-18T09:30:59.058Z","repository":{"id":57656210,"uuid":"418258316","full_name":"ravenexp/planetarium","owner":"ravenexp","description":"Sub-pixel precision light spot rendering library","archived":false,"fork":false,"pushed_at":"2023-03-16T11:17:42.000Z","size":136,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-14T15:06:00.329Z","etag":null,"topics":["astronomy","graphics-library","science","simulation-modeling"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ravenexp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-17T21:19:59.000Z","updated_at":"2024-12-23T04:23:34.000Z","dependencies_parsed_at":"2024-10-27T17:29:11.759Z","dependency_job_id":"21c4d584-ab33-452f-8830-212ce226eab6","html_url":"https://github.com/ravenexp/planetarium","commit_stats":{"total_commits":68,"total_committers":1,"mean_commits":68.0,"dds":0.0,"last_synced_commit":"c109918ca1fd59b0b298ae242fc47a4c122ab7bb"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravenexp%2Fplanetarium","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravenexp%2Fplanetarium/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravenexp%2Fplanetarium/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ravenexp%2Fplanetarium/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ravenexp","download_url":"https://codeload.github.com/ravenexp/planetarium/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243597833,"owners_count":20316844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["astronomy","graphics-library","science","simulation-modeling"],"created_at":"2024-10-09T19:39:18.862Z","updated_at":"2025-03-18T09:30:58.497Z","avatar_url":"https://github.com/ravenexp.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Planetarium\n===========\n\nSub-pixel precision light spot rendering library for astronomy\nand video tracking applications.\n\nSample image\n------------\n\n![Sample](https://raw.githubusercontent.com/ravenexp/planetarium/main/tests/test_8bpp.png)\n\nExample usage\n-------------\n\n```rust\nuse planetarium::{Canvas, SpotShape};\n\n// Draw on a square 256x256 pixel canvas.\nlet mut c = Canvas::new(256, 256);\n\n// Define a round spot shape with diffraction radius of 2.5 pixels.\nlet shape = SpotShape::default().scale(2.5);\n\n// Add some spots at random positions with varying shape size\n// and peak intensity.\nlet spot1 = c.add_spot((100.3, 130.8), shape, 0.5);\nlet spot2 = c.add_spot((80.6, 200.2), shape.scale(0.5), 0.9);\n\n// Note: Out of range position coordinates and peak intensities are fine.\n//       The resulting spot image is clipped into the canvas rectangle.\n//       Peak intensity \u003e 1.0 leads to saturation to the maximum pixel value.\nlet spot3 = c.add_spot((256.1, 3.5), shape.scale(10.0), 1.1);\n\n// Set the canvas background pixel value.\nc.set_background(100);\n\n// Clear the canvas and paint the light spots.\nc.draw();\n\n// Access the rendered image data as a linear pixel array.\nlet image_pixbuf = c.pixels();\n\n// Get pixel at x = 100, y = 200.\nlet (x, y) = (100, 200);\nlet (image_width, image_height) = c.dimensions();\nlet val_x_y = image_pixbuf[(y * image_width + x) as usize];\n```\n\nLight spot parameters adjustment\n--------------------------------\n\nSome of the light spot parameters like coordinates and peak intensity\ncan be adjusted after the spot has been added to the canvas.\n\nThe spot position coordinates can be changed by adding an offset vector\nand the peak intensity can be adjusted by multiplying with a spot\nillumination factor.\n\nIt is possible to define a custom world coordinates to canvas coordinates\ntransformation, which affects all light spots.\n\n```rust\nuse planetarium::{Canvas, SpotShape, Transform};\n\n// Draw on a square 256x256 pixel canvas.\nlet mut c = Canvas::new(256, 256);\n\n// Define an elliptic spot shape with diffraction radii of 2.5 x 1.5 pixels\n// rotated by 45 degrees counter-clockwise.\nlet shape1 = SpotShape::default().stretch(2.5, 1.5).rotate(45.0);\n\n// Define an elliptic spot shape by a 2x2 linear transform matrix.\nlet shape2 = SpotShape::from([[2.0, -0.5], [1.5, 3.0]]);\n\n// Add some spots at random positions with varying shape size\n// and peak intensity.\nlet spot1 = c.add_spot((100.3, 130.8), shape1, 0.5);\nlet spot2 = c.add_spot((80.6, 200.2), shape2, 0.9);\n\n// Shift the rendered spot positions by applying the relative offset vectors.\n// The intrinsic spot position coordinates are immutable.\nc.set_spot_offset(spot1, (-34.2, 12.6));\nc.set_spot_offset(spot2, (114.2, -73.3));\n\n// Adjust the rendered spot peak intensity by applying the spot illumination factors.\n// The intrinsic spot intensities are immutable.\nc.set_spot_illumination(spot1, 1.2);\nc.set_spot_illumination(spot2, 0.7);\n\n// Query the resulting spot coordinates on the canvas.\nlet pos1 = c.spot_position(spot1).unwrap();\nlet pos2 = c.spot_position(spot2).unwrap();\n\n// Query the resulting peak spot intensities.\nlet int1 = c.spot_intensity(spot1).unwrap();\nlet int2 = c.spot_intensity(spot2).unwrap();\n\n// Apply a custom world coordinates to canvas coordinates transformation.\nc.set_view_transform(Transform::default().translate((13.7, -20.3)));\n\n// Query the resulting spot coordinates on the canvas after\n// the view coordinate transformation.\nlet pos1x = c.spot_position(spot1).unwrap();\nlet pos2x = c.spot_position(spot2).unwrap();\n```\n\nCanvas image export\n-------------------\n\nThe `Canvas` object supports image export to RAW and PNG file formats.\nBoth 8-bit and 16-bit PNG sample formats are supported.\nExport to PNG formats requires the default `png` feature to be enabled.\n\n### Example image export code\n\n```rust\nlet mut c = Canvas::new(256, 256);\n\nc.set_background(1000);\nc.clear();\n\n// Export to a 8-bit gamma-compressed grayscale RAW image.\nlet raw_8bpp_bytes = c.export_image(ImageFormat::RawGamma8Bpp).unwrap();\n\n// Export to a 10-bit linear light grayscale little-endian RAW image.\nlet raw_10bpp_bytes = c.export_image(ImageFormat::RawLinear10BppLE).unwrap();\n\n// Export to a 12-bit gamma-compressed grayscale little-endian RAW image.\nlet raw_12bpp_bytes = c.export_image(ImageFormat::RawLinear12BppLE).unwrap();\n\n// Export to a 8-bit gamma-compressed grayscale PNG image.\nlet png_8bpp_bytes = c.export_image(ImageFormat::PngGamma8Bpp).unwrap();\n\n// Export to a 16-bit linear light grayscale PNG image.\nlet png_16bpp_bytes = c.export_image(ImageFormat::PngLinear16Bpp).unwrap();\n```\n\nWindow image export\n-------------------\n\nThe `Canvas` object additionally supports windowed image export.\n\nA single rectangular window represents a region of interest (ROI)\non the canvas image. Window rectangle coordinates are represented\nby the public `Window` structure.\n\n### Example window image export code\n\n```rust\nlet c = Canvas::new(256, 256);\n\n// Create a 32x16 pixels window with origin at (100, 150).\nlet wnd = Window::new(32, 16).at(100, 150);\n\nlet fmt = ImageFormat::RawGamma8Bpp;\n\n// Export to the canvas window image bytes.\nlet raw_window_bytes = c.export_window_image(wnd, fmt).unwrap();\n```\n\nSubsampled image export\n-----------------------\n\nThe `Canvas` object additionally supports subsampled image export\nwith independent row and column subsampling factors.\n\nOnly whole canvas images can be exported with subsampling.\n\n### Example subsampled image export code\n\n```rust\nlet c = Canvas::new(256, 256);\n\nlet fmt = ImageFormat::RawLinear10BppLE;\n\n// Column (X) and row (Y) subsampling factors\nlet factors = (4, 2);\n\n// Export to the subsampled canvas image bytes.\nlet raw_sub_bytes = c.export_subsampled_image(factors, fmt).unwrap();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravenexp%2Fplanetarium","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fravenexp%2Fplanetarium","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fravenexp%2Fplanetarium/lists"}