{"id":16170169,"url":"https://github.com/porglezomp/pixel-canvas","last_synced_at":"2025-09-15T03:09:51.947Z","repository":{"id":35078064,"uuid":"203322929","full_name":"porglezomp/pixel-canvas","owner":"porglezomp","description":"A crate to make drawing in a buffer of pixels easy!","archived":false,"fork":false,"pushed_at":"2023-08-31T22:17:16.000Z","size":29,"stargazers_count":30,"open_issues_count":3,"forks_count":9,"subscribers_count":5,"default_branch":"develop","last_synced_at":"2024-10-11T03:17:42.893Z","etag":null,"topics":["art","crate","graphics","interactive","rust"],"latest_commit_sha":null,"homepage":"https://docs.rs/pixel-canvas/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/porglezomp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-20T07:26:43.000Z","updated_at":"2024-09-21T10:46:51.000Z","dependencies_parsed_at":"2022-08-17T22:51:05.556Z","dependency_job_id":null,"html_url":"https://github.com/porglezomp/pixel-canvas","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porglezomp%2Fpixel-canvas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porglezomp%2Fpixel-canvas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porglezomp%2Fpixel-canvas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/porglezomp%2Fpixel-canvas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/porglezomp","download_url":"https://codeload.github.com/porglezomp/pixel-canvas/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221662684,"owners_count":16859731,"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":["art","crate","graphics","interactive","rust"],"created_at":"2024-10-10T03:17:44.836Z","updated_at":"2024-10-27T10:25:06.755Z","avatar_url":"https://github.com/porglezomp.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Crates.io](https://img.shields.io/crates/v/pixel-canvas.svg)](https://crates.io/crates/pixel-canvas)\n[![Docs.rs](https://docs.rs/pixel-canvas/badge.svg)](https://docs.rs/pixel-canvas)\n[![Build Status](https://travis-ci.org/porglezomp/pixel-canvas.svg?branch=develop)](https://travis-ci.org/porglezomp/pixel-canvas)\n\n# Pixel Canvas\n\nThis crate is designed to make it easy to build interactive computer art\nwith just a pixel buffer. For inspiration, consider looking at\n\u003chttps://shadertoy.com\u003e and \u003chttp://www.iquilezles.org/www/index.htm\u003e,\nthere are a lot of cool art pieces to see and explanations of fun techniques!\n\n## Usage\n\nTo make a piece of art, you create and configure a `Canvas` object, and\nthen you ask it to `render` with your code. The canvas will do state\nmanagement and hand you an image to modify. Whatever modifications you make\nto the image will be displayed on the screen.\n\n\n## Example\n\n```rust\nuse pixel_canvas::{Canvas, Color, input::MouseState};\n\nfn main() {\n    // Configure the window that you want to draw in. You can add an event\n    // handler to build interactive art. Input handlers for common use are\n    // provided.\n    let canvas = Canvas::new(512, 512)\n        .title(\"Tile\")\n        .state(MouseState::new())\n        .input(MouseState::handle_input);\n    // The canvas will render for you at up to 60fps.\n    canvas.render(|mouse, image| {\n        // Modify the `image` based on your state.\n        let width = image.width() as usize;\n        for (y, row) in image.chunks_mut(width).enumerate() {\n            for (x, pixel) in row.iter_mut().enumerate() {\n                let dx = x as i32 - mouse.x;\n                let dy = y as i32 - mouse.y;\n                let dist = dx * dx + dy * dy;\n                *pixel = Color {\n                    r: if dist \u003c 128 * 128 { dy as u8 } else { 0 },\n                    g: if dist \u003c 128 * 128 { dx as u8 } else { 0 },\n                    b: (x * y) as u8,\n                }\n            }\n        }\n    });\n}\n```\n\nor run an included example (with nightly):\n\n```sh\ncargo +nightly run --example api_example\n```\n\nLicense: MIT OR Apache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fporglezomp%2Fpixel-canvas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fporglezomp%2Fpixel-canvas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fporglezomp%2Fpixel-canvas/lists"}