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.

284 • Chapter 6: <strong>Programming</strong> with Maple Graphics> i=1..N[j] ) ), j=1..n ) ];> # Build new curves adding HUE color.> seq( CURVES( seq( [curves[j][i], curves[j][i+1]],> i=1..N[j]-1 ),> COLOUR(HUE, seq((curves[j][i][2]> - m[j])/(M[j] - m[j]),> i=1..N[j]-1)),> op(curveopts) ), j=1..n );> end proc:For example> c := CURVES( [ [0,0], [1,1], [2,2], [3,3] ],> [ [2,0], [2,1], [3,1] ] );c := CURVES([[0, 0], [1, 1], [2, 2], [3, 3]],[[2, 0], [2, 1], [3, 1]])> addCurvecolor( c );CURVES([[0, 0], [1, 1]], [[1, 1], [2, 2]], [[2, 2], [3, 3]],COLOUR(HUE , 0, 1 3 , 2 )), CURVES([[2, 0], [2, 1]],3[[2, 1], [3, 1]], COLOUR(HUE , 0, 1))You can then map such a procedure over all CURVES structures of anexisting plot structure to provide the desired coloring for each curve.> addcolor := proc( aplot )> local recolor;> recolor := x -> if op(0,x)=CURVES then> addCurvecolor(x)> else x end if;> map( recolor, aplot );> end proc:Try addcolor on a plot of sin(x) + cos(x).> p := plot( sin(x) + cos(x), x=0..2*Pi,> linestyle=2, thickness=3 ):> addcolor( p );

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

Saved successfully!

Ooh no, something went wrong!