From: <and...@us...> - 2009-12-07 21:43:00
|
Revision: 10701 http://plplot.svn.sourceforge.net/plplot/?rev=10701&view=rev Author: andrewross Date: 2009-12-07 21:42:50 +0000 (Mon, 07 Dec 2009) Log Message: ----------- Add plgradient to tcl bindings and update examples 25 and 30 to use it. Modified Paths: -------------- trunk/bindings/tcl/plapi.tpl trunk/examples/tcl/x25.tcl trunk/examples/tcl/x30.tcl Modified: trunk/bindings/tcl/plapi.tpl =================================================================== --- trunk/bindings/tcl/plapi.tpl 2009-12-07 21:26:09 UTC (rev 10700) +++ trunk/bindings/tcl/plapi.tpl 2009-12-07 21:42:50 UTC (rev 10701) @@ -382,6 +382,14 @@ pltclcmd plgra void +# Draw gradient in polygon. + +pltclcmd plgradient void +n PLINT +x PLFLT * +y PLFLT * +angle PLFLT + # Get subpage boundaries in absolute coordinates. pltclcmd plgspa void Modified: trunk/examples/tcl/x25.tcl =================================================================== --- trunk/examples/tcl/x25.tcl 2009-12-07 21:26:09 UTC (rev 10700) +++ trunk/examples/tcl/x25.tcl 2009-12-07 21:42:50 UTC (rev 10701) @@ -77,94 +77,100 @@ yextreme 8 0 = -120.0 yextreme 8 1 = 120.0 - for {set j 0} {$j < 4} {incr j} { - if { $j == 0 } { - # Polygon 1: a diamond - x0 0 = 0 - y0 0 = -100 - x0 1 = -100 - y0 1 = 0 - x0 2 = 0 - y0 2 = 100 - x0 3 = 100 - y0 3 = 0 - set npts 4 - } - if { $j == 1 } { - # Polygon 1: a diamond - reverse direction - x0 3 = 0 - y0 3 = -100 - x0 2 = -100 - y0 2 = 0 - x0 1 = 0 - y0 1 = 100 - x0 0 = 100 - y0 0 = 0 - set npts 4 - } - if { $j == 2 } { - # Polygon 2: a square with punctures - x0 0 = -100 - y0 0 = -100 - x0 1 = -100 - y0 1 = -80 - x0 2 = 80 - y0 2 = 0 - x0 3 = -100 - y0 3 = 80 - x0 4 = -100 - y0 4 = 100 - x0 5 = -80 - y0 5 = 100 - x0 6 = 0 - y0 6 = 80 - x0 7 = 80 - y0 7 = 100 - x0 8 = 100 - y0 8 = 100 - x0 9 = 100 - y0 9 = -100 - set npts 10 - } - if { $j == 3 } { - # Polygon 2: a square with punctures - reversed direction - x0 9 = -100 - y0 9 = -100 - x0 8 = -100 - y0 8 = -80 - x0 7 = 80 - y0 7 = 0 - x0 6 = -100 - y0 6 = 80 - x0 5 = -100 - y0 5 = 100 - x0 4 = -80 - y0 4 = 100 - x0 3 = 0 - y0 3 = 80 - x0 2 = 80 - y0 2 = 100 - x0 1 = 100 - y0 1 = 100 - x0 0 = 100 - y0 0 = -100 - set npts 10 - } + for {set k 0} {$k < 2} {incr k} { + for {set j 0} {$j < 4} {incr j} { + if { $j == 0 } { + # Polygon 1: a diamond + x0 0 = 0 + y0 0 = -100 + x0 1 = -100 + y0 1 = 0 + x0 2 = 0 + y0 2 = 100 + x0 3 = 100 + y0 3 = 0 + set npts 4 + } + if { $j == 1 } { + # Polygon 1: a diamond - reverse direction + x0 3 = 0 + y0 3 = -100 + x0 2 = -100 + y0 2 = 0 + x0 1 = 0 + y0 1 = 100 + x0 0 = 100 + y0 0 = 0 + set npts 4 + } + if { $j == 2 } { + # Polygon 2: a square with punctures + x0 0 = -100 + y0 0 = -100 + x0 1 = -100 + y0 1 = -80 + x0 2 = 80 + y0 2 = 0 + x0 3 = -100 + y0 3 = 80 + x0 4 = -100 + y0 4 = 100 + x0 5 = -80 + y0 5 = 100 + x0 6 = 0 + y0 6 = 80 + x0 7 = 80 + y0 7 = 100 + x0 8 = 100 + y0 8 = 100 + x0 9 = 100 + y0 9 = -100 + set npts 10 + } + if { $j == 3 } { + # Polygon 2: a square with punctures - reversed direction + x0 9 = -100 + y0 9 = -100 + x0 8 = -100 + y0 8 = -80 + x0 7 = 80 + y0 7 = 0 + x0 6 = -100 + y0 6 = 80 + x0 5 = -100 + y0 5 = 100 + x0 4 = -80 + y0 4 = 100 + x0 3 = 0 + y0 3 = 80 + x0 2 = 80 + y0 2 = 100 + x0 1 = 100 + y0 1 = 100 + x0 0 = 100 + y0 0 = -100 + set npts 10 + } - for {set i 0} {$i < 9} {incr i} { - $w cmd pladv 0 - $w cmd plvsta - $w cmd plwind [xextreme $i 0] [xextreme $i 1] [yextreme $i 0] [yextreme $i 1] + for {set i 0} {$i < 9} {incr i} { + $w cmd pladv 0 + $w cmd plvsta + $w cmd plwind [xextreme $i 0] [xextreme $i 1] [yextreme $i 0] [yextreme $i 1] - $w cmd plcol0 2 - $w cmd plbox "bc" 1.0 0 "bcnv" 10.0 0 - $w cmd plcol0 1 - $w cmd plpsty 0 - $w cmd plfill $npts x0 y0 - $w cmd plcol0 2 - $w cmd pllsty 1 - $w cmd plline $npts x0 y0 - } + $w cmd plcol0 2 + $w cmd plbox "bc" 1.0 0 "bcnv" 10.0 0 + $w cmd plcol0 1 + $w cmd plpsty 0 + if { $k == 0 } { + $w cmd plfill $npts x0 y0 + } else { + $w cmd plgradient $npts x0 y0 45.0 + } + $w cmd plcol0 2 + $w cmd pllsty 1 + $w cmd plline $npts x0 y0 + } + } } # Restore defaults Modified: trunk/examples/tcl/x30.tcl =================================================================== --- trunk/examples/tcl/x30.tcl 2009-12-07 21:26:09 UTC (rev 10700) +++ trunk/examples/tcl/x30.tcl 2009-12-07 21:42:50 UTC (rev 10701) @@ -126,25 +126,19 @@ $w cmd plscmap1n 128 $w cmd plscmap1la 1 2 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. - matrix z f 2 2 - z 0 0 = 0.0 - z 1 0 = 0.0 - z 0 1 = 1.0 - z 1 1 = 1.0 + # Use that cmap1 to create a transparent red gradient for the whole + # window. + px 0 = 0. + px 1 = 1. + px 2 = 1. + px 3 = 0. - matrix clevel f 101 + py 0 = 0. + py 1 = 0. + py 2 = 1. + py 3 = 1. - # Set the color levels array. These levels are also between 0.0 and 1.0 - for {set i 0} {$i<101} {incr i} { - clevel $i = [expr {0.01 * double($i)}] - } + $w cmd plgradient 4 px py 90. - # 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. - $w cmd plshades z 0.0 1.0 0.0 1.0 clevel 0 -1 2 1 - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |