This commit is contained in:
nek0 2024-10-11 16:10:00 +02:00
parent 41ad2cabee
commit daf99064d5

View file

@ -5,12 +5,30 @@ use sdl2::event::Event;
use sdl2::keyboard::Keycode; use sdl2::keyboard::Keycode;
use std::time::Duration; use std::time::Duration;
struct Base {
lines: Vec<Line>,
}
struct Position {
x: u32,
y: u32,
}
struct Line {
start: Position,
end: Position,
}
pub fn main() { pub fn main() {
println!("Hello, world!"); println!("Hello, world!");
let width = 800;
let height = 600;
let sdl_context = sdl2::init().unwrap(); let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap(); let video_subsystem = sdl_context.video().unwrap();
let window = match video_subsystem.window("fractals", 800, 600) let window = match video_subsystem.window("fractals", width, height)
.position_centered() .position_centered()
.build() { .build() {
Ok(w) => { w }, Ok(w) => { w },
@ -23,6 +41,15 @@ pub fn main() {
let mut i = 0; let mut i = 0;
let mut flip = true; let mut flip = true;
let mut base = Base{lines:
vec![ Line{start: Position{x: width / 4, y: 3 * height / 4}
, end: Position{x: 3 * width / 4, y: 3 * height / 4}}
, Line{start: Position{x: 3* width / 4, y: 3 * height / 4}
, end: Position{x: width / 2, y: height / 4}}
, Line{start: Position{x: width / 2, y: height / 4}
, end: Position{x: width / 4, y: 3 * height / 4}}
]};
'running: loop { 'running: loop {
if i % 255 == 0 { if i % 255 == 0 {
flip = !flip; flip = !flip;