From: <and...@us...> - 2009-12-07 21:26:18
|
Revision: 10700 http://plplot.svn.sourceforge.net/plplot/?rev=10700&view=rev Author: andrewross Date: 2009-12-07 21:26:09 +0000 (Mon, 07 Dec 2009) Log Message: ----------- Add octave support for plgradient and update octave examples 25 and 30 to use it. Modified Paths: -------------- trunk/bindings/octave/plplot_octave.h.in trunk/examples/octave/x25c.m trunk/examples/octave/x30c.m Modified: trunk/bindings/octave/plplot_octave.h.in =================================================================== --- trunk/bindings/octave/plplot_octave.h.in 2009-12-07 19:33:00 UTC (rev 10699) +++ trunk/bindings/octave/plplot_octave.h.in 2009-12-07 21:26:09 UTC (rev 10700) @@ -483,6 +483,7 @@ #define plglevel c_plglevel #define plgpage c_plgpage #define plgra c_plgra +#define plgradient c_plgradient #define plgriddata c_plgriddata #define plgspa c_plgspa #define plgstrm c_plgstrm @@ -932,6 +933,10 @@ void c_plgra( void ); //%name plgra +/* Draw gradient in polygon. */ + +void c_plgradient( PLINT n, PLFLT *x, PLFLT *y, PLFLT angle ); //%name plgradient //%input x(n), y(n) + void plgriddata( PLFLT *x, PLFLT *y, PLFLT *z, int npts, PLFLT *xg, int nptsx, PLFLT *yg, int nptsy, PLFLT **zg, int type, PLFLT data ); //%nowrap Modified: trunk/examples/octave/x25c.m =================================================================== --- trunk/examples/octave/x25c.m 2009-12-07 19:33:00 UTC (rev 10699) +++ trunk/examples/octave/x25c.m 2009-12-07 21:26:09 UTC (rev 10700) @@ -26,44 +26,50 @@ xextreme = [-120,120;-120,120;-120,120;-80,80;-220,-120;-20,20;-20,20;-80,80;20,120]; yextreme = [-120,120;20,120;-20,120;-20,120;-120,120;-120,120;-20,20;-80,80;-120,120]; - for j=0:3 - if ( j == 0 ) - ## Polygon 1: a diamond - x0 = [0;-100;0;100]; - y0 = [-100;0;100;0]; - npts = 4 ; - endif - if ( j == 1 ) -## Polygon 1: a diamond - reverse direction - x0 = [100;0;-100;0]; - y0 = [0;100;0;-100]; - npts = 4 ; - endif - if ( j == 2 ) -## Polygon 2: a square with punctures - x0 = [-100;-100;80;-100;-100;-80;0;80;100;100]; - y0 = [-100;-80;0;80;100;100;80;100;100;-100]; - npts = 10 ; - endif - if ( j == 3 ) -## Polygon 2: a square with punctures - reversed direction - x0 = [100;100;80;0;-80;-100;-100;80;-100;-100]; - y0 = [-100;100;100;80;100;100;80;0;-80;-100]; - npts = 10 ; - endif - for i = 1:9 - pladv(0); - plvsta; - plwind(xextreme(i,1), xextreme(i,2), yextreme(i,1), yextreme(i,2)); - - plcol0(2) ; - plbox("bc", 1.0, 0, "bcnv", 10.0, 0); - plcol0(1) ; - plpsty(0) ; - plfill(x0,y0) ; - plcol0(2) ; - pllsty(1) ; - plline(x0,y0) ; + for k=0:1 + for j=0:3 + if ( j == 0 ) + ## Polygon 1: a diamond + x0 = [0;-100;0;100]; + y0 = [-100;0;100;0]; + npts = 4 ; + endif + if ( j == 1 ) + ## Polygon 1: a diamond - reverse direction + x0 = [100;0;-100;0]; + y0 = [0;100;0;-100]; + npts = 4 ; + endif + if ( j == 2 ) + ## Polygon 2: a square with punctures + x0 = [-100;-100;80;-100;-100;-80;0;80;100;100]; + y0 = [-100;-80;0;80;100;100;80;100;100;-100]; + npts = 10 ; + endif + if ( j == 3 ) + ## Polygon 2: a square with punctures - reversed direction + x0 = [100;100;80;0;-80;-100;-100;80;-100;-100]; + y0 = [-100;100;100;80;100;100;80;0;-80;-100]; + npts = 10 ; + endif + for i = 1:9 + pladv(0); + plvsta; + plwind(xextreme(i,1), xextreme(i,2), yextreme(i,1), yextreme(i,2)); + + plcol0(2) ; + plbox("bc", 1.0, 0, "bcnv", 10.0, 0); + plcol0(1) ; + plpsty(0) ; + if (k == 0) + plfill(x0,y0) ; + else + plgradient(x0,y0,45.) ; + endif + plcol0(2) ; + pllsty(1) ; + plline(x0,y0) ; + endfor endfor endfor Modified: trunk/examples/octave/x30c.m =================================================================== --- trunk/examples/octave/x30c.m 2009-12-07 19:33:00 UTC (rev 10699) +++ trunk/examples/octave/x30c.m 2009-12-07 21:26:09 UTC (rev 10700) @@ -130,21 +130,19 @@ plscmap1n(128); plscmap1la(1, pos', rcoord', gcoord', bcoord', acoord', rev'); - ## Create a 2 x 2 array that contains the z values (0.0 to 1.0) that will - ## used for the shade plot. plshades will use linear interpolation to - ## calculate the z values of all the intermediate points in this - ## array. - z = zeros(2,2); - z(1,2) = 1.0; - z(2,2) = 1.0; + ## Use that cmap1 to create a transparent red gradient for the whole + ## window. + px(1) = 0.; + px(2) = 1.; + px(3) = 1.; + px(4) = 0.; - ## Set the color levels array. These levels are also between 0.0 and - ## 1.0 - clevel = 0.01 * (0:100); + py(1) = 0.; + py(2) = 0.; + py(3) = 1.; + py(4) = 1.; - ## Draw the shade plot with zmin = 0.0, zmax = 1.0 and x and y - ## coordinate ranges such that it fills the entire plotting area. - plshades(z, 0.0, 1.0, 0.0, 1.0, clevel', 0, -1, 2, 1); + plgradient( px', py', 90. ); plend1(); endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |