File: x25d.d

package info (click to toggle)
plplot 5.15.0%2Bdfsg-19
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 31,312 kB
  • sloc: ansic: 79,707; xml: 28,583; cpp: 20,033; ada: 19,456; tcl: 12,081; f90: 11,431; ml: 7,276; java: 6,863; python: 6,792; sh: 3,274; perl: 828; lisp: 75; makefile: 50; sed: 34; fortran: 5
file content (102 lines) | stat: -rw-r--r-- 3,456 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//      Filling and clipping polygons.
//

import plplot;
import std.string;


//--------------------------------------------------------------------------
// main
//
// Test program for filling polygons and proper clipping
//--------------------------------------------------------------------------

int main( char[][] args )
{
    // Parse and process command line arguments
    plparseopts( args, PL_PARSE_FULL );

    // Initialize plplot
    plssub( 3, 3 );
    plinit();

    static PLFLT[2][9] xextreme = [ [-120.0, 120.0],
                                    [-120.0, 120.0],
                                    [-120.0, 120.0],
                                    [ -80.0, 80.0],
                                    [-220.0, -120.0],
                                    [ -20.0, 20.0],
                                    [ -20.0, 20.0],
                                    [ -80.0, 80.0],
                                    [  20.0, 120.0] ];

    static PLFLT[2][9] yextreme = [ [-120.0, 120.0],
                                    [  20.0, 120.0],
                                    [ -20.0, 120.0],
                                    [ -20.0, 120.0],
                                    [-120.0, 120.0],
                                    [-120.0, 120.0],
                                    [ -20.0, 20.0],
                                    [ -80.0, 80.0],
                                    [-120.0, 120.0] ];

    PLFLT[] x0, y0;
    for ( int k = 0; k < 2; k++ )
    {
        for ( int j = 0; j < 4; j++ )
        {
            switch ( j )
            {
            case 0:
                x0.length = 4;
                y0.length = 4;
                // Polygon 1: a diamond
                x0[] = [   0.0, -100.0, 0.0, 100.0 ];
                y0[] = [-100.0, 0.0, 100.0, 0.0 ];
                break;
            case 1:
                // Polygon 1: a diamond - reverse direction
                x0[] = [ 100.0, 0.0, -100.0, 0.0 ];
                y0[] = [   0.0, 100.0, 0.0, -100.0 ];
                break;
            case 2:
                // Polygon 2: a square with punctures
                x0.length = 10;
                y0.length = 10;
                x0[]      = [ -100.0, -100.0, 80.0, -100.0, -100.0, -80.0, 0.0, 80.0, 100.0, 100.0 ];
                y0[]      = [ -100.0, -80.0, 0.0, 80.0, 100.0, 100.0, 80.0, 100.0, 100.0, -100.0 ];
                break;
            case 3:
                // Polygon 2: a square with punctures - reversed direction
                x0[] = [  100.0, 100.0, 80.0, 0.0, -80.0, -100.0, -100.0, 80.0, -100.0, -100.0 ];
                y0[] = [ -100.0, 100.0, 100.0, 80.0, 100.0, 100.0, 80.0, 0.0, -80.0, -100.0 ];
                break;
            default:
                break;
            }

            for ( int i = 0; i < 9; i++ )
            {
                pladv( 0 );
                plvsta();
                plwind( xextreme[i][0], xextreme[i][1], yextreme[i][0], yextreme[i][1] );

                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. );
                plcol0( 2 );
                pllsty( 1 );
                plline( x0, y0 );
            }
        }
    }

    // Don't forget to call plend() to finish off!
    plend();
    return 0;
}