Created
June 16, 2019 20:14
-
-
Save bbagwang/20dd67fe95a3b612cebebacd039829e6 to your computer and use it in GitHub Desktop.
Black to White Gradient PPM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
//Gradient 함수 | |
void Gradient(int size_x, int size_y) | |
{ | |
//파일 출력 | |
std::ofstream out("Gradient.ppm"); | |
//PPM 헤더 설정 | |
out << "P3\n" << size_x << " " << size_y << "\n" | |
<< "255\n"; | |
for (int y = 0; y < size_y; y++) | |
{ | |
for (int x = 0; x < size_x; x++) | |
{ | |
double opt; | |
opt = (x / (double)size_x)*255; | |
out << (int)opt << " " << (int)opt << " " << (int)opt << " "; | |
} | |
out << "\n"; | |
} | |
out.close(); | |
} | |
int main() { | |
Gradient(1024, 1024); | |
std::cout << "FINISHED" << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment