Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void draw_line(s32 x1, s32 y1, s32 x2, s32 y2){
- //faster Bresenham by Endesga
- s32 xd = x2 - x1;
- s32 yd = y2 - y1;
- s32 hs = 0x8000;
- s32 vs = 0x8000;
- s32 amount = max(abs(xd), abs(yd));
- s32 xs = ((xd << 16) / amount);
- s32 ys = ((yd << 16) / amount);
- for (u16 i = 0; i < amount; i++){
- hs += xs;
- vs += ys;
- draw_pixel(x1 + (hs >> 16), y1 + (vs >> 16));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement