Plotting More Than 16 Colors


Pro-SiMPLE has only 16 standard colors available for displaying information:

Notice, for example, that there are only two different shades of red (color=4 and color=12). So how is it possible to display more than two shades of red?

If we look at a magnified view of the five "red" samples shown above, we see that each of the the new shades of red is actually a tiny "checker board" arrangement of two different standard color pixels:

When viewed from afar, each of these tiny checker board patterns appears to blend into a solid color (which we call the "effective" color).

Since Pro-SiMPLE has 16 different standard colors with which to work, there are a total of 256 such effective colors that it can produce:

However, since the result of "checker-boarding" color A with color B is virtually indistinguishable from "checker-boarding" color B with color A, there are (at most) only 136 different effective colors. (I.e., the upper-right half of the above color grid is essentially a mirror image the lower-left half.)

As an application of this checker board technique, let's write a short task that will allow users to plot points whose effective color values range from 0-255:

            Task plot256 (Int x, Int y, Int color)
            If ((x+y)%2) put pixel (x, y, color)
            Else put pixel (x, y, color/16)
And, to try out the task, let's write a program that will display a portion of the Mandelbrot set:
            Pro-SiMPLE
            real=-0.77195; imag=-0.116
            increment=0.0000025
            graph on
            Do y=0,479
               r=real
               Do x=0,639
                  color=mandelbrot (r, imag, 256)
                  plot256 (x, y, color) @
                  r=r+increment
               Loop x
               imag=imag+increment
            Loop y
When we run the program (don't forget to include our plot256 task too!), the following image is generated:



  [ Webmaster | FAQ's | Home Page | Contact Us ]