move example out of module
This commit is contained in:
		
							parent
							
								
									6b5fdca654
								
							
						
					
					
						commit
						2ff0ffa0d6
					
				
					 5 changed files with 39 additions and 28 deletions
				
			
		
							
								
								
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -1,2 +1,2 @@
 | 
				
			||||||
/target
 | 
					target
 | 
				
			||||||
.idea
 | 
					.idea
 | 
				
			||||||
							
								
								
									
										14
									
								
								examples/moving_line/Cargo.lock
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								examples/moving_line/Cargo.lock
									
										
									
										generated
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,14 @@
 | 
				
			||||||
 | 
					# This file is automatically @generated by Cargo.
 | 
				
			||||||
 | 
					# It is not intended for manual editing.
 | 
				
			||||||
 | 
					version = 3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[package]]
 | 
				
			||||||
 | 
					name = "moving_line"
 | 
				
			||||||
 | 
					version = "0.1.0"
 | 
				
			||||||
 | 
					dependencies = [
 | 
				
			||||||
 | 
					 "servicepoint2",
 | 
				
			||||||
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[[package]]
 | 
				
			||||||
 | 
					name = "servicepoint2"
 | 
				
			||||||
 | 
					version = "0.1.0"
 | 
				
			||||||
							
								
								
									
										7
									
								
								examples/moving_line/Cargo.toml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								examples/moving_line/Cargo.toml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,7 @@
 | 
				
			||||||
 | 
					[package]
 | 
				
			||||||
 | 
					name = "moving_line"
 | 
				
			||||||
 | 
					version = "0.1.0"
 | 
				
			||||||
 | 
					edition = "2021"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[dependencies]
 | 
				
			||||||
 | 
					servicepoint2 = { path = "../.." }
 | 
				
			||||||
							
								
								
									
										17
									
								
								examples/moving_line/src/main.rs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								examples/moving_line/src/main.rs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,17 @@
 | 
				
			||||||
 | 
					use servicepoint2::{Connection, Origin, PIXEL_HEIGHT, PIXEL_WIDTH, PixelGrid, Size, TILE_WIDTH, Window};
 | 
				
			||||||
 | 
					use servicepoint2::Command::BitmapLinearWin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fn main() {
 | 
				
			||||||
 | 
					    let connection = Connection::open("localhost:2342").unwrap();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    for x_offset in 0..usize::MAX {
 | 
				
			||||||
 | 
					        let mut pixels = PixelGrid::new(PIXEL_WIDTH as usize, PIXEL_HEIGHT as usize);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for y in 0..PIXEL_HEIGHT as usize {
 | 
				
			||||||
 | 
					            pixels.set((y + x_offset) % PIXEL_WIDTH as usize, y, true);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let window = Window(Origin(0, 0), Size(TILE_WIDTH, PIXEL_HEIGHT));
 | 
				
			||||||
 | 
					        connection.send(BitmapLinearWin(window, pixels)).unwrap();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										27
									
								
								src/main.rs
									
										
									
									
									
								
							
							
						
						
									
										27
									
								
								src/main.rs
									
										
									
									
									
								
							| 
						 | 
					@ -1,27 +0,0 @@
 | 
				
			||||||
use std::thread;
 | 
					 | 
				
			||||||
use std::time::Duration;
 | 
					 | 
				
			||||||
use servicepoint2::{Command, Connection, Origin, PIXEL_HEIGHT, PIXEL_WIDTH, PixelGrid, Size, TILE_WIDTH, Window};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
fn main() {
 | 
					 | 
				
			||||||
    // 172.23.42.29
 | 
					 | 
				
			||||||
    let connection = Connection::open("localhost:2342").unwrap();
 | 
					 | 
				
			||||||
    connection.send(Command::Clear).unwrap();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    connection.send(Command::Cp437Data(Window(Origin(0, 0), Size(3, 2)), Vec::from("abcdef"))).unwrap();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    loop {
 | 
					 | 
				
			||||||
        for x_offset in 0..usize::MAX {
 | 
					 | 
				
			||||||
            let mut pixels = PixelGrid::new(PIXEL_WIDTH as usize, PIXEL_HEIGHT as usize);
 | 
					 | 
				
			||||||
            for y in 0..PIXEL_HEIGHT as usize {
 | 
					 | 
				
			||||||
                for x_add in 0..=y % 8 {
 | 
					 | 
				
			||||||
                    pixels.set((y + x_offset + x_add) % PIXEL_WIDTH as usize, y, true);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            let window = Window(Origin(0, 0), Size(TILE_WIDTH, PIXEL_HEIGHT));
 | 
					 | 
				
			||||||
            connection.send(Command::BitmapLinearWin(window, pixels)).unwrap();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            thread::sleep(Duration::from_millis(100));
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue