Created
June 10, 2017 11:54
-
-
Save jackmott/d654720a5647166b119e23b646358a40 to your computer and use it in GitHub Desktop.
checkerboard pattern sdl2 rust
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mut finish_line_tex = texture_creator | |
.create_texture_streaming(PixelFormatEnum::RGB24, | |
FINISH_LINE_LENGTH as u32, | |
FINISH_LINE_WIDTH as u32) | |
.unwrap(); | |
finish_line_tex.set_blend_mode(BlendMode::Add); | |
finish_line_tex | |
.with_lock(None, | |
|buffer: &mut [u8], pitch: usize| for y in 0..FINISH_LINE_WIDTH { | |
for x in 0..FINISH_LINE_LENGTH { | |
let offset = y as usize * pitch + x as usize * 3; | |
let color = if (y as f64 / 5.0) as i32 % 2 == 0 { | |
if (x as f64 / 5.0) as i32 % 2 == 0 { | |
0 | |
} else { | |
128 | |
} | |
} else { | |
if (x as f64 / 5.0) as i32 % 2 == 0 { | |
128 | |
} else { | |
0 | |
} | |
}; | |
buffer[offset] = color; | |
buffer[offset + 1] = color; | |
buffer[offset + 2] = color; | |
} | |
}) | |
.unwrap(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment