Subversion Repositories shark

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1493 giacomo 1
 
2
#include <kernel/kern.h>
3
#include <tracer.h>
4
 
5
#define PWCET_Automatic_Ipoint(a) TRACER_LOGEVENT(FTrace_EVT_ipoint,(a),0);
6
 
7
/* here are the bezier curves defined
8
format:
9
{startpoint, endpoint, controlpoint1, controlpoint}
10
.
11
.
12
. */
13
int curveno = 20;
14
int data[20][4][2] = {
15
        {{123,321},{ 23,432},{345,120},{123, 98}},
16
        {{567, 31},{ 23, 24},{ 35,421},{123,398}},
17
        {{  0, 21},{623,532},{145,323},{153, 68}},
18
        {{253,321},{ 23,432},{745,525},{423,198}},
19
        {{123,456},{ 23,482},{  0,123},{123,128}},
20
        {{322, 21},{223,232},{ 45,224},{123,98}},
21
        {{423, 32},{123,332},{144,329},{123,98}},
22
        {{276, 35},{ 23,492},{476,423},{123,98}},
23
        {{783,121},{723,139},{ 78,528},{123,98}},
24
        {{723,221},{623, 98},{734,683},{123,98}},
25
        {{ 60,421},{523,132},{364,753},{123,98}},
26
        {{100,521},{423,432},{633,623},{123,98}},
27
        {{ 23,371},{323,599},{343,533},{123,98}},
28
        {{123,123},{123,  0},{343,403},{123,98}},
29
        {{253,321},{490, 32},{347,393},{123,98}},
30
        {{ 68,321},{260,272},{674,283},{123,98}},
31
        {{500,321},{245,373},{ 98,173},{123,98}},
32
        {{423,321},{198,532},{306, 63},{123,98}},
33
        {{197,321},{203,432},{307,443},{123,98}},
34
        {{143,321},{293,132},{334,393},{123,98}}
35
};
36
#define STEPWIDTH 0.01 /* draws 1/STEPWIDTH +1 points between SP and EP */
37
#define XSIZE 800
38
#define YSIZE 600
39
 
40
char screen[YSIZE][XSIZE];
41
int xco[4],yco[4];
42
 
43
int init()
44
{
45
        int y,x;
46
 
47
        /*initialize screen*/
48
        for (x = 0;x < XSIZE;x++) {
49
                for (y = 0;y < YSIZE;y++)  {
50
                        screen[y][x] = 255;  /*white*/
51
                }
52
        }
53
 
54
        return 0;
55
 
56
}
57
 
58
void rand_init()
59
{
60
        int i,j,x,y;
61
        for (i=0;i<20;i++)
62
                for (j=0;j<4;j++) {
63
                        x=rand()%800;
64
                        y=rand()%600;
65
                        data[i][j][0]=x;
66
                        data[i][j][1]=y;
67
                }
68
}
69
 
70
int bezier()
71
{
72
 
73
  int i,y,x;
74
  float k;
75
 
76
  init();
77
 
78
        for (i = 0;i < curveno;i++)  {
79
                xco[3] = data[i][0][0];
80
                yco[3] = data[i][0][1];
81
                xco[2] = 3*(data[i][2][0] - data[i][0][0]);
82
                yco[2] = 3*(data[i][2][1] - data[i][0][1]);
83
                xco[1] = 3*(data[i][3][0] - data[i][2][0]) - xco[2];
84
                yco[1] = 3*(data[i][3][1] - data[i][2][1]) - yco[2];
85
                xco[0] = data[i][1][0] - data[i][0][0] - xco[2]- xco[1];
86
                yco[0] = data[i][1][1] - data[i][0][1] - yco[2]- yco[1];
87
 
88
                /*scan curve for t = 0 to t = 1 with STEPWIDTH*/
89
                for (k = 0;k <=1;k+=STEPWIDTH)  {                       /* PAN_FIXED_LOOP PAN_VARPATH */
90
                        x = (int)(((float)xco[0]*k*k*k)+((float)xco[1]*k*k)+((float)xco[2]*k)+(float)xco[3]);
91
                        y = (int)(((float)yco[0]*k*k*k)+((float)yco[1]*k*k)+((float)yco[2]*k)+(float)yco[3]);
92
                        if ((x < XSIZE)&&(x > 0)&&(y < YSIZE)&&(y > 0))  {
93
                                /*write dot to screen*/
94
                                screen[y][x] = 0;  /*black*/
95
                        }
96
                }
97
        }
98
 
99
        return 0;
100
}
101
 
102
int instrumented_function() {
103
 
104
        rand_init();
105
 
106
        bezier();
107
 
108
        return 0;
109
}
110