#include #include #include #include #include #define MAXPTS 200 #define EPS 0.000001 #define STEP 0.01 int mousex, mousey; int sirka=640, vyska=480; int pts=0,color=1; double P[205][2],beta1[205],beta2[205]; int sel_pt=-1,last_pt=2,is_ctrl=0,is_alt=0; void PisBitmapovyText(int x, int y, char *string, void *font) { int len, i; glRasterPos2f(x, y); len = (int) strlen(string); for (i = 0; i < len; i++) glutBitmapCharacter(font, string[i]); } void draw_segment(double a0,double a1,double b0,double b1,double c0,double c1,double d0,double d1) { double t,pom[2]; glColor3d(0.3, 0.3, 0.3); glBegin(GL_LINE_STRIP); glVertex2d(a0,a1); glVertex2d(b0,b1); glVertex2d(c0,c1); glVertex2d(d0,d1); glEnd(); if (color) glColor3d(1.0,0.33,0.0); else glColor3d(1.0,1.0,0.0); color=1-color; glBegin(GL_LINE_STRIP); for (t=0.0;t<1.0+STEP-EPS;t+=STEP) { pom[0] =a0*pow(t,0)*pow(1-t,3); pom[1] =a1*pow(t,0)*pow(1-t,3); pom[0]+=b0*3*pow(t,1)*pow(1-t,2); pom[1]+=b1*3*pow(t,1)*pow(1-t,2); pom[0]+=c0*3*pow(t,2)*pow(1-t,1); pom[1]+=c1*3*pow(t,2)*pow(1-t,1); pom[0]+=d0*pow(t,3)*pow(1-t,0); pom[1]+=d1*pow(t,3)*pow(1-t,0); glVertex2dv(pom); } glEnd(); glPointSize(6); glColor3d(0.6, 0.6, 0.6); glBegin(GL_POINTS); glVertex2d(a0,a1); glVertex2d(b0,b1); glVertex2d(c0,c1); glVertex2d(d0,d1); glEnd(); } void display(void) { int i,j; double A[2],B[2],C[2],D[2],E[2],F[2],G[2],H[2]; char pom[100]; glClear(GL_COLOR_BUFFER_BIT); color=1; // glColor3d(0.3, 0.3, 0.3); // glBegin(GL_LINE_STRIP); for (i=0;i=4) { draw_segment(P[0][0],P[0][1],P[1][0],P[1][1],P[2][0],P[2][1],P[3][0],P[3][1]); A[0]=P[0][0]; A[1]=P[0][1]; B[0]=P[1][0]; B[1]=P[1][1]; C[0]=P[2][0]; C[1]=P[2][1]; D[0]=P[3][0]; D[1]=P[3][1]; // A[0]=P[0][0]; A[1]=P[0][1]; B[0]=P[0][0]; B[1]=P[0][1]; C[0]=P[0][0]; C[1]=P[0][1]; D[0]=P[0][0]; D[1]=P[0][1]; for (i=3;i