⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 draw.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	    set_echo_position( KEYBOARD,1, 0.01, 0.02);	    set_echo( KEYBOARD,1,1);		/* echo the text */	    set_keyboard( 1, 80, "Filename: ", 10);	/* set prompt string */	    await_keyboard( 1000000000,1, string, &length);	    if (string[length-1] == '\n') string[length-1] = '\0';	    save_segment( segnam, string);	    }}/*-------------------------------------------*/go_restore_segment()			/* restore a segment from disk */{	char string[80];  int length;        if (segopen) close_retained_segment();	opensegment = newseg++;	set_echo_position( KEYBOARD,1, 0.01, 0.02);/* move to start positn */	set_echo( KEYBOARD,1,1);		/* echo the text */	set_keyboard( 1, 80, "Filename: ", 10);	/* set user char buf size */	await_keyboard( 1000000000,1, string, &length);	if (string[length-1] == '\n') string[length-1] = '\0';	set_image_transformation_type( XLATE2);	if ( !restore_segment( opensegment, string )) {	    set_segment_detectability( opensegment, 5);	    segopen = FALSE;	    }}/*-------------------------------------------*/go_draw_text()				/* text draw */{    int butnum;    float wx, wy, x, y;    char string[80];  int length;    set_echo( LOCATOR,1, 1);			/* dingbat to start position */    do {	await_any_button_get_locator_2( 1000000,1, &butnum, &x, &y);	if (butnum == 3) return(0);    } while (butnum != 1);    set_echo_position( KEYBOARD,1, x, y);	/* move to start positn */    set_keyboard( 1, 80, "", 0);		/* set user char buf size */    map_ndc_to_world_2( x, y, &wx, &wy);    move_abs_2( wx, wy);    set_echo( KEYBOARD,1,1);			/* echo the text */    await_keyboard( 1000000000,1, string, &length);    set_pick_id( 1);    if (length && string[length-1] == '\n') string[length-1] = '\0';    text( string);    set_segment_detectability( opensegment, 10);    return(0);}/*-------------------------------------------*/go_draw_polyline( mode)	int mode;		/* polyline draw */{    int butnum;    float wx, wy, x, y;    set_echo( LOCATOR,1, 1);			/* dingbat to start position */    do {	await_any_button_get_locator_2( 1000000,1, &butnum, &x, &y);	if (butnum == 3) return(0);    } while (butnum != 1);    set_echo_position( LOCATOR,1, x, y);	/* move to start position */    map_ndc_to_world_2( x, y, &wx, &wy);    move_abs_2( wx, wy);    if (mode) set_echo( LOCATOR,1, 2);		/* rubberband to position */    else {	set_pick_id(1);	marker_abs_2( wx, wy);    }    do {	do {	    await_any_button_get_locator_2( 1000000,1, &butnum, &x, &y);	    if (butnum == 3) {		set_segment_detectability( opensegment, 10); return(0);	    }	} while (butnum != 1);        set_echo_position( LOCATOR,1, x, y);	map_ndc_to_world_2( x, y, &wx, &wy);	set_pick_id( 1);	if (mode) line_abs_2( wx, wy);	else marker_abs_2( wx, wy);    } while (TRUE);}/*-------------------------------------------*/go_draw_polygon()				/* polygon draw */{    int butnum;    float wx, wy, x, y;    set_echo( LOCATOR,1, 1);			/* dingbat to start position */    do {	await_any_button_get_locator_2( 1000000,1, &butnum, &x, &y);	if (butnum == 3) return(0);    } while (butnum != 1);    set_echo_position( LOCATOR,1, x, y);	/* move to start position */    map_ndc_to_world_2( x, y, &wx, &wy);    move_abs_2( wx, wy);    pointcount = 0;    xlist[pointcount] = wx;    ylist[pointcount++] = wy;    set_echo( LOCATOR,1, 2);			/* rubberband to position */    do {	do {	    await_any_button_get_locator_2( 1000000,1, &butnum, &x, &y);	    if (butnum == 3 || pointcount > 98) {		set_pick_id( 1);		move_abs_2( xlist[0], ylist[0]);		polygon_abs_2( &xlist[0], &ylist[0], pointcount);		move_abs_2( xlist[0], ylist[0]);		polyline_abs_2( &xlist[1], &ylist[1], pointcount-1);    		set_segment_detectability( opensegment, 5);		return(0);		}	} while (butnum != 1);        set_echo_position( LOCATOR,1, x, y);	map_ndc_to_world_2( x, y, &wx, &wy);	line_abs_2( wx, wy);	xlist[pointcount] = wx;	ylist[pointcount++] = wy;    } while (TRUE);}/*-----------------------------------------*/set_up_core(argv) char *argv[];{    get_view_surface(our_surface,argv);    our_surface->cmapsize = MAPSIZE;    our_surface->cmapname[0] = '\0';    if ( initialize_core(DYNAMICC, SYNCHRONOUS, THREED)) exit(0);    if (initialize_view_surface( our_surface, FALSE)) exit(0);    initialize_device( BUTTON, 1);		/* initialize input devices */    initialize_device( BUTTON, 2);		/* initialize input devices */    initialize_device( BUTTON, 3);		/* initialize input devices */    initialize_device( LOCATOR, 1);    initialize_device( PICK, 1);    initialize_device( KEYBOARD, 1);    set_keyboard( 1, 80, " ", 1);		/* set user char buf size */    set_echo_position( LOCATOR, 1, 0., 0.);    set_echo_surface( LOCATOR, 1, our_surface);    set_echo_surface( PICK, 1, our_surface);    set_echo_surface( KEYBOARD, 1, our_surface);    set_pick(1,0.001);    set_window(0.,511.,0.,383.);    set_viewport_2( .01,.99,.006, .744);	/* init viewing transform */    set_window_clipping(FALSE);    set_output_clipping(TRUE);    select_view_surface(our_surface);}/*------------------------------------------*/static float colorbox[4] = {0., 25.,   0., -25.};static float colorboy[4] = {25., 0., -25.,   0.};static float attbox[5] = { 0.,  120., 0.,  -120. };static float attboy[5] = { 190.,0.,  -190.,  0.};static float redlist[MAPSIZE], grnlist[MAPSIZE], blulist[MAPSIZE];static float redtex[] ={.9961,.1765,.1334,.1334,.4667,.1334,.1334,.1334,.8001,.2667,.5334,.0};static float grntex[] ={.5334,.2079,.5334,.5334,.5334,.5020,.5020,.3334,.2667,.5334,.5334,.2667};static float blutex[] = {   0.,   0.,.4001,   0.,.2118,.3529,.6471,.4001,.4001,.4001,.4001,.3882};build_menus(){    int i, j;    float white=1.0;    define_color_indices( our_surface,MAPSIZE-1,MAPSIZE-1,&white,&white,&white);    inquire_color_indices(our_surface,0,MAPSIZE-1,redlist,grnlist,blulist);    if(!colorflag) {        for (i=0;i<12;i++) {            redlist[colortable[i]]=redtex[i];            grnlist[colortable[i]]=grntex[i];            blulist[colortable[i]]=blutex[i];            define_color_indices(our_surface,0,MAPSIZE-1,redlist,grnlist,blulist);            }        }            set_image_transformation_type(XLATE2);    create_retained_segment( main_menu);			/* MAIN MENU  */	 set_primitive_attributes( &PRIMATTS);	 move_abs_2( 3., 116.);   	 line_rel_2(0., 194.);	 set_font( 1); set_charsize( 4.,3.);	 move_abs_2( 6., 300.); set_pick_id( 1); text("New Seg xlate");	 move_abs_2( 6., 288.); set_pick_id( 2); text("New Seg xform");	 move_abs_2( 6., 276.); set_pick_id( 3); text("Delete Seg");	 move_abs_2( 6., 264.); set_pick_id( 4); text("Lines");	 move_abs_2( 6., 252.); set_pick_id( 5); text("Polygon");	 move_abs_2( 6., 240.); set_pick_id( 6); text("Raster");	 move_abs_2( 6., 228.); set_pick_id( 7); text("Text");	 move_abs_2( 6., 216.); set_pick_id( 8); text("Marker");	 move_abs_2( 6., 204.); set_pick_id( 9); text("Move");	 move_abs_2( 6., 192.); set_pick_id(10); text("Rotate");	 move_abs_2( 6., 180.); set_pick_id(11); text("Scale");	 move_abs_2( 6., 168.); set_pick_id(12); text("Attributes");	 move_abs_2( 6., 156.); set_pick_id(13); text("Save Seg");	 move_abs_2( 6., 144.); set_pick_id(14); text("Restore Seg");	 move_abs_2( 6., 132.); set_pick_id(15); text("Exit");    close_retained_segment();    set_segment_detectability( main_menu, 100);    set_segment_visibility( main_menu, FALSE);    create_retained_segment( attribute_menu);		/* ATTRIBUTE MENU */	set_primitive_attributes( &PRIMATTS);	move_abs_2( 5., 120.);   	polyline_rel_2(attbox,attboy,4);        set_charsize( 9.,9.);  set_charprecision(CHARACTER);	for (i=ROMAN; i<=SYMBOLS; i++) {	/* font selections */	    set_font( i);			/* pickids 2...7   */	    move_abs_2( (i%3)*40.+8., 300.-(20.*(i/3)) ); set_pick_id( 2+i);	    if (i==SYMBOLS) text("* , -");	    else text("Abc");	}	set_linewidth( 0.);	for (i=SOLID; i<=DOTDASHED; i++) {	/* linestyle selections */	    set_linestyle( i);			/* pickids 8...11 */	    move_abs_2( 8., 260.-i*10.); set_pick_id( 8+i);	    line_abs_2( 75., 260.-i*10.);	}	set_linestyle(SOLID);	for (i=0; i<4; i++) {			/* linewidth selections */	    set_linewidth( i*0.25);		/* pickids 16...19      */	    move_abs_2( 85., 260.-i*10.); set_pick_id( 16+i);	    line_abs_2( 122., 260.-i*10.);	}	for (i=0; i<3; i++) {			/* color selections */	    for (j=0; j<4; j++) {		/* pickids 20...31  */		set_fill_index( colortable[i*4+j]);		move_abs_2( j*30.+8., 200.-i*30.); set_pick_id( 20+i*4+j);		polygon_rel_2( colorbox, colorboy, 4);	    }	}    close_retained_segment();    set_segment_detectability( attribute_menu, 100);    set_segment_visibility( attribute_menu, FALSE);    return(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -