File:Schachbrett-bw.png

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Schachbrett-bw.png(445 × 445 pixels, file size: 1 KB, MIME type: image/png)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
Deutsch: Schachbrettmuster schwarz-weiss
Date
Source Own work
Author User:BigBen666, src code by User:Adam majewski



Licensing

[edit]
Public domain I, the copyright holder of this work, release this work into the public domain. This applies worldwide.
In some countries this may not be legally possible; if so:
I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

cpp source code

[edit]
/*
[[:File:XOR_texture.png]]

*/


#include <fstream>





// http://fraktal.republika.pl/grid.html
int f( int x, int y, int Width){

 
  int g;
  int bx = (x / Width) % 2; // check if odd
  int by = (y / Width) % 2;

 if (bx == by ) 
    g= 0; 
    else g= 255;
    
 return g;
}





int main()
{
        const int side = 445; 
   int xMax = side;
int yMax = side;

int rows = 5; 
        int width = side / rows;    
        
	std::ofstream file;
	file.open("checkerboard.ppm");
	file << "P2" << xMax << ' ' <<  yMax << ' ' << " 255\n";
	for (int x = 0; x < xMax; x++)
		for (int y = 0; y < yMax; y++)
			file << f(x,y, width) << ' ';
	file.close();
	return 0;
}

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current12:24, 12 December 2005Thumbnail for version as of 12:24, 12 December 2005445 × 445 (1 KB)BigBen666 (talk | contribs)Schachbrettmuster schwarz-weiss

There are no pages that use this file.