11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

280 • Chapter 6: <strong>Programming</strong> with Maple Graphics10.80.60.40.200.5 1 1.5 2The three RGB values must be numbers between 0 and 1.Generating Color TablesThe following procedure generates an m × n color table of RGB values.Example The colormap procedure returns a sequence of two elements:a POLYGONS structure and a TITLE.> colormap := proc(m, n, B)> local i, j, points, colors, flatten;> # points = sequence of corners for rectangles> points := seq( seq( evalf(> [ [i/m, j/n], [(i+1)/m, j/n],> [(i+1)/m, (j+1)/n], [i/m, (j+1)/n] ]> ), i=0..m-1 ), j=0..n-1 ):> # colors = listlist of RGB color values> colors := [seq( seq( [i/(m-1), j/(n-1), B],> i=0..m-1 ), j=0..n-1 )] ;> # flatten turns the colors listlist into a sequence> flatten := a -> op( map(op, a) );> POLYGONS( points,> COLOUR(RGB, flatten(colors) ) ),> TITLE( cat( "Blue=", convert(B, string) ) );> end proc:Here is a 10 × 10 table of colors; the blue component is 0.> PLOT( colormap(10, 10, 0) );

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!