GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — libprocessing/examples/update_pixels.rs at python-fixes · processing/libprocessing Expand file tree/ Copy pathupdate_pixels.rsMore file actions 82 lines (67 loc) · 2.58 KB / Copy pathupdate_pixels.rsFile metadata and controls82 lines (67 loc) · 2.58 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 use processing_glfw::GlfwContext; use bevy::{color::Color, prelude::LinearRgba}; use processing::prelude::*; fn main() { match sketch() { Ok(_) => { eprintln!("Sketch completed successfully"); exit(0).unwrap(); } Err(e) => { eprintln!("Sketch error: {:?}", e); exit(1).unwrap(); } }; } fn sketch() -> error::Result<()> { let mut glfw_ctx = GlfwContext::new(100, 100, false)?; init(Config::default())?; let width = 100; let height = 100; let surface = glfw_ctx.create_surface(width, height, false)?; let graphics = graphics_create(surface, width, height, TextureFormat::Rgba16Float)?; let rect_w = 10; let rect_h = 10; let red = LinearRgba::new(1.0, 0.0, 0.0, 1.0); let red_pixels: Vec<LinearRgba> = vec![red; rect_w * rect_h]; let blue = LinearRgba::new(0.0, 0.0, 1.0, 1.0); let blue_pixels: Vec<LinearRgba> = vec![blue; rect_w * rect_h]; let mut first_frame = true; while glfw_ctx.poll_events() { graphics_begin_draw(graphics)?; graphics_record_command(graphics, DrawCommand::BackgroundColor(Color::BLACK))?; graphics_flush(graphics)?; graphics_update_region(graphics, 20, 20, rect_w as u32, rect_h as u32, &red_pixels)?; graphics_update_region(graphics, 60, 60, rect_w as u32, rect_h as u32, &blue_pixels)?; graphics_end_draw(graphics)?; if first_frame { first_frame = false; let pixels = graphics_readback(graphics)?; eprintln!("Total pixels: {}", pixels.len()); for y in 0..height { for x in 0..width { let idx = (y * width + x) as usize; if idx < pixels.len() { let pixel = pixels[idx]; if pixel.red > 0.5 { eprint!("R"); } else if pixel.blue > 0.5 { eprint!("B"); } else if pixel.alpha > 0.5 { eprint!("."); } else { eprint!(" "); } } } eprintln!(); } eprintln!("\nSample pixels:"); eprintln!("(25, 25): {:?}", pixels[25 * width as usize + 25]); eprintln!("(65, 65): {:?}", pixels[65 * width as usize + 65]); eprintln!("(0, 0): {:?}", pixels[0]); eprintln!("(50, 50): {:?}", pixels[50 * width as usize + 50]); } } Ok(()) } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |