More samples in the graphic help pages Note that they are automatically generated...
[scilab.git] / scilab / modules / graphics / help / en_US / polygon / xfpolys.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) ENPC - Jean-Philippe Chancelier
5  * 
6  * This file must be used under the terms of the CeCILL.
7  * This source file is licensed as described in the file COPYING, which
8  * you should have received as part of this distribution.  The terms
9  * are also available at    
10  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
11  *
12  -->
13 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="xfpolys">
14   <info>
15     <pubdate>$LastChangedDate$</pubdate>
16   </info>
17   <refnamediv>
18     <refname>xfpolys</refname>
19     <refpurpose> fill a set of polygons</refpurpose>
20   </refnamediv>
21   <refsynopsisdiv>
22     <title>Calling Sequence</title>
23     <synopsis>xfpolys(xpols,ypols,[fill])</synopsis>
24   </refsynopsisdiv>
25   <refsection>
26     <title>Arguments</title>
27     <variablelist>
28       <varlistentry>
29         <term>xpols,ypols</term>
30         <listitem>
31           <para>matrices of the same size (p,n) (points of the polygons).</para>
32         </listitem>
33       </varlistentry>
34       <varlistentry>
35         <term>fill</term>
36         <listitem>
37           <para>vector of size n or of size (p,n)</para>
38         </listitem>
39       </varlistentry>
40     </variablelist>
41   </refsection>
42   <refsection>
43     <title>Description</title>
44     <para>
45       <literal>xfpolys</literal> fills a set of polygons of the same size defined by 
46       the two matrices <literal>xpols</literal> and <literal>ypols</literal>. 
47       The coordinates of each polygon
48       are stored in a column of <literal>xpols</literal> and <literal>ypols</literal>.
49     </para>
50     <para>The polygons may be filled with a given color (flat) or painted with
51       interpolated (shaded) colors.
52     </para>
53     <variablelist>
54       <varlistentry>
55         <term>flat color painting</term>
56         <listitem>
57           <para>
58             In this case <literal>fill</literal> should be a vector of size
59             <literal>n</literal>.
60             The pattern for filling polygon number i is given by
61             <literal>fill(i)</literal>:
62           </para>
63           <itemizedlist>
64             <listitem>
65               <para>
66                 if <literal>fill(i)&lt;0</literal>, the polygon is filled with
67                 pattern id <literal>-fill(i)</literal>.
68               </para>
69             </listitem>
70             <listitem>
71               <para>
72                 if <literal>fill(i)=0</literal>, the polygon is drawn with the
73                 current dash style (or current color) and not filled.
74               </para>
75             </listitem>
76             <listitem>
77               <para>
78                 if <literal>fill(i)&gt;0</literal>, the polygon is filled with
79                 pattern id <literal>fill(i)</literal>.  Then its contour is drawn with
80                 the current dash (or color) and closed if necessary.
81               </para>
82             </listitem>
83           </itemizedlist>
84         </listitem>
85       </varlistentry>
86       <varlistentry>
87         <term>interpolated color painting</term>
88         <listitem>
89           <para>
90             In this case <literal>fill</literal> should be a matrix with same sizes
91             as <literal>xpols</literal> and <literal>ypols</literal>. Note that
92             <literal>p</literal> must be equal to 3 or 4.
93           </para>
94           <para>
95             <literal>fill(k,i)</literal> gives the color at the <literal>k</literal>th edge
96             of polygon <literal>i</literal>.
97           </para>
98         </listitem>
99       </varlistentry>
100     </variablelist>
101   </refsection>
102   <refsection>
103     <title>Sample</title>
104     <scilab:image>
105       clf()
106       f=gcf();
107       a=gca();
108       a.data_bounds=[0,-10;40,30];
109       a.isoview='on';
110       x1=[0,10,20,10]';
111       y1=[10,0,10,20]';
112       c=linspace(2,100,4)';
113       xpols=[x1 x1+20 x1+10 x1+10];
114       ypols=[y1 y1    y1+10 y1-10];
115       cols= [c c($:-1:1) c([3 4 1 2]) c]
116       f.color_map=jetcolormap(max(cols));
117       xfpolys(xpols,ypols,cols)
118     </scilab:image>
119   </refsection>
120   
121   <refsection>
122     <title>Examples</title>
123     <programlisting role="example"><![CDATA[ 
124 a=gca();
125 a.data_bounds=[0,-10;210,40];
126 a.foreground=color('red');
127 x1=[0,10,20,30,20,10,0]';
128 y1=[15,30,30,15,0,0,15]';
129 xpols=[x1 x1 x1 x1];
130 xpols=xpols+[0,60,120,180].*.ones(x1);
131 ypols=[y1 y1 y1 y1];
132 xfpolys(xpols,ypols,[-1,0,1,2])
133  ]]></programlisting>
134     <programlisting role="example"><![CDATA[ 
135 // interpolated colors
136 clf()
137 f=gcf();
138 a=gca();
139 a.data_bounds=[0,-10;40,30];
140 a.isoview='on';
141 x1=[0,10,20,10]';
142 y1=[10,0,10,20]';
143 c=linspace(2,100,4)';
144 xpols=[x1 x1+20 x1+10 x1+10];
145 ypols=[y1 y1    y1+10 y1-10];
146 cols= [c c($:-1:1) c([3 4 1 2]) c]
147 f.color_map=jetcolormap(max(cols));
148 xfpolys(xpols,ypols,cols)
149  ]]></programlisting>
150     <programlisting role="example"><![CDATA[   
151 // interpolated colors
152 clf()
153 f=gcf();
154 x11=[0;20;20;0];
155 y11=[10;10;30;30];
156 c11=[10;10;30;30];
157 x12=x11;
158 y12=y11+20;
159 c12=[20;20;1;1];
160 c12=[30;30;10;10];
161 x21=[0;30;30;0]+22;
162 y21=[20;20;30;30];
163 c21=[20;20;30;30];
164 x22=x21;
165 y22=y21+10;
166 c22=[30;30;20;20];
167 x31=[0;40;40;0]+55;
168 y31=[0;0;30;30];
169 c31=[0;0;30;30];
170 x32=x31;
171 y32=y31+30;
172 c32=[30;30;0;0];
173 X=[x11 x12 x21 x22 x31 x32];
174 Y=[y11 y12 y21 y22 y31 y32];
175 C=([c11 c12 c21 c22 c31 c32]+1)*5;
176 a=gca();
177 a.isoview='on';
178 a.data_bounds=[min(X),min(Y);max(X),max(Y)];
179 f=gcf();
180 f.color_map=graycolormap(max(C));
181 xfpolys(X,Y,C)
182  ]]></programlisting>
183   </refsection>
184   <refsection role="see also">
185     <title>See Also</title>
186     <simplelist type="inline">
187       <member>
188         <link linkend="xfpoly">xfpoly</link>
189       </member>
190       <member>
191         <link linkend="xpoly">xpoly</link>
192       </member>
193       <member>
194         <link linkend="xpolys">xpolys</link>
195       </member>
196     </simplelist>
197   </refsection>
198 </refentry>