|
122 | 122 | auto g = double(j) / (image_height-1);
|
123 | 123 | auto b = 0;
|
124 | 124 |
|
125 |
| - int ir = static_cast<int>(255.999 * r); |
126 |
| - int ig = static_cast<int>(255.999 * g); |
127 |
| - int ib = static_cast<int>(255.999 * b); |
| 125 | + int ir = int(255.999 * r); |
| 126 | + int ig = int(255.999 * g); |
| 127 | + int ib = int(255.999 * b); |
128 | 128 |
|
129 | 129 | std::cout << ir << ' ' << ig << ' ' << ib << '\n';
|
130 | 130 | }
|
|
240 | 240 | auto g = double(j) / (image_height-1);
|
241 | 241 | auto b = 0;
|
242 | 242 |
|
243 |
| - int ir = static_cast<int>(255.999 * r); |
244 |
| - int ig = static_cast<int>(255.999 * g); |
245 |
| - int ib = static_cast<int>(255.999 * b); |
| 243 | + int ir = int(255.999 * r); |
| 244 | + int ig = int(255.999 * g); |
| 245 | + int ib = int(255.999 * b); |
246 | 246 |
|
247 | 247 | std::cout << ir << ' ' << ig << ' ' << ib << '\n';
|
248 | 248 | }
|
|
405 | 405 |
|
406 | 406 | void write_color(std::ostream &out, color pixel_color) {
|
407 | 407 | // Write the translated [0,255] value of each color component.
|
408 |
| - out << static_cast<int>(255.999 * pixel_color.x()) << ' ' |
409 |
| - << static_cast<int>(255.999 * pixel_color.y()) << ' ' |
410 |
| - << static_cast<int>(255.999 * pixel_color.z()) << '\n'; |
| 408 | + out << int(255.999 * pixel_color.x()) << ' ' |
| 409 | + << int(255.999 * pixel_color.y()) << ' ' |
| 410 | + << int(255.999 * pixel_color.z()) << '\n'; |
411 | 411 | }
|
412 | 412 |
|
413 | 413 | #endif
|
|
548 | 548 | int image_width = 400;
|
549 | 549 |
|
550 | 550 | // Calculate the image height, and ensure that it's at least 1.
|
551 |
| - int image_height = static_cast<int>(image_width / aspect_ratio); |
| 551 | + int image_height = int(image_width / aspect_ratio); |
552 | 552 | image_height = (image_height < 1) ? 1 : image_height;
|
553 | 553 |
|
554 | 554 | // Viewport widths less than one are ok since they are real valued.
|
555 | 555 | auto viewport_height = 2.0;
|
556 |
| - auto viewport_width = viewport_height * (static_cast<double>(image_width)/image_height); |
| 556 | + auto viewport_width = viewport_height * (double(image_width)/image_height); |
557 | 557 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
558 | 558 | [Listing [image-setup]: Rendered image setup]
|
559 | 559 |
|
|
634 | 634 | int image_width = 400;
|
635 | 635 |
|
636 | 636 | // Calculate the image height, and ensure that it's at least 1.
|
637 |
| - int image_height = static_cast<int>(image_width / aspect_ratio); |
| 637 | + int image_height = int(image_width / aspect_ratio); |
638 | 638 | image_height = (image_height < 1) ? 1 : image_height;
|
639 | 639 |
|
640 | 640 | // Camera
|
641 | 641 |
|
642 | 642 | auto focal_length = 1.0;
|
643 | 643 | auto viewport_height = 2.0;
|
644 |
| - auto viewport_width = viewport_height * (static_cast<double>(image_width)/image_height); |
| 644 | + auto viewport_width = viewport_height * (double(image_width)/image_height); |
645 | 645 | auto camera_center = point3(0, 0, 0);
|
646 | 646 |
|
647 | 647 | // Calculate the vectors across the horizontal and down the vertical viewport edges.
|
|
1426 | 1426 | int image_width = 400;
|
1427 | 1427 |
|
1428 | 1428 | // Calculate the image height, and ensure that it's at least 1.
|
1429 |
| - int image_height = static_cast<int>(image_width / aspect_ratio); |
| 1429 | + int image_height = int(image_width / aspect_ratio); |
1430 | 1430 | image_height = (image_height < 1) ? 1 : image_height;
|
1431 | 1431 |
|
1432 | 1432 |
|
|
1443 | 1443 |
|
1444 | 1444 | auto focal_length = 1.0;
|
1445 | 1445 | auto viewport_height = 2.0;
|
1446 |
| - auto viewport_width = viewport_height * (static_cast<double>(image_width)/image_height); |
| 1446 | + auto viewport_width = viewport_height * (double(image_width)/image_height); |
1447 | 1447 | auto camera_center = point3(0, 0, 0);
|
1448 | 1448 |
|
1449 | 1449 | // Calculate the vectors across the horizontal and down the vertical viewport edges.
|
|
1781 | 1781 | vec3 pixel_delta_v; // Offset to pixel below
|
1782 | 1782 |
|
1783 | 1783 | void initialize() {
|
1784 |
| - image_height = static_cast<int>(image_width / aspect_ratio); |
| 1784 | + image_height = int(image_width / aspect_ratio); |
1785 | 1785 | image_height = (image_height < 1) ? 1 : image_height;
|
1786 | 1786 |
|
1787 | 1787 | center = point3(0, 0, 0);
|
1788 | 1788 |
|
1789 | 1789 | // Determine viewport dimensions.
|
1790 | 1790 | auto focal_length = 1.0;
|
1791 | 1791 | auto viewport_height = 2.0;
|
1792 |
| - auto viewport_width = viewport_height * (static_cast<double>(image_width)/image_height); |
| 1792 | + auto viewport_width = viewport_height * (double(image_width)/image_height); |
1793 | 1793 |
|
1794 | 1794 | // Calculate the vectors across the horizontal and down the vertical viewport edges.
|
1795 | 1795 | auto viewport_u = vec3(viewport_width, 0, 0);
|
|
1986 | 1986 |
|
1987 | 1987 | // Write the translated [0,255] value of each color component.
|
1988 | 1988 | static const interval intensity(0.000, 0.999);
|
1989 |
| - out << static_cast<int>(256 * intensity.clamp(r)) << ' ' |
1990 |
| - << static_cast<int>(256 * intensity.clamp(g)) << ' ' |
1991 |
| - << static_cast<int>(256 * intensity.clamp(b)) << '\n'; |
| 1989 | + out << int(256 * intensity.clamp(r)) << ' ' |
| 1990 | + << int(256 * intensity.clamp(g)) << ' ' |
| 1991 | + << int(256 * intensity.clamp(b)) << '\n'; |
1992 | 1992 | }
|
1993 | 1993 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
1994 | 1994 | [Listing [write-color-clamped]: <kbd>[color.h]</kbd> The multi-sample write_color() function]
|
|
2632 | 2632 |
|
2633 | 2633 | // Write the translated [0,255] value of each color component.
|
2634 | 2634 | static const interval intensity(0.000, 0.999);
|
2635 |
| - out << static_cast<int>(256 * intensity.clamp(r)) << ' ' |
2636 |
| - << static_cast<int>(256 * intensity.clamp(g)) << ' ' |
2637 |
| - << static_cast<int>(256 * intensity.clamp(b)) << '\n'; |
| 2635 | + out << int(256 * intensity.clamp(r)) << ' ' |
| 2636 | + << int(256 * intensity.clamp(g)) << ' ' |
| 2637 | + << int(256 * intensity.clamp(b)) << '\n'; |
2638 | 2638 | }
|
2639 | 2639 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2640 | 2640 | [Listing [write-color-gamma]: <kbd>[color.h]</kbd> write_color(), with gamma correction]
|
|
3484 | 3484 | ...
|
3485 | 3485 |
|
3486 | 3486 | void initialize() {
|
3487 |
| - image_height = static_cast<int>(image_width / aspect_ratio); |
| 3487 | + image_height = int(image_width / aspect_ratio); |
3488 | 3488 | image_height = (image_height < 1) ? 1 : image_height;
|
3489 | 3489 |
|
3490 | 3490 | center = point3(0, 0, 0);
|
|
3496 | 3496 | auto h = tan(theta/2);
|
3497 | 3497 | auto viewport_height = 2 * h * focal_length;
|
3498 | 3498 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
|
3499 |
| - auto viewport_width = viewport_height * (static_cast<double>(image_width)/image_height); |
| 3499 | + auto viewport_width = viewport_height * (double(image_width)/image_height); |
3500 | 3500 |
|
3501 | 3501 | // Calculate the vectors across the horizontal and down the vertical viewport edges.
|
3502 | 3502 | auto viewport_u = vec3(viewport_width, 0, 0);
|
|
3621 | 3621 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
|
3622 | 3622 |
|
3623 | 3623 | void initialize() {
|
3624 |
| - image_height = static_cast<int>(image_width / aspect_ratio); |
| 3624 | + image_height = int(image_width / aspect_ratio); |
3625 | 3625 | image_height = (image_height < 1) ? 1 : image_height;
|
3626 | 3626 |
|
3627 | 3627 |
|
|
3636 | 3636 | auto theta = degrees_to_radians(vfov);
|
3637 | 3637 | auto h = tan(theta/2);
|
3638 | 3638 | auto viewport_height = 2 * h * focal_length;
|
3639 |
| - auto viewport_width = viewport_height * (static_cast<double>(image_width)/image_height); |
| 3639 | + auto viewport_width = viewport_height * (double(image_width)/image_height); |
3640 | 3640 |
|
3641 | 3641 |
|
3642 | 3642 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
|
|
3866 | 3866 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
|
3867 | 3867 |
|
3868 | 3868 | void initialize() {
|
3869 |
| - image_height = static_cast<int>(image_width / aspect_ratio); |
| 3869 | + image_height = int(image_width / aspect_ratio); |
3870 | 3870 | image_height = (image_height < 1) ? 1 : image_height;
|
3871 | 3871 |
|
3872 | 3872 | center = lookfrom;
|
|
3880 | 3880 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
|
3881 | 3881 | auto viewport_height = 2 * h * focus_dist;
|
3882 | 3882 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
|
3883 |
| - auto viewport_width = viewport_height * (static_cast<double>(image_width)/image_height); |
| 3883 | + auto viewport_width = viewport_height * (double(image_width)/image_height); |
3884 | 3884 |
|
3885 | 3885 | // Calculate the u,v,w unit basis vectors for the camera coordinate frame.
|
3886 | 3886 | w = unit_vector(lookfrom - lookat);
|
|
0 commit comments