Search
 
SCRIPT & CODE EXAMPLE
 

C

write a ppm image

#include <iostream>

int main() {

    // Image

    const int image_width = 256;
    const int image_height = 256;

    // Render

    std::cout << "P3
" << image_width << ' ' << image_height << "
255
";

    for (int j = image_height-1; j >= 0; --j) {
        for (int i = 0; i < image_width; ++i) {
            auto r = double(i) / (image_width-1);
            auto g = double(j) / (image_height-1);
            auto b = 0.25;

            int ir = static_cast<int>(255.999 * r);
            int ig = static_cast<int>(255.999 * g);
            int ib = static_cast<int>(255.999 * b);

            std::cout << ir << ' ' << ig << ' ' << ib << '
';
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
C :: c refresher 
C :: how much larger integer i can input in c language? 
C :: os.listdir to array 
C :: how to make random string in c 
C :: cannot reach esp8266 via udp while he is running with a static ip 
C :: too many arg 
C :: how to make play a song javascript 
C :: Defining a macro in a header file 
C :: string once declared 
C :: passing an array of unspecified number of variables to a function 
C :: countoddevenDifference 
C :: Write a c program to add two numbers without using addition operator. 
C :: sort linked list c 
C :: C printf Declaration 
C :: C Program to calculate the total execution time of a program 
Dart :: round corner of alertdialog flutter 
Dart :: asset image in circle avatar flutter 
Dart :: how to change input text color in flutter 
Dart :: reverse srring in dart 
Dart :: Container border left 
Dart :: detect os in flutter 
Dart :: textfield height flutter 
Dart :: flutter delete chip 
Dart :: dart random password generator 
Dart :: flutter snackbar replacement 
Dart :: flutter floting action button elevation 
Dart :: dart regex for url 
Dart :: dart typeof 
Dart :: flutter appbar leading icon 
Dart :: dart store unique values 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =