Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- const int szer = 400; //szerokość
- const int wys = 400; // wysokosc
- const float wsp = 3.2; //3.2 ~=(szer+wys) / 255
- int i,j; //licznik pętli
- static unsigned char kolor [3]; //tablica kolorów
- FILE * file; //deskryptor pliku
- file = fopen("obraz.ppm", "wb"); //otwarcie pliku
- fprintf(file, "P6\n%d %d\n 255\n", szer, wys); //nagłówek
- for(j=0;i<wys;i++){
- for(j=0;j<szer;j++){
- kolor[0] = abs(j*j+i*i) % 255; //czerwone kółka
- kolor[1] = round(abs(i+j)/wsp); //zielony gradient - i+j - coraz mocniejszy kolor, 3.2 - żeby w obrazku mieścił się jeden gradient
- kolor[2] = (int)(abs(255-(i+j)/wsp)); //niebieski gradient od calosci odejmujemy i oraz j
- fwrite(kolor,1,3,file);
- }
- }
- fclose(file); //zamkniecie pliku
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement