add new blend function and rgba triangle 2d visual reference tests
|
@ -2104,3 +2104,693 @@ fn blend_function_blend_source_with_alpha() {
|
|||
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
|
||||
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn blend_function_multiplied_blend() {
|
||||
let mut screen = setup_for_blending_half_solid_half_semi_transparent();
|
||||
|
||||
let bmp_solid = generate_bitmap(32, 32);
|
||||
let bmp_solid_with_varied_alpha = generate_solid_bitmap_with_varied_alpha(32, 32);
|
||||
let bmp_with_varied_alpha = generate_bitmap_with_varied_alpha(32, 32);
|
||||
|
||||
let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(to_argb32(255, 242, 29, 81)));
|
||||
screen.blit(method.clone(), &bmp_solid, 10, 5);
|
||||
screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 5);
|
||||
screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 5);
|
||||
|
||||
let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(to_argb32(127, 242, 29, 81)));
|
||||
screen.blit(method.clone(), &bmp_solid, 10, 40);
|
||||
screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 40);
|
||||
screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 40);
|
||||
|
||||
let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(to_argb32(0, 242, 29, 81)));
|
||||
screen.blit(method.clone(), &bmp_solid, 10, 75);
|
||||
screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 75);
|
||||
screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 75);
|
||||
|
||||
//////
|
||||
|
||||
let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(to_argb32(255, 242, 29, 81)));
|
||||
screen.blit(method.clone(), &bmp_solid, 10, 125);
|
||||
screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 125);
|
||||
screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 125);
|
||||
|
||||
let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(to_argb32(127, 242, 29, 81)));
|
||||
screen.blit(method.clone(), &bmp_solid, 10, 160);
|
||||
screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 160);
|
||||
screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 160);
|
||||
|
||||
let method = RgbaBlitMethod::SolidBlended(BlendFunction::MultipliedBlend(to_argb32(0, 242, 29, 81)));
|
||||
screen.blit(method.clone(), &bmp_solid, 10, 195);
|
||||
screen.blit(method.clone(), &bmp_solid_with_varied_alpha, 100, 195);
|
||||
screen.blit(method.clone(), &bmp_with_varied_alpha, 200, 195);
|
||||
|
||||
let path = reference_file(Path::new("blend_function_multiplied_blend.png"));
|
||||
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
|
||||
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn triangle_2d() {
|
||||
use RgbaTriangle2d::*;
|
||||
|
||||
let mut screen = setup();
|
||||
screen.clear(LIGHTER_BACKGROUND);
|
||||
|
||||
let color = COLOR_BLUE;
|
||||
let v1 = Vector2::new(32.0, 36.0);
|
||||
let v2 = Vector2::new(32.0, 63.0);
|
||||
let v3 = Vector2::new(73.0, 36.0);
|
||||
screen.triangle_2d(&Solid { position: [v1, v2, v3], color });
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
v1 - Vector2::new(50.0, 0.0), //
|
||||
v2 - Vector2::new(50.0, 0.0),
|
||||
v3 - Vector2::new(50.0, 0.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
v1 - Vector2::new(0.0, 50.0), //
|
||||
v2 - Vector2::new(0.0, 50.0),
|
||||
v3 - Vector2::new(0.0, 50.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
|
||||
let color = COLOR_GREEN;
|
||||
let v1 = Vector2::new(123.0, 60.0);
|
||||
let v2 = Vector2::new(162.0, 60.0);
|
||||
let v3 = Vector2::new(144.0, 32.0);
|
||||
screen.triangle_2d(&Solid { position: [v1, v2, v3], color });
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
v1 - Vector2::new(0.0, 45.0), //
|
||||
v2 - Vector2::new(0.0, 45.0),
|
||||
v3 - Vector2::new(0.0, 45.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
|
||||
let color = COLOR_CYAN;
|
||||
let v1 = Vector2::new(265.0, 74.0);
|
||||
let v2 = Vector2::new(265.0, 37.0);
|
||||
let v3 = Vector2::new(231.0, 37.0);
|
||||
screen.triangle_2d(&Solid { position: [v1, v2, v3], color });
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
v1 - Vector2::new(-70.0, 0.0), //
|
||||
v2 - Vector2::new(-70.0, 0.0),
|
||||
v3 - Vector2::new(-70.0, 0.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
v1 - Vector2::new(0.0, 55.0), //
|
||||
v2 - Vector2::new(0.0, 55.0),
|
||||
v3 - Vector2::new(0.0, 55.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
|
||||
let color = COLOR_RED;
|
||||
let v1 = Vector2::new(33.0, 108.0);
|
||||
let v2 = Vector2::new(33.0, 137.0);
|
||||
let v3 = Vector2::new(59.0, 122.0);
|
||||
screen.triangle_2d(&Solid { position: [v1, v2, v3], color });
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
v1 - Vector2::new(45.0, 0.0), //
|
||||
v2 - Vector2::new(45.0, 0.0),
|
||||
v3 - Vector2::new(45.0, 0.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
|
||||
let color = COLOR_MAGENTA;
|
||||
let v1 = Vector2::new(161.0, 132.0);
|
||||
let v2 = Vector2::new(145.0, 92.0);
|
||||
let v3 = Vector2::new(120.0, 115.0);
|
||||
screen.triangle_2d(&Solid { position: [v1, v2, v3], color });
|
||||
|
||||
let color = COLOR_BROWN;
|
||||
let v1 = Vector2::new(237.0, 120.0);
|
||||
let v2 = Vector2::new(267.0, 136.0);
|
||||
let v3 = Vector2::new(267.0, 105.0);
|
||||
screen.triangle_2d(&Solid { position: [v1, v2, v3], color });
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
v1 - Vector2::new(-70.0, 0.0), //
|
||||
v2 - Vector2::new(-70.0, 0.0),
|
||||
v3 - Vector2::new(-70.0, 0.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
|
||||
let color = COLOR_LIGHT_GRAY;
|
||||
let v1 = Vector2::new(29.0, 194.0);
|
||||
let v2 = Vector2::new(62.0, 194.0);
|
||||
let v3 = Vector2::new(29.0, 163.0);
|
||||
screen.triangle_2d(&Solid { position: [v1, v2, v3], color });
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
v1 - Vector2::new(45.0, 0.0), //
|
||||
v2 - Vector2::new(45.0, 0.0),
|
||||
v3 - Vector2::new(45.0, 0.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
v1 - Vector2::new(0.0, -55.0), //
|
||||
v2 - Vector2::new(0.0, -55.0),
|
||||
v3 - Vector2::new(0.0, -55.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
|
||||
let color = COLOR_DARK_GRAY;
|
||||
let v1 = Vector2::new(130.0, 164.0);
|
||||
let v2 = Vector2::new(155.0, 190.0);
|
||||
let v3 = Vector2::new(177.0, 164.0);
|
||||
screen.triangle_2d(&Solid { position: [v1, v2, v3], color });
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
v1 - Vector2::new(0.0, -60.0), //
|
||||
v2 - Vector2::new(0.0, -60.0),
|
||||
v3 - Vector2::new(0.0, -60.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
|
||||
let color = COLOR_BRIGHT_BLUE;
|
||||
let v1 = Vector2::new(235.0, 193.0);
|
||||
let v2 = Vector2::new(269.0, 193.0);
|
||||
let v3 = Vector2::new(269.0, 163.0);
|
||||
screen.triangle_2d(&Solid { position: [v1, v2, v3], color });
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
v1 - Vector2::new(-70.0, 0.0), //
|
||||
v2 - Vector2::new(-70.0, 0.0),
|
||||
v3 - Vector2::new(-70.0, 0.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
v1 - Vector2::new(0.0, -60.0), //
|
||||
v2 - Vector2::new(0.0, -60.0),
|
||||
v3 - Vector2::new(0.0, -60.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
|
||||
// totally off screen
|
||||
|
||||
let color = COLOR_BRIGHT_RED;
|
||||
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
Vector2::new(-32.0, 36.0), //
|
||||
Vector2::new(-32.0, 63.0),
|
||||
Vector2::new(-73.0, 36.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
Vector2::new(265.0, -26.0), //
|
||||
Vector2::new(265.0, -63.0),
|
||||
Vector2::new(231.0, -63.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
Vector2::new(29.0, 294.0), //
|
||||
Vector2::new(62.0, 294.0),
|
||||
Vector2::new(29.0, 263.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
Vector2::new(335.0, 193.0), //
|
||||
Vector2::new(369.0, 193.0),
|
||||
Vector2::new(369.0, 163.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
|
||||
// wrong vertex winding (clockwise instead of counter-clockwise)
|
||||
|
||||
let color = COLOR_BRIGHT_RED;
|
||||
|
||||
screen.triangle_2d(&Solid {
|
||||
position: [
|
||||
Vector2::new(120.0, 115.0), //
|
||||
Vector2::new(145.0, 92.0),
|
||||
Vector2::new(161.0, 132.0),
|
||||
],
|
||||
color,
|
||||
});
|
||||
|
||||
let path = reference_file(Path::new("triangle_2d.png"));
|
||||
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
|
||||
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
enum TriangleType {
|
||||
Solid = 0,
|
||||
SolidBlended = 1,
|
||||
SolidMultiColorBlended = 2,
|
||||
SolidTextured = 3,
|
||||
SolidTexturedColored = 4,
|
||||
SolidTexturedColoredBlended = 5,
|
||||
SolidTexturedMultiColored = 6,
|
||||
SolidTexturedMultiColoredBlended = 7,
|
||||
SolidTexturedTinted = 8,
|
||||
SolidTexturedBlended = 9,
|
||||
}
|
||||
|
||||
fn get_quad(
|
||||
mode: TriangleType,
|
||||
texture: Option<&RgbaBitmap>,
|
||||
transform: Matrix3x3,
|
||||
top_left: Vector2,
|
||||
top_right: Vector2,
|
||||
bottom_left: Vector2,
|
||||
bottom_right: Vector2,
|
||||
) -> [RgbaTriangle2d; 2] {
|
||||
let top_left = transform * top_left;
|
||||
let top_right = transform * top_right;
|
||||
let bottom_left = transform * bottom_left;
|
||||
let bottom_right = transform * bottom_right;
|
||||
|
||||
let positions_1 = [top_left, bottom_left, bottom_right];
|
||||
let positions_2 = [top_left, bottom_right, top_right];
|
||||
let texcoords_1 = [Vector2::new(0.0, 0.0), Vector2::new(0.0, 1.0), Vector2::new(1.0, 1.0)];
|
||||
let texcoords_2 = [Vector2::new(0.0, 0.0), Vector2::new(1.0, 1.0), Vector2::new(1.0, 0.0)];
|
||||
let single_color = to_argb32(128, 255, 0, 255);
|
||||
let colors_1 = [to_rgb32(255, 0, 0), to_rgb32(0, 255, 0), to_rgb32(0, 0, 255)];
|
||||
let colors_2 = [to_rgb32(255, 0, 0), to_rgb32(0, 0, 255), to_rgb32(255, 255, 255)];
|
||||
let tint_color = to_argb32(128, 192, 47, 160);
|
||||
|
||||
match mode {
|
||||
TriangleType::Solid => [
|
||||
RgbaTriangle2d::Solid { position: positions_1, color: to_rgb32(255, 0, 255) },
|
||||
RgbaTriangle2d::Solid { position: positions_2, color: to_rgb32(255, 0, 255) },
|
||||
],
|
||||
TriangleType::SolidBlended => [
|
||||
RgbaTriangle2d::SolidBlended { position: positions_1, color: single_color, blend: BlendFunction::Blend },
|
||||
RgbaTriangle2d::SolidBlended { position: positions_2, color: single_color, blend: BlendFunction::Blend },
|
||||
],
|
||||
TriangleType::SolidMultiColorBlended => [
|
||||
RgbaTriangle2d::SolidMultiColorBlended {
|
||||
position: positions_1,
|
||||
color: colors_1,
|
||||
blend: BlendFunction::BlendSourceWithAlpha(128),
|
||||
},
|
||||
RgbaTriangle2d::SolidMultiColorBlended {
|
||||
position: positions_2,
|
||||
color: colors_2,
|
||||
blend: BlendFunction::BlendSourceWithAlpha(128),
|
||||
},
|
||||
],
|
||||
TriangleType::SolidTextured => [
|
||||
RgbaTriangle2d::SolidTextured { position: positions_1, texcoord: texcoords_1, bitmap: &texture.unwrap() },
|
||||
RgbaTriangle2d::SolidTextured { position: positions_2, texcoord: texcoords_2, bitmap: &texture.unwrap() },
|
||||
],
|
||||
TriangleType::SolidTexturedColored => [
|
||||
RgbaTriangle2d::SolidTexturedColored {
|
||||
position: positions_1,
|
||||
texcoord: texcoords_1,
|
||||
color: single_color,
|
||||
bitmap: &texture.unwrap(),
|
||||
},
|
||||
RgbaTriangle2d::SolidTexturedColored {
|
||||
position: positions_2,
|
||||
texcoord: texcoords_2,
|
||||
color: single_color,
|
||||
bitmap: &texture.unwrap(),
|
||||
},
|
||||
],
|
||||
TriangleType::SolidTexturedColoredBlended => [
|
||||
RgbaTriangle2d::SolidTexturedColoredBlended {
|
||||
position: positions_1,
|
||||
texcoord: texcoords_1,
|
||||
color: single_color,
|
||||
bitmap: &texture.unwrap(),
|
||||
blend: BlendFunction::BlendSourceWithAlpha(128),
|
||||
},
|
||||
RgbaTriangle2d::SolidTexturedColoredBlended {
|
||||
position: positions_2,
|
||||
texcoord: texcoords_2,
|
||||
color: single_color,
|
||||
bitmap: &texture.unwrap(),
|
||||
blend: BlendFunction::BlendSourceWithAlpha(128),
|
||||
},
|
||||
],
|
||||
TriangleType::SolidTexturedMultiColored => [
|
||||
RgbaTriangle2d::SolidTexturedMultiColored {
|
||||
position: positions_1,
|
||||
texcoord: texcoords_1,
|
||||
color: colors_1,
|
||||
bitmap: &texture.unwrap(),
|
||||
},
|
||||
RgbaTriangle2d::SolidTexturedMultiColored {
|
||||
position: positions_2,
|
||||
texcoord: texcoords_2,
|
||||
color: colors_2,
|
||||
bitmap: &texture.unwrap(),
|
||||
},
|
||||
],
|
||||
TriangleType::SolidTexturedMultiColoredBlended => [
|
||||
RgbaTriangle2d::SolidTexturedMultiColoredBlended {
|
||||
position: positions_1,
|
||||
texcoord: texcoords_1,
|
||||
color: colors_1,
|
||||
bitmap: &texture.unwrap(),
|
||||
blend: BlendFunction::BlendSourceWithAlpha(192),
|
||||
},
|
||||
RgbaTriangle2d::SolidTexturedMultiColoredBlended {
|
||||
position: positions_2,
|
||||
texcoord: texcoords_2,
|
||||
color: colors_2,
|
||||
bitmap: &texture.unwrap(),
|
||||
blend: BlendFunction::BlendSourceWithAlpha(192),
|
||||
},
|
||||
],
|
||||
TriangleType::SolidTexturedTinted => [
|
||||
RgbaTriangle2d::SolidTexturedTinted {
|
||||
position: positions_1,
|
||||
texcoord: texcoords_1,
|
||||
bitmap: &texture.unwrap(),
|
||||
tint: tint_color,
|
||||
},
|
||||
RgbaTriangle2d::SolidTexturedTinted {
|
||||
position: positions_2,
|
||||
texcoord: texcoords_2,
|
||||
bitmap: &texture.unwrap(),
|
||||
tint: tint_color,
|
||||
},
|
||||
],
|
||||
TriangleType::SolidTexturedBlended => [
|
||||
RgbaTriangle2d::SolidTexturedBlended {
|
||||
position: positions_1,
|
||||
texcoord: texcoords_1,
|
||||
bitmap: &texture.unwrap(),
|
||||
blend: BlendFunction::BlendSourceWithAlpha(128),
|
||||
},
|
||||
RgbaTriangle2d::SolidTexturedBlended {
|
||||
position: positions_2,
|
||||
texcoord: texcoords_2,
|
||||
bitmap: &texture.unwrap(),
|
||||
blend: BlendFunction::BlendSourceWithAlpha(128),
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[test]
|
||||
fn triangle_2d_solid_blended() {
|
||||
let mut screen = setup_for_blending();
|
||||
|
||||
let top_left = Vector2::new(0.0, 0.0);
|
||||
let top_right = Vector2::new(32.0, 0.0);
|
||||
let bottom_left = Vector2::new(0.0, 32.0);
|
||||
let bottom_right = Vector2::new(32.0, 32.0);
|
||||
|
||||
let rotate = Matrix3x3::new_2d_rotation(RADIANS_45);
|
||||
let scale = Matrix3x3::new_2d_scaling(2.0, 2.0);
|
||||
|
||||
let mode = TriangleType::SolidBlended;
|
||||
|
||||
let triangles = get_quad(mode, None, Matrix3x3::new_2d_translation(40.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, None, scale * Matrix3x3::new_2d_translation(200.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, None, scale * rotate * Matrix3x3::new_2d_translation(120.0, 120.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let path = reference_file(Path::new("triangle_2d_solid_blended.png"));
|
||||
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
|
||||
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[test]
|
||||
fn triangle_2d_solid_multicolor_blended() {
|
||||
let mut screen = setup_for_blending();
|
||||
|
||||
let top_left = Vector2::new(0.0, 0.0);
|
||||
let top_right = Vector2::new(32.0, 0.0);
|
||||
let bottom_left = Vector2::new(0.0, 32.0);
|
||||
let bottom_right = Vector2::new(32.0, 32.0);
|
||||
|
||||
let rotate = Matrix3x3::new_2d_rotation(RADIANS_45);
|
||||
let scale = Matrix3x3::new_2d_scaling(2.0, 2.0);
|
||||
|
||||
let mode = TriangleType::SolidMultiColorBlended;
|
||||
|
||||
let triangles = get_quad(mode, None, Matrix3x3::new_2d_translation(40.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, None, scale * Matrix3x3::new_2d_translation(200.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, None, scale * rotate * Matrix3x3::new_2d_translation(120.0, 120.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let path = reference_file(Path::new("triangle_2d_solid_multicolor_blended.png"));
|
||||
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
|
||||
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[test]
|
||||
fn triangle_2d_solid_textured() {
|
||||
let mut screen = setup();
|
||||
screen.clear(LIGHTER_BACKGROUND);
|
||||
|
||||
let texture = generate_bitmap(32, 32);
|
||||
|
||||
let top_left = Vector2::new(0.0, 0.0);
|
||||
let top_right = Vector2::new(32.0, 0.0);
|
||||
let bottom_left = Vector2::new(0.0, 32.0);
|
||||
let bottom_right = Vector2::new(32.0, 32.0);
|
||||
|
||||
let rotate = Matrix3x3::new_2d_rotation(RADIANS_45);
|
||||
let scale = Matrix3x3::new_2d_scaling(2.0, 2.0);
|
||||
|
||||
let mode = TriangleType::SolidTextured;
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), Matrix3x3::new_2d_translation(40.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * Matrix3x3::new_2d_translation(200.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * rotate * Matrix3x3::new_2d_translation(120.0, 120.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let path = reference_file(Path::new("triangle_2d_solid_textured.png"));
|
||||
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
|
||||
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[test]
|
||||
fn triangle_2d_solid_textured_colored() {
|
||||
let mut screen = setup();
|
||||
screen.clear(LIGHTER_BACKGROUND);
|
||||
|
||||
let texture = generate_bitmap(32, 32);
|
||||
|
||||
let top_left = Vector2::new(0.0, 0.0);
|
||||
let top_right = Vector2::new(32.0, 0.0);
|
||||
let bottom_left = Vector2::new(0.0, 32.0);
|
||||
let bottom_right = Vector2::new(32.0, 32.0);
|
||||
|
||||
let rotate = Matrix3x3::new_2d_rotation(RADIANS_45);
|
||||
let scale = Matrix3x3::new_2d_scaling(2.0, 2.0);
|
||||
|
||||
let mode = TriangleType::SolidTexturedColored;
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), Matrix3x3::new_2d_translation(40.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * Matrix3x3::new_2d_translation(200.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * rotate * Matrix3x3::new_2d_translation(120.0, 120.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let path = reference_file(Path::new("triangle_2d_solid_textured_colored.png"));
|
||||
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
|
||||
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[test]
|
||||
fn triangle_2d_solid_textured_colored_blended() {
|
||||
let mut screen = setup_for_blending();
|
||||
|
||||
let texture = generate_bitmap(32, 32);
|
||||
|
||||
let top_left = Vector2::new(0.0, 0.0);
|
||||
let top_right = Vector2::new(32.0, 0.0);
|
||||
let bottom_left = Vector2::new(0.0, 32.0);
|
||||
let bottom_right = Vector2::new(32.0, 32.0);
|
||||
|
||||
let rotate = Matrix3x3::new_2d_rotation(RADIANS_45);
|
||||
let scale = Matrix3x3::new_2d_scaling(2.0, 2.0);
|
||||
|
||||
let mode = TriangleType::SolidTexturedColoredBlended;
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), Matrix3x3::new_2d_translation(40.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * Matrix3x3::new_2d_translation(200.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * rotate * Matrix3x3::new_2d_translation(120.0, 120.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let path = reference_file(Path::new("triangle_2d_solid_textured_colored_blended.png"));
|
||||
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
|
||||
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[test]
|
||||
fn triangle_2d_solid_textured_multicolored() {
|
||||
let mut screen = setup();
|
||||
screen.clear(LIGHTER_BACKGROUND);
|
||||
|
||||
let texture = generate_bitmap(32, 32);
|
||||
|
||||
let top_left = Vector2::new(0.0, 0.0);
|
||||
let top_right = Vector2::new(32.0, 0.0);
|
||||
let bottom_left = Vector2::new(0.0, 32.0);
|
||||
let bottom_right = Vector2::new(32.0, 32.0);
|
||||
|
||||
let rotate = Matrix3x3::new_2d_rotation(RADIANS_45);
|
||||
let scale = Matrix3x3::new_2d_scaling(2.0, 2.0);
|
||||
|
||||
let mode = TriangleType::SolidTexturedMultiColored;
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), Matrix3x3::new_2d_translation(40.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * Matrix3x3::new_2d_translation(200.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * rotate * Matrix3x3::new_2d_translation(120.0, 120.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let path = reference_file(Path::new("triangle_2d_solid_textured_multicolored.png"));
|
||||
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
|
||||
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[test]
|
||||
fn triangle_2d_solid_textured_multicolored_blended() {
|
||||
let mut screen = setup_for_blending();
|
||||
|
||||
let texture = generate_bitmap(32, 32);
|
||||
|
||||
let top_left = Vector2::new(0.0, 0.0);
|
||||
let top_right = Vector2::new(32.0, 0.0);
|
||||
let bottom_left = Vector2::new(0.0, 32.0);
|
||||
let bottom_right = Vector2::new(32.0, 32.0);
|
||||
|
||||
let rotate = Matrix3x3::new_2d_rotation(RADIANS_45);
|
||||
let scale = Matrix3x3::new_2d_scaling(2.0, 2.0);
|
||||
|
||||
let mode = TriangleType::SolidTexturedMultiColoredBlended;
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), Matrix3x3::new_2d_translation(40.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * Matrix3x3::new_2d_translation(200.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * rotate * Matrix3x3::new_2d_translation(120.0, 120.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let path = reference_file(Path::new("triangle_2d_solid_textured_multicolored_blended.png"));
|
||||
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
|
||||
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[test]
|
||||
fn triangle_2d_solid_textured_tinted() {
|
||||
let mut screen = setup();
|
||||
screen.clear(LIGHTER_BACKGROUND);
|
||||
|
||||
let texture = generate_bitmap(32, 32);
|
||||
|
||||
let top_left = Vector2::new(0.0, 0.0);
|
||||
let top_right = Vector2::new(32.0, 0.0);
|
||||
let bottom_left = Vector2::new(0.0, 32.0);
|
||||
let bottom_right = Vector2::new(32.0, 32.0);
|
||||
|
||||
let rotate = Matrix3x3::new_2d_rotation(RADIANS_45);
|
||||
let scale = Matrix3x3::new_2d_scaling(2.0, 2.0);
|
||||
|
||||
let mode = TriangleType::SolidTexturedTinted;
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), Matrix3x3::new_2d_translation(40.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * Matrix3x3::new_2d_translation(200.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * rotate * Matrix3x3::new_2d_translation(120.0, 120.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let path = reference_file(Path::new("triangle_2d_solid_textured_tinted.png"));
|
||||
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
|
||||
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
#[test]
|
||||
fn triangle_2d_solid_textured_blended() {
|
||||
let mut screen = setup_for_blending();
|
||||
|
||||
let texture = generate_bitmap(32, 32);
|
||||
|
||||
let top_left = Vector2::new(0.0, 0.0);
|
||||
let top_right = Vector2::new(32.0, 0.0);
|
||||
let bottom_left = Vector2::new(0.0, 32.0);
|
||||
let bottom_right = Vector2::new(32.0, 32.0);
|
||||
|
||||
let rotate = Matrix3x3::new_2d_rotation(RADIANS_45);
|
||||
let scale = Matrix3x3::new_2d_scaling(2.0, 2.0);
|
||||
|
||||
let mode = TriangleType::SolidTexturedBlended;
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), Matrix3x3::new_2d_translation(40.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * Matrix3x3::new_2d_translation(200.0, 40.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let triangles = get_quad(mode, Some(&texture), scale * rotate * Matrix3x3::new_2d_translation(120.0, 120.0), top_left, top_right, bottom_left, bottom_right);
|
||||
screen.triangle_list_2d(&triangles);
|
||||
|
||||
let path = reference_file(Path::new("triangle_2d_solid_textured_blended.png"));
|
||||
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
|
||||
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
|
||||
}
|
||||
|
|
BIN
ggdt/tests/ref/rgba/blend_function_multiplied_blend.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
ggdt/tests/ref/rgba/triangle_2d.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
ggdt/tests/ref/rgba/triangle_2d_solid_blended.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
ggdt/tests/ref/rgba/triangle_2d_solid_multicolor_blended.png
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
ggdt/tests/ref/rgba/triangle_2d_solid_textured.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
ggdt/tests/ref/rgba/triangle_2d_solid_textured_blended.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
ggdt/tests/ref/rgba/triangle_2d_solid_textured_colored.png
Normal file
After Width: | Height: | Size: 2 KiB |
After Width: | Height: | Size: 4.6 KiB |
BIN
ggdt/tests/ref/rgba/triangle_2d_solid_textured_multicolored.png
Normal file
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 16 KiB |
BIN
ggdt/tests/ref/rgba/triangle_2d_solid_textured_tinted.png
Normal file
After Width: | Height: | Size: 2.1 KiB |