| 9 | { |
| 10 | |
| 11 | TEST( MRMesh, Pdf ) |
| 12 | { |
| 13 | UniqueTemporaryFolder pathFolder; |
| 14 | Pdf pdfTest; |
| 15 | pdfTest.addText( "Test Title", true ); |
| 16 | pdfTest.addText( "Test text" |
| 17 | "\nstring 1" |
| 18 | "\nstring 2" ); |
| 19 | |
| 20 | constexpr float scaleFactor = 17.f / 6.f; // ~2.8(3) |
| 21 | constexpr float pageWidth = 595.f; |
| 22 | constexpr float borderFieldLeft = 20 * scaleFactor; |
| 23 | constexpr float borderFieldRight = pageWidth - 10 * scaleFactor; |
| 24 | constexpr float pageWorkWidth = borderFieldRight - borderFieldLeft; |
| 25 | |
| 26 | const int colorMapSizeX = int( pageWorkWidth ); |
| 27 | const int colorMapSizeY = int( 10 * scaleFactor ); |
| 28 | std::vector<Color> pixels( colorMapSizeX * colorMapSizeY ); |
| 29 | Color colorLeft = Color::blue(); |
| 30 | Color colorRight = Color::red(); |
| 31 | for ( int i = 0; i < colorMapSizeX; ++i ) |
| 32 | { |
| 33 | for ( int j = 0; j < colorMapSizeY; ++j ) |
| 34 | { |
| 35 | const float c = float( i ) / colorMapSizeX; |
| 36 | pixels[i + j * colorMapSizeX] = lerp( colorLeft, colorRight, c ); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | auto colorMapPath = pathFolder / std::filesystem::path( "color_map.png" ); |
| 41 | auto res = ImageSave::toAnySupportedFormat( { pixels, Vector2i( colorMapSizeX, colorMapSizeY ) }, colorMapPath ); |
| 42 | |
| 43 | pdfTest.addImageFromFile( colorMapPath, { .size = {-1, 0}, .caption = "test image", .uniformScale = Pdf::ImageParams::UniformScale::FromWidth } ); |
| 44 | pdfTest.saveToFile( pathFolder / std::filesystem::path( "test.pdf" ) ); |
| 45 | } |
| 46 | |
| 47 | } //namespace MR |
| 48 |
nothing calls this directly
no test coverage detected