void draw_real_part(int begin, int end) { complex comp; comp.real = 0, comp.image = 0; double round_x, round_el_array; int i = 0; setcolor(YELLOW); moveto(width / 2, height / 2); int x_0 = getx(); int y_0 = gety(); for(double x = begin; x <= end; x += 0.1) { comp = trigonometric_interpolation(x); double coord_x = x_0 + x * 60; double coord_y = y_0 + comp.real * 20; double invert_y = (coord_y - y_0) * 2; round_x = round(x * 1000000) / 1000000; round_el_array = round(array_values[i][0] * 10000000) / 10000000; if (round_x == round_el_array) { setcolor(RED); setfillstyle(1, RED); circle(coord_x, coord_y - invert_y, 7); floodfill(coord_x, coord_y - invert_y, RED); setcolor(YELLOW); i++; if (i == n) i = 0; } if (x == begin) moveto(coord_x, coord_y - invert_y); lineto(coord_x, coord_y - invert_y); } }
void trace_temp (struct sndg_struct *sp, short width) /*************************************************************/ /* TRACE_TEMP */ /* John Hart NSSFC KCMO */ /* */ /* Plots environmental temperature trace on SkewT. */ /*************************************************************/ { short i, x, y, xold, yold, ok = 0; setcliprgn (skv.tlx, skv.tly, skv.brx, skv.bry, draw_reg, gc); setlinestyle (1, width); for (i = 0; i < sp->numlev; i++) { if (sp->sndg[i].temp > -200) { xold = x; yold = y; x = temp_to_pix (sndgp->sndg[i].temp, sndgp->sndg[i].pres); y = pres_to_pix (sndgp->sndg[i].pres); if (ok == 0) { moveto (x, y); ok = 1; } else { moveto (xold, yold); lineto (x, y); } } } }
void gwinGraphDrawPoints(GHandle gh, const point *points, unsigned count) { #define gg ((GGraphObject *)gh) unsigned i; const point *p; if (gh->vmt != &graphVMT || !_gwinDrawStart(gh)) return; // Draw the connecting lines for(p = points, i = 0; i < count; p++, i++) { if ((gh->flags & GGRAPH_FLG_CONNECTPOINTS)) { // Draw the line lineto(gg, gg->lastx, gg->lasty, p->x, p->y, &gg->style.line); // Redraw the previous point because the line may have overwritten it if (i == 0) pointto(gg, gg->lastx, gg->lasty, &gg->style.point); } else gh->flags |= GGRAPH_FLG_CONNECTPOINTS; // Save this point for next time. gg->lastx = p->x; gg->lasty = p->y; } // Draw the points. for(p = points, i = 0; i < count; p++, i++) pointto(gg, p->x, p->y, &gg->style.point); _gwinDrawEnd(gh); #undef gg }
void _draw_link(node *p,int x1, int x2, int y) { if (p != NULL) { lineto((x1+x2)/2, y); _draw_link(p->left, x1, (x1+x2)/2, y+DY); moveto((x1+x2)/2, y); _draw_link(p->right, (x1+x2)/2, x2, y+DY); lineto((x1+x2)/2, y); } else { lineto((x1+x2)/2, y); moveto((x1+x2)/2, y); } }
/* * Redeseneaza zona din dreapta dupa ce utilizatorul a miscat sau a * modificat dreptunghiul in zona din stanga. */ void redraw_right_area() { int restidx, pi; set(3); setwritemode(COPY_PUT); setcolor(LIGHTBLUE); clearviewport(); for (int i = 0; i <= REF; i++) { if ((x[i] >= x1) && (x[i] <= x2) && (y[i] >= y1) && (y[i] <= y2)) { moveto(newX(x[i]), newY(y[i])); pi = i; restidx = i+1; i = REF+1; } } for (i = restidx; i <= REF; i++) { if ((x[i] >= x1) && (x[i] <= x2) && (y[i] >= y1) && (y[i] <= y2)) { if ((pi+1) == i) { lineto(newX(x[i]), newY(y[i])); } else { moveto(newX(x[i]), newY(y[i])); } pi = i; } } }
void gwinGraphDrawPoint(GHandle gh, coord_t x, coord_t y) { #define gg ((GGraphObject *)gh) if (gh->vmt != &graphVMT) return; if ((gh->flags & GGRAPH_FLG_CONNECTPOINTS)) { // Draw the line lineto(gg, gg->lastx, gg->lasty, x, y, &gg->style.line); // Redraw the previous point because the line may have overwritten it pointto(gg, gg->lastx, gg->lasty, &gg->style.point); } else gh->flags |= GGRAPH_FLG_CONNECTPOINTS; // Save this point for next time. gg->lastx = x; gg->lasty = y; // Draw this point. pointto(gg, x, y, &gg->style.point); #undef gg }
void main() { int gd=DETECT,gm; int i,n,x[4],y[4],x1,y1; float u; printf("Enter no of controlling points(4): "); scanf("%d",&n); printf("Enter the coordinates\n"); for(i=0;i<4;i++) { printf("Point %d(x,y):\n",i+1); scanf("%d%d",&x[i],&y[i]); } initgraph(&gd,&gm,""); for(i=0;i<3;i++) line(x[i],y[i],x[i+1],y[i+1]); moveto(x[0],y[0]); for(u=0;u<1;u=u+0.0001) { delay(5); x1=pow(1-u,3)*x[0]+3*u*pow(1-u,2)*x[1]+3*u*u*(1-u)*x[2]+u*u*u*x[3]; y1=pow(1-u,3)*y[0]+3*u*pow(1-u,2)*y[1]+3*u*u*(1-u)*y[2]+u*u*u*y[3]; setcolor(5); lineto(x1,y1); } getch(); }
void trace_vtmp (short width) /*************************************************************/ /* TRACE_VTMP */ /* John Hart NSSFC KCMO */ /* */ /* Plots virtual temperature trace on SkewT. */ /*************************************************************/ { short i, x, y, xold, yold, ok = 0; setlinestyle (3, width); for (i = 0; i < sndgp->numlev; i++) { if (qc (sndgp->sndg[i].temp) && qc (sndgp->sndg[i].dwpt)) { xold = x; yold = y; x = temp_to_pix (i_vtmp (sndgp->sndg[i].pres), sndgp->sndg[i].pres); y = pres_to_pix (sndgp->sndg[i].pres); if (ok == 0) { moveto (x, y); ok = 1; } else { moveto (xold, yold); lineto (x, y); } } } }
void move() { setfillstyle(1, 1); bar(0, 0, 640, 480); for (dxx = - 190; !bioskey(1); dxx++) { setfillstyle(1, 1); bar(0, 0, 640, 300); for (i = 0; i <= pn; i++) { j = ld[i]; x = x0 - (0.71 * dx[j] - 0.71 * dy[j]); y = y0 - (0.82 * dz[j] - 0.41 * dx[j] - 0.41 * dy[j]); dyy = 20; x = x + dxx; y = y + dyy; if (tl[i] == 0) { moveto(x, y); } lineto(x, y); if (x >= 640) { dxx = -200; } } delay(1000); } }
/*===============================================================*/ void DrawFractalImage(void) { int i,x,step,number; number=(int) pow(2.0,(double)MAX_LEVEL); step=getmaxx()/number*3/2; moveto(0,(int)Array[0]); for(i=1,x=step;i<number;x+=step,i++) lineto(x,(int)Array[i]); }
void trace_dwpt2 (short width) /*************************************************************/ /* TRACE_DWPT2 */ /* John Hart NSSFC KCMO */ /* */ /* Plots environmental Dew Point trace on SkewT. */ /*************************************************************/ { short i, x, y, xold, yold, ok = 0, numlvl2; numlvl2 = sndgp->ovrlev; setcliprgn (skv.tlx, skv.tly, skv.brx, skv.bry, draw_reg, gc); setlinestyle (1, width); for (i = 0; i < numlvl2; i++) { if (sndgp->ovrl[i].dwpt > -200) { xold = x; yold = y; x = temp_to_pix (sndgp->ovrl[i].dwpt, sndgp->ovrl[i].pres); y = pres_to_pix (sndgp->ovrl[i].pres); if (ok == 0) { moveto (x, y); ok = 1; } else { moveto (xold, yold); lineto (x, y); } } } }
/* * Desenarea graficului in zona din stanga a ecranului. */ void initialize_left_area() { set(2); // desenarea graficului setcolor(LIGHTBLUE); moveto(x[0], y[0]); for (int i = 1; i <= REF; i++) lineto(x[i], y[i]); setcolor(LIGHTGRAY); // desenarea axelor daca sunt in figura if ((minf <= 0) && (maxf >= 0)) { // axa Ox line(0, virtualY(f(zerof())), 316, virtualY(f(zerof()))); } if ((a <= 0) && (b >= 0)) { // axa Oy line(virtualX(0), 0, virtualX(0), 316); } setwritemode(XOR_PUT); setcolor(GREEN); rectangle(x1, y1, x2, y2); }
void GraficoEspSecund ( void ) { int col; float far *apt; inicEsp2 = inicEsp1; AtivaJanelaGrafica ( GRAF2 ); clearviewport (); DesenhaEixos ( 25 , 235 , 10 , 110 , 0 , 0 , 50 , 12 ); ScalaEspSecund (); moveto ( 25 , 62 ); apt = inicEsp2; col = 25; for (; (*apt != FIM) && (apt < (inicEsp2 + NUMMAXPONTOS - 40)) ; apt += 40 , ++col) lineto ( col , 62 - *apt * 12 ); CapacVital2 = CapacidadeVital; CapacInspi2 = CapacidadeInspiratoria; VolResExpi2 = VolumeReservaExpiratorio; CVpercen2 = CVpercent; gprintf ( 5 , 160 , "Param. Teorico Calculado %%"); gprintf ( 5 , 170 , " CV %7.2f %6.2f %5d" , CVteorico , CapacVital2 , (int)(CVpercen2 + 0.5) ); gprintf ( 5 , 180 , " CI - %6.2f -" , CapacInspi2 ); gprintf ( 5 , 190 , " VRE - %6.2f -" , VolResExpi2 ); DesativaJanelaGrafica ( GRAF2 ); }
void isotherm (float temp) /*************************************************************/ /* ISOTHERM */ /* John Hart NSSFC KCMO */ /* */ /* Draws temperature lines (temp, c) on SkewT graphic. */ /*************************************************************/ { short x, y; char st[10]; setcolor (24, draw_reg, gc); x = temp_to_pix (temp, 1050); y = skv.bry; if ((temp >= -30) && (temp <= 50)) { setcliprgn (1, 1, xwdth, xhght, draw_reg, gc); itoa ((short) temp, st, 10); setcolor (1, draw_reg, gc); outgtext (st, x - (getgtextextent (st) / 2), y); setcolor (24, draw_reg, gc); } setcliprgn (skv.tlx, skv.tly, skv.brx, skv.bry, draw_reg, gc); moveto (x, y); x = temp_to_pix (temp, 100); y = skv.tly; lineto (x, y); }
void fir(int x,int y,int h, int c1) // ѕроцедура рисовани¤ елочки //ѕараметры: x,y Ц координаты вершины h Ц высота; st Ц стиль закраски c1 - цвет линий и закраски { int a = int((h*2/sqrt(3))); triangle(x, y, h, c1); triangle(x, y+h, h, c1); triangle(x, y+2*h, h, c1); setcolor(BROWN); setfillstyle(1, BROWN); moveto(x+a/2-5, y+2*h); lineto(x+a/2-5, y+h+2*h); lineto(x+a/2+5, y+h+2*h); lineto(x+a/2+5, y+2*h); lineto(x+a/2-5, y+2*h); floodfill(x+a/2-5+1, y+2*h+1, BROWN); }
void DrawLineWithWidth(int xStart,int yStart,int width,int height) { int i; for(i=0;i<height;++i){ moveto(xStart , yStart+i ); lineto(xStart + width , yStart+i ); } }
double diamondsquare (double x0, double y0, double side) { side /= 2.0; /* Plot outer square */ rectangle (x0 - side, y0 - side, x0 + side, y0 + side); /* Plot inner diagonal square */ moveto (x0, y0 - side); lineto (x0 + side, y0); lineto (x0, y0 + side); lineto (x0 - side, y0); lineto (x0, y0 - side); /* Return radius of circumscribing circle */ return (sqrt ((side * side) * 2.0)); }
void CGameControllerRalla3::DrawHUD() { if (m_PlayerWin == PLAYER_NULL) { if (m_ActivePlayer == PLAYER_1) { circle(mousex(), mousey(), 10); outtextxy(g_Game.GetScreenW()/2-textwidth("TURNO: JUGADOR 1")/2, dimTY+60, "TURNO: JUGADOR 1"); } else { moveto(mousex()-10, mousey()-10); lineto(mousex()+10, mousey()+10); moveto(mousex()+10, mousey()-10); lineto(mousex()-10, mousey()+10); if (m_CPU) outtextxy(g_Game.GetScreenW()/2-textwidth("TURNO: CPU")/2, dimTY+120, "TURNO: CPU"); else outtextxy(g_Game.GetScreenW()/2-textwidth("TURNO: JUGADOR 2")/2, dimTY+60, "TURNO: JUGADOR 2"); } } else { const char *sBuff; if (m_PlayerWin == PLAYER_1) sBuff = "Gana el JUGADOR 1"; else if (m_PlayerWin == PLAYER_2) sBuff = "Gana el JUGADOR 2"; else if (m_PlayerWin == PLAYER_CPU) sBuff = "Gana la CPU"; else sBuff = "EMPATE!"; int xt = g_Game.GetScreenW()/2 - textwidth(sBuff)/2; int yt = g_Game.GetScreenH()/2 - textheight(sBuff)/2; outtextxy(xt, yt, sBuff); xt = g_Game.GetScreenW()/2 - textwidth("pulsa INTRO para reiniciar")/2; yt = g_Game.GetScreenH()/2 - textheight("pulsa INTRO para reiniciar")/2; yt += textheight(sBuff) + 15; outtextxy(xt, yt, "pulsa INTRO para reiniciar"); rectangle(-1, yt-2, g_Game.GetScreenW()+1, yt-1 + textheight("pulsa INTRO para reiniciar") + 2); } }
void GraficoFluxSecund ( void ) { float volume = 0; float far *apt; inicFlux2 = inicFlux1; AtivaJanelaGrafica ( GRAF2,0 ); clearviewport (); DesenhaEixos ( 25 , 235 , 10 , 110 , 0 , 36 , 40 , 12 ); ScalaFluxSecund (); moveto ( 25 , 110 ); apt = inicFlux2; volume = 0; for (; (*(apt + 1) != FIM) && (apt < (inicFlux2 + NUMMAXPONTOSINF)) ; apt++) if (*apt != 4096) { volume += *apt / FREQ; lineto ( volume * 20 + 25 , *apt * (-3.0) + 74 ); } lineto ( volume * 20 + 25 , 74 ); CVF2 = CVF1; PeakFlow2 = PeakFlow1; VEF1DEUX = VEF1UN; TIFFDEUX = TIFFUN; FEF50DEUX = FEF50UN; FEF75DEUX = FEF75UN; FEF2575DEUX = FEF2575UN; FEF7585DEUX = FEF7585UN; CVFpercent2 = CVFpercent1; PeakFlowpercent2 = PeakFlowpercent1; VEF1percent2 = VEF1percent1; TIFFpercent2 = TIFFpercent1; FEF50percent2 = FEF50percent1; FEF75percent2 = FEF75percent1; FEF2575percent2 = FEF2575percent1; FEF7585percent2 = FEF7585percent1; VolumeExtDEUX = VolumeExtUN; TempoCurvaDEUX = TempoCurvaUN; MET2 = MET1; METpercent2 = METpercent1; ExibeParametrosDEUX ( 5 , 110 ); DesativaJanelaGrafica ( GRAF2 ); }
static void condraw (float x, float y) { lineto(x,y); if (++pathcount>PATHMAX) { stroke(); moveto(x,y); pathcount = 0; } }
/*NP*/ void trace_parcel (float pres, float temp, float dwpt) /*************************************************************/ /* TRACE_PARCEL */ /* John Hart NSSFC KCMO */ /* */ /* Plots parcel(pres, temp, dwpt) trajectory on SkewT */ /* graphic. */ /* */ /* pres - Pressure of initial parcel(mb) */ /* temp - Temperature of initial parcel (c) */ /* dwpt - Dew Point of initial parcel (c) */ /*************************************************************/ { float i, p2, t2, t3; short x, y; if (!qc (pres) || !qc (temp) || !qc (dwpt)) return; setcolor (31, draw_reg, gc); setlinestyle (4, 1); x = temp_to_pix (virtemp (pres, temp, dwpt), pres); y = pres_to_pix (pres); moveto (x, y); drylift (pres, temp, dwpt, &p2, &t2); x = temp_to_pix (virtemp (p2, t2, t2), p2); y = pres_to_pix (p2); lineto (x, y); for (i = p2 - 50; i >= 100; i = i - 50) { t3 = wetlift (p2, t2, i); x = temp_to_pix (virtemp (i, t3, t3), i); y = pres_to_pix (i); lineto (x, y); } t3 = wetlift (p2, t2, 100); x = temp_to_pix (virtemp (100, t3, t3), 100); y = pres_to_pix (100); lineto (x, y); }
double zigzagring (double x0, double y0, double r1, double r2, int npts, int incr, int flag) { int i; double x1[128], y1[128]; double x2[128], y2[128]; double theta1, theta2; double delta; int n1, n2; delta = (2.0 * M_PI) / (double)npts; for (i = 0; i < npts; i++) { if (flag) { theta2 = delta * (double)i; theta1 = (delta * (double)i) + (delta / 2.0); } else { theta1 = delta * (double)i; theta2 = (delta * (double)i) + (delta / 2.0); } x1[i] = (cos (theta1) * r1) + x0; y1[i] = (sin (theta1) * r1) + y0; x2[i] = (cos (theta2) * r2) + x0; y2[i] = (sin (theta2) * r2) + y0; } moveto (x1[0], y1[0]); n1 = 0; n2 = incr / 2; for (i = 0; i < npts; i++) { lineto (x1[n1], y1[n1]); lineto (x2[n2], y2[n2]); n1 = (n1 + incr) % npts; n2 = (n2 + incr) % npts; } lineto (x1[0], y1[0]); return (r2); }
void newpos(void) { cleardevice(); x=0.0;y=0.0;z=0.0; sx=0.0;sy=0.0; xa=0.0;ya=0.0;za=0.0; sxa=0.0;sya=0.0;sxb=0.0;syb=0.0; sxs=0.0;sys=0.0; sr1=0.0;sr2=0.0;sr3=0.0; cr1=0.0;cr2=0.0;cr3=0.0; msx=0.0;msy=0.0; rx=0.0;ry=0.0; t1=0;t2=0; p1=0; rotation(); /* for(t2=1;t2<=6;t2++) */ for(t2=1;t2<=4;t2++) { setlinestyle(USERBIT_LINE,0xffff,NORM_WIDTH); /* get starting position */ /* x=array1[p1][0]; y=array1[p1][1]; z=array1[p1][2]; */ x=array2[p1][0]; y=array2[p1][1]; z=array2[p1][2]; calc_3d(); windows(); sxa=sx;sya=sy; /* finish displaying side */ /* for(t1=1;t1<=4;t1++) */ for(t1=1;t1<=3;t1++) { p1++; /* x=array1[p1][0]; y=array1[p1][1]; z=array1[p1][2]; */ x=array2[p1][0]; y=array2[p1][1]; z=array2[p1][2]; calc_3d(); windows(); sxs=sx; sys=sy; sxb=sx; syb=sy; moveto(sxa,sya); lineto(sxb,syb); sxa=sxs; sya=sys; } p1++; } }
/****************************************************************************** // dessiner_ligne // **************************************************************************** // Cette fonction privée permet de dessiner une des lignes de la route. // **************************************************************************** // Parametres : ptA, ptB = les 2 extrémités de la ligne à afficher. ******************************************************************************/ static void dessiner_ligne(t_pt2d ptA, t_pt2d ptB) { setcolor(LIGNE); setlinestyle(SOLID_LINE, 1, 3); /****** ARRONDIR LES POINTS ******/ moveto(ARRONDI(ptA.X), ARRONDI(ptA.Y)); /* Positionner le crayon au debut de la ligne */ lineto(ARRONDI(ptB.X), ARRONDI(ptB.Y)); /* Faire une ligne jusqu'a l'extremité de fin */ }
/* ----------------------------------------------------------------------- */ void GraficoFluxSecund() /* ----------------------------------------------------------------------- */ { float far *apt; float volume = 0; inicFlux2 = inicFlux1; AtivaJanelaGrafica(GRAF2); clearviewport(); /*************/ DesenhaEixos(25,235,10,110,0,36,40,12); ScalaFluxSecund(); moveto(FVMV /* 25,110*/); apt = inicFlux2; volume = 0; for (;(*(apt+1)!=FIM)&&(apt<inicFlux2+NUMMAXPONTOSINF);apt++) { volume += *apt / 6400.0; /*******/ lineto (volume*20+25, (* apt / 64.0) * (-6) + 74); } /*******/ lineto (volume*20+25,74); CVF2 = CVF1; PeakFlow2 = PeakFlow1; VEF1DEUX = VEF1UN; TIFFDEUX = TIFFUN; FEF50DEUX = FEF50UN; FEF75DEUX = FEF75UN; FEF2575DEUX = FEF2575UN; FEF7585DEUX = FEF7585UN; CVFpercent2 = CVFpercent1; PeakFlowpercent2 = PeakFlowpercent1; VEF1percent2 = VEF1percent1; TIFFpercent2 = TIFFpercent1; FEF50percent2 = FEF50percent1; FEF75percent2 = FEF75percent1; FEF2575percent2 = FEF2575percent1; FEF7585percent2 = FEF7585percent1; MET2 = MET1; METpercent2 = METpercent1; ExibeParametrosDEUX(FVEPD /* 5,130*/); DesativaJanelaGrafica(GRAF2); } /* GraficoFluxSecund */
void MyOwnStar(int x0, int y0) { double deltPiece = 2.0 / pieces, k = 0, angle = 0, x, y; StarPoint(angle, x, y); moveto(x * 100 + x0, y * 100 + y0); for(k += deltPiece; k <= 2; angle = k * pi, k += deltPiece) { StarPoint(angle, x, y); lineto(x * 100 + x0, y * 100 + y0); } }
bool polyline::applyTo(BatchBitmap24& p_target) { if (numCoords > 0) { p_target.setCurrentPos(coords[0].convert(p_target)); } for (unsigned int i = 1; i < numCoords; i++) { lineto(coords[i]).applyTo(p_target); } return true; }
void runkernel(void) { cleardevice(); setbkcolor(0); int id,l,count=0; Control.First=0; Control.Free=50; id=Number+1; while((Control.Free<50)||(Number==-1)) { while(bioskey(1)!=0) { count++; bioskey(0); biuldwait(id); id++; Number++; } if((wt==wh&&wh==0)||(wt!=wh)) biuldmem();/*Biuld all can*/ cleardevice(); setbkcolor(0); drawgrid(); run(); finish(); compress(); display(); delay(2000); } setcolor(0); for(int a=0;a<629;a++) { moveto(a,390); lineto(a,425); moveto(a,445); lineto(a,460); } setcolor(YELLOW); outtextxy(180,450,"All the processes have been done!"); getch(); }
main() { int graphdriver=VGA; int graphmode=VGAHI; initgraph(&graphdriver,&graphmode,""); cleardevice(); moveto(200,200); lineto(100,100); closegraph(); getch(); }
double sqwavering (double x0, double y0, double radius, double len, int nwaves) { double delta; double theta; double degrees; double xvec, yvec; double x1, y1; double x2, y2; int i; /* Number of half-waves; must be even */ nwaves *= 2; delta = (2.0 * M_PI) / (double)nwaves; degrees = 360.0 / (double)nwaves; for (i = 0; i < nwaves; i++) { theta = (double)i * delta; xvec = cos (theta); yvec = sin (theta); x1 = xvec * radius; y1 = yvec * radius; x2 = xvec * (radius + len); y2 = yvec * (radius + len); if (i == 0) moveto (x0 + x2, y0 + y2); if (i & 1) lineto (x0 + x2, y0 + y2); else lineto (x0 + x1, y0 + y1); arc (x0, y0, degrees); } return (radius + len); }