Subversion Repositories shark

Rev

Rev 1493 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1493 giacomo 1
 
1606 tullio 2
/*
3
 * This program is free software; you can redistribute it and/or modify
4
 * it under the terms of the GNU General Public License as published by
5
 * the Free Software Foundation; either version 2 of the License, or
6
 * (at your option) any later version.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program; if not, write to the Free Software
15
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 *
17
 */
18
 
1493 giacomo 19
#include <kernel/kern.h>
20
#include <tracer.h>
21
 
22
#define PWCET_Automatic_Ipoint(a) TRACER_LOGEVENT(FTrace_EVT_ipoint,(a),0);
23
 
24
/* here are the bezier curves defined
25
format:
26
{startpoint, endpoint, controlpoint1, controlpoint}
27
.
28
.
29
. */
30
int curveno = 20;
31
int data[20][4][2] = {
32
        {{123,321},{ 23,432},{345,120},{123, 98}},
33
        {{567, 31},{ 23, 24},{ 35,421},{123,398}},
34
        {{  0, 21},{623,532},{145,323},{153, 68}},
35
        {{253,321},{ 23,432},{745,525},{423,198}},
36
        {{123,456},{ 23,482},{  0,123},{123,128}},
37
        {{322, 21},{223,232},{ 45,224},{123,98}},
38
        {{423, 32},{123,332},{144,329},{123,98}},
39
        {{276, 35},{ 23,492},{476,423},{123,98}},
40
        {{783,121},{723,139},{ 78,528},{123,98}},
41
        {{723,221},{623, 98},{734,683},{123,98}},
42
        {{ 60,421},{523,132},{364,753},{123,98}},
43
        {{100,521},{423,432},{633,623},{123,98}},
44
        {{ 23,371},{323,599},{343,533},{123,98}},
45
        {{123,123},{123,  0},{343,403},{123,98}},
46
        {{253,321},{490, 32},{347,393},{123,98}},
47
        {{ 68,321},{260,272},{674,283},{123,98}},
48
        {{500,321},{245,373},{ 98,173},{123,98}},
49
        {{423,321},{198,532},{306, 63},{123,98}},
50
        {{197,321},{203,432},{307,443},{123,98}},
51
        {{143,321},{293,132},{334,393},{123,98}}
52
};
53
#define STEPWIDTH 0.01 /* draws 1/STEPWIDTH +1 points between SP and EP */
54
#define XSIZE 800
55
#define YSIZE 600
56
 
57
char screen[YSIZE][XSIZE];
58
int xco[4],yco[4];
59
 
60
int init()
61
{
62
        int y,x;
63
 
64
        /*initialize screen*/
65
        for (x = 0;x < XSIZE;x++) {
66
                for (y = 0;y < YSIZE;y++)  {
67
                        screen[y][x] = 255;  /*white*/
68
                }
69
        }
70
 
71
        return 0;
72
 
73
}
74
 
75
void rand_init()
76
{
77
        int i,j,x,y;
78
        for (i=0;i<20;i++)
79
                for (j=0;j<4;j++) {
80
                        x=rand()%800;
81
                        y=rand()%600;
82
                        data[i][j][0]=x;
83
                        data[i][j][1]=y;
84
                }
85
}
86
 
87
int bezier()
88
{
89
 
90
  int i,y,x;
91
  float k;
92
 
93
  init();
94
 
95
        for (i = 0;i < curveno;i++)  {
96
                xco[3] = data[i][0][0];
97
                yco[3] = data[i][0][1];
98
                xco[2] = 3*(data[i][2][0] - data[i][0][0]);
99
                yco[2] = 3*(data[i][2][1] - data[i][0][1]);
100
                xco[1] = 3*(data[i][3][0] - data[i][2][0]) - xco[2];
101
                yco[1] = 3*(data[i][3][1] - data[i][2][1]) - yco[2];
102
                xco[0] = data[i][1][0] - data[i][0][0] - xco[2]- xco[1];
103
                yco[0] = data[i][1][1] - data[i][0][1] - yco[2]- yco[1];
104
 
105
                /*scan curve for t = 0 to t = 1 with STEPWIDTH*/
106
                for (k = 0;k <=1;k+=STEPWIDTH)  {                       /* PAN_FIXED_LOOP PAN_VARPATH */
107
                        x = (int)(((float)xco[0]*k*k*k)+((float)xco[1]*k*k)+((float)xco[2]*k)+(float)xco[3]);
108
                        y = (int)(((float)yco[0]*k*k*k)+((float)yco[1]*k*k)+((float)yco[2]*k)+(float)yco[3]);
109
                        if ((x < XSIZE)&&(x > 0)&&(y < YSIZE)&&(y > 0))  {
110
                                /*write dot to screen*/
111
                                screen[y][x] = 0;  /*black*/
112
                        }
113
                }
114
        }
115
 
116
        return 0;
117
}
118
 
119
int instrumented_function() {
120
 
121
        rand_init();
122
 
123
        bezier();
124
 
125
        return 0;
126
}
127