56 if ( plsc->level < 3 )
58 plabort(
"plgradient: Please set up window first" );
63 plabort(
"plgradient: Not enough vertices in polygon" );
67 if ( !plsc->dev_gradient )
71 plwarn(
"Driver does not support native gradients, switching to software fallback gradient.\n" );
89 double cosangle = cos(
PI * angle / 180. );
90 double sinangle = sin(
PI * angle / 180. );
91 xrot = x[0] * cosangle + y[0] * sinangle;
95 for ( i = 1; i < n; i++ )
97 xrot = x[i] * cosangle + y[i] * sinangle;
98 if ( xrot < xrot_min )
103 else if ( xrot > xrot_max )
114 dxgrad[0] = x[irot_min];
115 dxgrad[1] = dxgrad[0] + ( xrot_max - xrot_min ) * cosangle;
116 dygrad[0] = y[irot_min];
117 dygrad[1] = dygrad[0] + ( xrot_max - xrot_min ) * sinangle;
118 for ( i = 0; i <
NGRAD; i++ )
124 difilt( xgrad, ygrad, NGRAD, &clpxmi, &clpxma, &clpymi, &clpyma );
125 plsc->xgradient = xgrad;
126 plsc->ygradient = ygrad;
127 plsc->ngradient = NGRAD;
132 xpoly = (
PLINT *) malloc( (
size_t) ( n + 1 ) *
sizeof (
PLINT ) );
133 ypoly = (
PLINT *) malloc( (
size_t) ( n + 1 ) *
sizeof (
PLINT ) );
135 if ( ( xpoly == NULL ) || ( ypoly == NULL ) )
137 plexit(
"plgradient: Insufficient memory for large polygon" );
146 for ( i = 0; i < n; i++ )
151 if ( x[0] != x[n - 1] || y[0] != y[n - 1] )
157 plP_plfclp( xpoly, ypoly, n, plsc->clpxmi, plsc->clpxma,
182 PLFLT xrot, xrot_min, xrot_max, cosangle, sinangle;
184 PLFLT **z, *edge, xcoord, ycoord;
189 plabort(
"plgradient_soft: Not enough vertices in polygon" );
206 cosangle = cos(
PI / 180. * angle );
207 sinangle = sin(
PI / 180. * angle );
208 xrot = x[0] * cosangle + y[0] * sinangle;
211 for ( i = 1; i < n; i++ )
215 else if ( x[i] > xmax )
220 else if ( y[i] > ymax )
223 xrot = x[i] * cosangle + y[i] * sinangle;
224 if ( xrot < xrot_min )
226 else if ( xrot > xrot_max )
236 for ( i = 0; i <
NX; i++ )
238 xcoord = xmin + ( (
PLFLT) i ) * ( xmax -
xmin ) / (
PLFLT) ( NX - 1 );
239 for ( j = 0; j <
NY; j++ )
241 ycoord = ymin + ( (
PLFLT) j ) * ( ymax -
ymin ) / (
PLFLT) ( NY - 1 );
242 xrot = xcoord * cosangle + ycoord * sinangle;
243 z[i][j] = ( xrot - xrot_min ) / ( xrot_max - xrot_min );
251 plexit(
"plgradient_soft: Insufficient memory for large polygon"
253 for ( i = 0; i <
NEDGE; i++ )
257 edge, NEDGE, 0, 0, 0,
plfill, 1, NULL, NULL );
258 free( (
void *) edge );