MCPcopy Index your code
hub / github.com/endbasic/endbasic / test_sdl_console_draw

Function test_sdl_console_draw

sdl/src/console.rs:819–933  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

817
818 #[test]
819 fn test_sdl_console_draw() {
820 let mut test = SdlTest::default();
821 let console = test.console();
822
823 fn xy(x: i16, y: i16) -> PixelsXY {
824 PixelsXY { x, y }
825 }
826
827 // ----
828 // Draw some stuff that is completely visible.
829 // ----
830
831 console.set_color(Some(15), None).unwrap();
832 console.draw_line(xy(10, 50), xy(110, 60)).unwrap();
833 console.set_color(Some(12), Some(1)).unwrap();
834 console.draw_line(xy(120, 70), xy(20, 60)).unwrap();
835
836 console.set_color(Some(12), Some(1)).unwrap();
837 // A line with start and end at the same spot should be invisible.
838 console.draw_line(xy(200, 200), xy(200, 200)).unwrap();
839 // But with a slight variation it should be a pixel.
840 console.draw_line(xy(190, 190), xy(190, 191)).unwrap();
841 console.draw_line(xy(190, 190), xy(191, 190)).unwrap();
842 console.draw_line(xy(190, 191), xy(190, 190)).unwrap();
843 console.draw_line(xy(191, 190), xy(190, 190)).unwrap();
844
845 console.set_color(Some(15), None).unwrap();
846 console.draw_rect_filled(xy(380, 180), xy(220, 120)).unwrap();
847 console.set_color(Some(10), None).unwrap();
848 console.draw_rect(xy(200, 100), xy(400, 200)).unwrap();
849 console.set_color(Some(11), None).unwrap();
850 console.draw_tri_filled(xy(500, 100), xy(560, 200), xy(440, 200)).unwrap();
851 console.set_color(Some(13), None).unwrap();
852 console.draw_tri(xy(500, 80), xy(580, 220), xy(420, 220)).unwrap();
853
854 console.set_color(Some(10), None).unwrap();
855 console
856 .draw_poly_filled(&[xy(80, 140), xy(140, 110), xy(180, 150), xy(150, 210), xy(90, 200)])
857 .unwrap();
858 console.set_color(Some(15), None).unwrap();
859 console
860 .draw_poly(&[xy(70, 130), xy(145, 90), xy(195, 145), xy(155, 225), xy(80, 210)])
861 .unwrap();
862
863 console.set_color(Some(14), None).unwrap();
864 console.draw_circle_filled(xy(650, 400), 50).unwrap();
865 console.set_color(Some(9), None).unwrap();
866 console.draw_circle(xy(650, 400), 80).unwrap();
867
868 console.set_color(Some(12), None).unwrap();
869 // A circle of radius 1 should be a single pixel.
870 console.draw_circle_filled(xy(650, 210), 1).unwrap();
871 console.draw_circle(xy(650, 200), 1).unwrap();
872 // A circle of radius 0 should be invisible.
873 console.draw_circle_filled(xy(650, 215), 0).unwrap();
874 console.draw_circle(xy(650, 205), 0).unwrap();
875
876 console.set_color(Some(14), None).unwrap();

Callers

nothing calls this directly

Calls 15

consoleMethod · 0.80
verifyMethod · 0.80
xyFunction · 0.70
set_colorMethod · 0.45
draw_lineMethod · 0.45
draw_rect_filledMethod · 0.45
draw_rectMethod · 0.45
draw_tri_filledMethod · 0.45
draw_triMethod · 0.45
draw_poly_filledMethod · 0.45
draw_polyMethod · 0.45
draw_circle_filledMethod · 0.45

Tested by

no test coverage detected