void CrayonLine(BITMAP* bmp, Vector start, Vector end, int colour, float wobble, float amplitude, int inner_radius, int outer_radius, float hardness) { Vector line_tangent = end - start; if (rand()%2 == 0) // If the normal is a randomised then it should result in the lines starting off on different direction wobbles crayon_line_normal = Vector(-line_tangent.Y(), line_tangent.X()); else crayon_line_normal = Vector(line_tangent.Y(), -line_tangent.X()); crayon_line_normal *= (1/crayon_line_normal.Mag()); prev_crayon_x = start.XInt(); prev_crayon_y = start.YInt(); crayon_line_wobble = wobble; crayon_line_wobble_amplitude = amplitude; crayon_line_inner_radius = inner_radius; crayon_line_outer_radius = outer_radius; int fg_r = getr(colour), fg_g = getg(colour), fg_b = getb(colour); int bg_r = (256 - fg_r)*hardness + fg_r, bg_g = (256 - fg_g)*hardness + fg_g, bg_b = (256 - fg_b)*hardness + fg_b; crayon_fade_colour = makecol(bg_r, bg_g, bg_b); points_down_line = 0; do_line(bmp, start.XInt(), start.YInt(), end.XInt(), end.YInt(), colour, CrayonBackLine); points_down_line = 0; prev_crayon_x = start.XInt(); prev_crayon_y = start.YInt(); do_line(bmp, start.XInt(), start.YInt(), end.XInt(), end.YInt(), colour, CrayonFrontLine); }
/** * Draw a straight trajectory for bullets */ void Bullet::showline(int z_s, int x_s, int y_s, int z_d, int x_d, int y_d) { if ((z_s == z_d) && (x_s == x_d) && (y_s == y_d)) return ; int xd, yd, zd; int xg, yg; int xg2, yg2; sel_man->calc_bullet_start(x_s, y_s, z_s, &x0, &y0, &z0); //start point as made in soldier::shoot xd = x_d * 16 + 8; yd = y_d * 16 + 8; zd = z_d * 12 + 8; //target in the center REAL ro = sqrt((double)((xd - x0) * (xd - x0) + (yd - y0) * (yd - y0) + (zd - z0) * (zd - z0))); REAL fi = acos((REAL)(zd - z0) / ro); REAL te = atan2((REAL)(yd - y0), (REAL)(xd - x0)); int i; for (i = 3; i < 100000; i++) { zd = (int)(z0 + i * cos(fi)); xd = (int)(x0 + i * cos(te) * sin(fi)); yd = (int)(y0 + i * sin(te) * sin(fi)); // hit obstacle or fly out of map borders if ((!map->inside(zd, xd, yd)) || (!map->pass_lof_cell(zd, xd, yd))) break; // hit enemy soldier, only visible soldiers are taken into account in // order to prevent cheating if (platoon_remote->check_for_hit(zd, xd, yd) && platoon_local->is_visible(zd / 12, xd / 16, yd / 16)) break; // hit local soldier (with a workaround preventing hit check for selected soldier) if (platoon_local->check_for_hit(zd, xd, yd, sel_man)) break; } xg = map->x + x0 + y0; yg = (int)(map->y - (x0 + 1) / 2 + y0 / 2 - z0 * 2.0 - 2); xg2 = map->x + xd + yd; yg2 = (int)(map->y - (xd + 1) / 2 + yd / 2 - zd * 2.0 - 2); do_line(screen2, xg, yg, xg2, yg2, COLOR_YELLOW, dotted_line_proc); i = 1000; zd = (int)(z0 + i * cos(fi)); xd = (int)(x0 + i * cos(te) * sin(fi)); yd = (int)(y0 + i * sin(te) * sin(fi)); xg = xg2; yg = yg2; xg2 = map->x + xd + yd; yg2 = (int)(map->y - (xd + 1) / 2 + yd / 2 - zd * 2.0 - 2); //line(screen2, xg, yg, xg2, yg2, 144); do_line(screen2, xg, yg, xg2, yg2, COLOR_BROWN, dotted_line_proc); }
void draw_crusher(BITMAP *bmp) { static fixed angle = 0; int x, y, x1, y1, x2, y2; x = crusher.x+crusher.w/2-get_bitmap(BMP_CRUSHER)->w/2; y = crusher.y+crusher.h/2-get_bitmap(BMP_CRUSHER)->h/2+8; /* crusher body */ draw_sprite(bmp, get_bitmap(BMP_CRUSHER), x, y); /* crusher motor */ draw_sprite(bmp, get_bitmap(BMP_CRUSHER_MOTOR), x1 = x-get_bitmap(BMP_CRUSHER_MOTOR)->w+1+rand()%3-1, y1 = y+rand()%3-1); /* crusher pulley */ rotate_sprite(bmp, get_bitmap(BMP_CRUSHER_PULLEY), x2 = x+17-get_bitmap(BMP_CRUSHER_PULLEY)->w/2+rand()%3-1, y2 = y+13-get_bitmap(BMP_CRUSHER_PULLEY)->h/2+rand()%3-1, angle); /* strap */ do_line(bmp, x1+12, y1+8, x2+get_bitmap(BMP_CRUSHER_PULLEY)->w/2-1, y2, makecol(0, 0, 0), strap_proc); do_line(bmp, x1+12, y1+18, x2+get_bitmap(BMP_CRUSHER_PULLEY)->w/2-1, y2+get_bitmap(BMP_CRUSHER_PULLEY)->h-1, makecol(0, 0, 0), strap_proc); angle = fadd(angle, itofix(16)); if (angle > itofix(256)) angle = fsub(angle, itofix(256)); /* scorer */ draw_sprite(bmp, get_bitmap(BMP_SCORER), x+get_bitmap(BMP_CRUSHER)->w, y+get_bitmap(BMP_CRUSHER)->h-get_bitmap(BMP_SCORER)->h); /* alarm */ if (alarm_time_blue >= 0) { masked_blit(get_bitmap(BMP_SCORER_ALARM), bmp, 0, 0, x+get_bitmap(BMP_CRUSHER)->w+63, y+get_bitmap(BMP_CRUSHER)->h-get_bitmap(BMP_SCORER)->h+27, 8, 9); } if (alarm_time_red >= 0) { masked_blit(get_bitmap(BMP_SCORER_ALARM), bmp, get_bitmap(BMP_SCORER_ALARM)->w-8, 0, x+get_bitmap(BMP_CRUSHER)->w+75, y+get_bitmap(BMP_CRUSHER)->h-get_bitmap(BMP_SCORER)->h+27, 8, 9); } }
int main(int argc, char* argv[]) { char buffer[BUF_SIZE]; char *s; size_t length; int line; s = buffer; length = 0; line = 0; do { char* nl = (char*) memchr( s, '\n', length ); if( nl == NULL ) { // no newline found; get more ssize_t len1; if( length == sizeof( buffer ) ) { fprintf( stdout, "Line %d too long: more than %zu characters\n", line + 1, sizeof( buffer ) ); return -1; } s = memmove( buffer, s, length ); len1 = read( 0, s + length, sizeof( buffer ) - length ); length += len1; if( len1 == 0 ) break; continue; } line++; if( do_line( s, nl - s ) ) { fprintf( stdout, "Line %d error\n", line ); return -1; } length -= nl - s + 1; s = nl + 1; } while( 1 ); if( do_line( s, length ) ) { fprintf( stdout, "Line %d error\n", line ); return -1; } return 0; }
void MarkSlope( PEDITOR pe, Image pImage ) { do_line( pImage, pe->ptN[0], pe->ptN[1] - MARK_SIZE, pe->ptN[0] + MARK_SIZE, pe->ptN[1] + MARK_SIZE, Color( 200, 200, 200 ) ); do_line( pImage, pe->ptN[0] + MARK_SIZE, pe->ptN[1] + MARK_SIZE, pe->ptN[0] - MARK_SIZE, pe->ptN[1] + MARK_SIZE, Color( 200, 200, 200 ) ); do_line( pImage, pe->ptN[0] - MARK_SIZE, pe->ptN[1] + MARK_SIZE, pe->ptN[0], pe->ptN[1] - MARK_SIZE, Color( 200, 200, 200 ) ); }
int com_line() { if (multiplot) { /* calls int_error() if it is not happy */ term_check_multiplot_okay(interactive); if (read_line("multiplot> ")) return (1); } else { if (read_line(PROMPT)) return (1); } /* So we can flag any new output: if false at time of error, * we reprint the command line before printing caret. * TRUE for interactive terminals, since the command line is typed. * FALSE for non-terminal stdin, so command line is printed anyway. * (DFK 11/89) */ screen_ok = interactive; if (do_line()) return (1); else return (0); }
int main(void) { char line[MAXLINE]; while(fgets(line,MAXLINE,stdin)!=NULL) do_line(line); exit(0); }
/** * Perform the user interface function of editing a program buffer. * @param program The base pointer to the buffer text to edit. * Never returns. */ void CVue::interpret() { if ( !m_running ) { reset(); do_new(); for(;;) { CARIBOU::CString output; show_prompt(); read_line(); if ( compile(output) ) { m_command = output; if (m_command.toInt()) { inherited::reset(); place(); } else { m_running = true; inherited::reset(); do_line(); m_running=false; } } } } inherited::interpret(); }
/* Rexx command line interface */ ULONG RexxInterface(PRXSTRING rxCmd, PUSHORT pusErr, PRXSTRING rxRc) { int rc; static JMP_BUF keepenv; int cmdlen; memcpy(keepenv, command_line_env, sizeof(JMP_BUF)); if (!SETJMP(command_line_env, 1)) { /* Set variable gp_input_line. Watch out for line length of NOT_ZERO_TERMINATED strings ! */ cmdlen = rxCmd->strlength + 1; /* FIXME HBB 20010121: 3rd argument doesn't make sense. Either * this should be gp_input_line_len, or it shouldn't use * safe_strncpy(), here */ safe_strncpy(gp_input_line, rxCmd->strptr, cmdlen); gp_input_line[cmdlen] = NUL; rc = do_line(); *pusErr = RXSUBCOM_OK; rxRc->strptr[0] = rc + '0'; rxRc->strptr[1] = NUL; rxRc->strlength = strlen(rxRc->strptr); } else { /* We end up here when bail_to_command_line() is called. Therefore sometimes this call should be avoided when executing a REXX program (e.g. 'Cancel' from PM GUI after a 'pause -1' command) */ *pusErr = RXSUBCOM_ERROR; RexxSetHalt(getpid(), 1); } memcpy(command_line_env, keepenv, sizeof(JMP_BUF)); return 0; }
int main(int argc, char **argv) { struct vfont *vfp; bu_setprogname(argv[0]); if (!get_args(argc, argv)) { fputs(usage, stderr); bu_exit(1, NULL); } if ((fbp = fb_open(framebuffer, scr_width, scr_height)) == NULL) { fprintf(stderr, "fblabel: Unable to open framebuffer %s\n", framebuffer); bu_exit(12, NULL); } if (clear) { fb_clear(fbp, PIXEL_NULL); } if ((vfp = vfont_get(font1)) == VFONT_NULL) { fprintf(stderr, "fblabel: Can't get font \"%s\"\n", font1 == NULL ? "(null)" : font1); bu_exit(1, NULL); } do_line(vfp, textstring); fb_close(fbp); vfont_free(vfp); return 0; }
nemo_main() { setparams(); read_data(); if (scanopt(method,"line")) { do_line(); } else if (scanopt(method,"ellipse")) { do_ellipse(); } else if (scanopt(method,"imageshift")) { do_imageshift(); } else if (scanopt(method,"plane")) { do_plane(); } else if (scanopt(method,"gauss1d")) { do_gauss1d(); } else if (scanopt(method,"gauss2d")) { do_gauss2d(); } else if (scanopt(method,"poly")) { do_poly(); } else if (scanopt(method,"area")) { do_area(); } else if (scanopt(method,"peak")) { do_peak(); } else if (scanopt(method,"zero")) { do_zero(); } else if (scanopt(method,"fourier")) { do_fourier(); } else error("fit=%s invalid; try [line,ellipse,imageshift,plane,gauss1d,gauss2d,poly,area,peak,zero,fourier]", getparam("fit")); if (outstr) strclose(outstr); }
static void DrawLine( Image pImage, PCVECTOR p, PCVECTOR m, RCOORD t1, RCOORD t2, CDATA c ) { VECTOR v1,v2; add( v1, scale( v1, m, t1 ), p ); add( v2, scale( v2, m, t2 ), p ); /* glBegin( GL_LINES ); glColor4ubv( (unsigned char *)&c ); glVertex3dv( v1 ); glVertex3dv( v2 ); glEnd(); glFlush(); */ //printf("end points = "); //PrintVector(v1); //PrintVector(v2); /*if( Clip( v1, v2, vc0.n, vc0.o ) && Clip( v1, v2, vc1.n, vc1.o ) && Clip( v1, v2, vc2.n, vc2.o ) && Clip( v1, v2, vc3.n, vc3.o ) && Clip( v1, v2, vc4.n, vc4.o ) ) */ { do_line( pImage, ProjectX( v1 ), ProjectY( v1 ), ProjectX( v2 ), ProjectY( v2 ), c ); } }
int main() { char line[MAXLINE]; while(fgets(line,sizeof(line),stdin)!=NULL) do_line(line); return 0; }
int main(void) { char line[MAXLINE]; if(setjmp(jmpbuffer) != 0) err_sys("setjmp error"); while(fgets(line,MAXLINE,stdin) != NULL) do_line(line); exit(0); }
int main ( int argc, char *argv[] ) { char line[MAXLINE]; while ( fgets(line, MAXLINE, stdin) != NULL) do_line(line); return 0; } /* ---------- end of function main ---------- */
void CrayonFrontLine(BITMAP *bmp, int x, int y, int colour) { Vector point(x, y); point += crayon_line_normal * (sin(points_down_line * crayon_line_wobble) * crayon_line_wobble_amplitude); do_line(bmp, prev_crayon_x, prev_crayon_y, point.XInt(), point.YInt(), colour, CrayonFrontPoint); prev_crayon_x = point.XInt(); prev_crayon_y = point.YInt(); }
int main(void) { char line[100]; if(setjmp(jmpbuf)!=0) printf("error"); while(fgets(line,100,stdin)!=NULL) do_line(line); exit(0); }
int main(void){ char line[MAXLINE]; if(setjmp(jmpbuffer)!=0) printf("ereeee"); while(fgets(line,MAXLINE,stdin)!=NULL){ do_line(line); } }
static void read_all_cnf (kpathsea kpse) { string *cnf_files; string *cnf; const_string cnf_path = kpathsea_init_format (kpse, kpse_cnf_format); kpse->cnf_hash = hash_create (CNF_HASH_SIZE); cnf_files = kpathsea_all_path_search (kpse, cnf_path, CNF_NAME); if (cnf_files && *cnf_files) { for (cnf = cnf_files; *cnf; cnf++) { string line; FILE *cnf_file = xfopen (*cnf, FOPEN_R_MODE); if (kpse->record_input) kpse->record_input (*cnf); while ((line = read_line (cnf_file)) != NULL) { unsigned len = strlen (line); /* Strip trailing spaces. */ while (len > 0 && ISSPACE(line[len-1])) { line[len - 1] = 0; --len; } /* Concatenate consecutive lines that end with \. */ while (len > 0 && line[len - 1] == '\\') { string next_line = read_line (cnf_file); line[len - 1] = 0; if (!next_line) { WARNING1 ("%s: Last line ends with \\", *cnf); } else { string new_line; new_line = concat (line, next_line); free (line); line = new_line; len = strlen (line); } } do_line (kpse, line); free (line); } xfclose (cnf_file, *cnf); free (*cnf); } free (cnf_files); } else { string warn = getenv ("KPATHSEA_WARNING"); if (!(warn && STREQ (warn, "0"))) { WARNING1 ("kpathsea: configuration file texmf.cnf not found in these directories: %s", cnf_path); } } }
void MarkOrigin( PEDITOR pe, Image pImage ) { do_line( pImage, pe->ptO[0] - MARK_SIZE, pe->ptO[1] - MARK_SIZE, pe->ptO[0] + MARK_SIZE, pe->ptO[1] - MARK_SIZE, Color( 200, 200, 200 ) ); do_line( pImage, pe->ptO[0] + MARK_SIZE, pe->ptO[1] - MARK_SIZE, pe->ptO[0] + MARK_SIZE, pe->ptO[1] + MARK_SIZE, Color( 200, 200, 200 ) ); do_line( pImage, pe->ptO[0] + MARK_SIZE, pe->ptO[1] + MARK_SIZE, pe->ptO[0] - MARK_SIZE, pe->ptO[1] + MARK_SIZE, Color( 200, 200, 200 ) ); do_line( pImage, pe->ptO[0] - MARK_SIZE, pe->ptO[1] + MARK_SIZE, pe->ptO[0] - MARK_SIZE, pe->ptO[1] - MARK_SIZE, Color( 200, 200, 200 ) ); }
int main(int argc,char *argv[]) { char line[MAXLINE]; if(setjmp(jmpbuffer)!=0) printf("error!\n"); while(fgets(line,MAXLINE,stdin)!=NULL) do_line(line); exit(0); }
int main(int argc, char* argv[]) { int errors ; prog_name = *argv ; if( argc != 1 ) die("pure filter, takes no arguments") ; errors = 0 ; while( fgets(buffer, MAX_LINE, stdin)) errors += do_line(buffer) ; exit(errors ? 1 : 0 ) ; }
int main(void) { char line[MAXLINE]; if (setjmp(jumbuffer) != 0) printf("error"); while (fgets(line, MAXLINE, stdin) != NULL) do_line(line); exit(0); }
void miller(element_t z, element_t PR, element_t R, element_t P, element_t Q) { int m = mpz_sizeinbase(order, 2) - 2; element_t Z; element_t z1; element_t x1; element_init_same_as(Z, PR); element_set(Z, P); element_set1(z); element_init_same_as(z1, z); element_init_same_as(x1, z); do_vert(x1, PR, Q); element_printf("vert(P+R) %B\n", x1); do_line(z1, P, R, Q); element_printf("line(P,R) %B\n", z1); element_div(x1, x1, z1); element_printf("x1 %B\n", x1); element_set(z, x1); for (;;) { printf("iteration %d: %d\n", m, mpz_tstbit(order,m)); element_square(z, z); element_printf("squared: %B\n", z); do_tangent(z1, Z, Q); element_mul(z, z, z1); element_double(Z, Z); do_vert(z1, Z, Q); element_div(z, z, z1); element_printf("pre-if: %B\n", z); if (mpz_tstbit(order, m)) { element_mul(z, z, x1); do_vert(z1, P, Q); element_mul(z, z, z1); element_printf("done %B\n", z); /* do_line(z1, Z, P, Q); element_mul(z, z, z1); element_add(Z, Z, P); do_vert(z1, Z, Q); element_div(z, z, z1); */ } if (!m) break; m--; } element_clear(x1); element_clear(z1); }
char *to_string(doc *d) { int i; buf b; memset(&b, 0, sizeof(b)); for (i = 0; i < d->size; i++) do_line(&b, d, i); cput(&b, 0); return b.d; }
void firenewmissile() { destroyed=0; totalpoints = 0; curpoint = 0; x1 = rand() % (SCREEN_W-1); y1 = 20; x2 = rand() % (SCREEN_W-1); y2 = SCREEN_H-50; do_line(buffer,x1,y1,x2,y2,0,&doline); }
void rubberline(List thelist, int color) { int x1, x2, y1, y2; int x3, y3; Line_Type linedata; while (!(mouse_b & 2)) { //quick addin if (mouse_b & 1) { x3 = x1 = mouse_x; y3 = y1 = mouse_y; scare_mouse(); /* draw circle while waiting for mouse release */ while (mouse_b & 1) { x2 = mouse_x; y2 = mouse_y; if (x2 != x3 || y2 != y3) { rrestore(screen);//first time through ii=0 do_line(screen,x1,y1,x2,y2, color, rsave); x3 = x2; y3 = y2; } } rrestore(screen); x2 = mouse_x; y2 = mouse_y; linebres(x1,y1,x2,y2,color); linedata.p1.x = x1; linedata.p1.y = y1; linedata.p2.x = x2; linedata.p2.y = y2; linedata.color = color; linedata.width = 1; AddLine(thelist,linedata); unscare_mouse(); } }// end whileaddin }
int can_see_from(int x1, int y1, int x2, int y2) { line_failed = 0; lastcx = x1; lastcy = y1; if ((x1 == x2) && (y1 == y2)) return 1; do_line(wallscreen, x1, y1, x2, y2, 0, line_callback); if (line_failed == 0) return 1; return 0; }
int main(int argc, char **argv) { char line[MAXLINE]; int ret = 0; if ((ret = setjmp(jmpbuffer)) != 0) //类似于goto所用的tag,告诉longjmp应该返回到哪里 { printf("error:%d\n", ret); } while (fgets(line, MAXLINE, stdin) != NULL) { do_line(line); } return 0; }
/* * Program entry point. */ int main( int argc, char *argv[] ) /*********************************/ { FILE * infile; FILE * miffile; char * outdir; int alive = 1; int rc; /*** Parse the command line ***/ if( argc != 4 ) { printf( "Usage: ALIASGEN <alias_file> <output_dir\\> <objects_mif_file>\n" ); return( EXIT_FAILURE ); } infile = fopen( argv[1], "rt" ); /* open alias file */ if( infile == NULL ) { FatalError( "Cannot open '%s'.", argv[1] ); } outdir = argv[2]; /* get output directory */ miffile = fopen( argv[3], "wt" ); /* open objects.mif file */ if( miffile == NULL ) { FatalError( "Cannot create '%s'.", argv[3] ); } /*** Handle the alias entries, one by one ***/ while( alive ) { rc = do_line( infile, miffile, outdir ); switch( rc ) { case 0: /* ok, but not done */ alive = 0; break; case 2: /* comment */ break; case 1: /* got one more */ fputc( '.', stdout ); fflush( stdout ); break; default: Zoinks(); break; } } fputc( '\n', stdout ); return( EXIT_SUCCESS ); }