[comp.windows.x] Re^2: 4x4 Dithering Patterns?

torbenm@freja.diku.dk (Torben Mogensen) (05/31/89)

jbm@eos.UUCP (Jeffrey Mulligan) writes:


>A simple way to do this without going to the library is to start with
>a small pattern:

>	0 2
>	3 1

>And double it in size by multiplying the original by four, repicating,
>and adding the elements of the original to each block:

>	times 4	            0  8
>			    12 4

>	replicate           0  8 0  8
>			    12 4 12 4
>			    0  8 0  8
>			    12 4 12 4

>			       +

>			    0 0 2 2
>			    0 0 2 2
>			    3 3 1 1
>			    3 3 1 1

>			       =

>			    0  8  2  10
>			    12 4  14 6
>			    3  11 1  9
>			    15 7  13 5


I have had good results with dithering based on magic squares.
The common sum in all rows, coloums and diagonals ensures that
all lines through the pattern will be filled at approximately
the same speed.

As an example, here is a 4x4 magic square:

			 0  6  9 15
			11 13  2  4
			 7  1 14  8
			12 10  5  3

The advantage of this over the above pattern is that there is
not the same tendency to generate throughgoing lines. With 6 dots
filled the magic square gives the pattern on the left, whereas
the other dithering gives the one on the right:

		X   X   X   		X X X X X X 
		  XX  XX  XX		 X   X   X  
		 X   X   X  		X X X X X X 
		  XX  XX  XX		   X   X   X
		X   X   X   		X X X X X X 
		  XX  XX  XX		 X   X   X  
		 X   X   X  		X X X X X X 
		  XX  XX  XX		   X   X   X
		X   X   X   		X X X X X X 
		  XX  XX  XX		 X   X   X  
		 X   X   X  		X X X X X X 
		  XX  XX  XX		   X   X   X

Incidentially, the method presented above for constructing large
patterns from small can also be applied to magic squares.


	torbenm@diku.dk

	Torben Mogensen
	DIKU, University of Copenhagen, Denmark