11.07.2015 Views

Advanced Programming Guide

Advanced Programming Guide

Advanced Programming Guide

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

plot3d( p, -3..3, -3..3, color=q );6.9 <strong>Programming</strong> with Color • 279Although usually less convenient, you can also specify the color attributesat the lower level of graphics primitives. At the lowest level, youcan color a graphical object by including a COLOUR function as one of theoptions inside the object.> PLOT( POLYGONS( [ [0,0], [1,0], [1,1] ],> [ [1,0], [1,1], [2,1], [2,0] ],> COLOUR(RGB, 1/2, 1/3, 1/4 ) ) );10.80.60.40.200.5 1 1.5 2You can use different colors for each polygon via eitherPLOT( POLYGONS( P1, ... , Pn ,COLOUR(RGB, p1, ..., pn)) )orPLOT( POLYGONS( P1, COLOUR(RGB, p1) ), ... ,POLYGONS( Pn, COLOUR(RGB, pn)) )Thus, the following two PLOT structures represent the same picture ofa red and a green triangle.> PLOT( POLYGONS( [ [0,0], [1,1], [2,0] ],> COLOUR( RGB, 1, 0, 0 ) ),> POLYGONS( [ [0,0], [1,1], [0,1] ],> COLOUR( RGB, 0, 1, 0 ) ) );> PLOT( POLYGONS( [ [0,0], [1,1], [2,0] ],> [ [0,0], [1,1], [0,1] ],> COLOUR( RGB, 1, 0, 0, 0, 1, 0 ) ) );

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

Saved successfully!

Ooh no, something went wrong!