예제 #1
0
void key_s3c(void)
{
int which_key,i;
while((rPDATG & 0xf0)==0xf0);
which_key=rPDATG&0xf0;
    switch(which_key)
    {
case 0xe0:
   Led_Display(0x1);
   point.y_point-=20;
   if(point.y_point<20)
   point.y_point=200;
   break;
case 0xd0:
   Led_Display(0x2);
   point.x_point-=20;
   if(point.x_point<20)
   point.x_point=200;
   break;
case 0xb0:
   Led_Display(0x4);
   if( map[point.y_map][point.x_map]==0 )
{
change_color();
map[point.y_map][point.x_map]=point.color;
draw_map();

if( if_won(point.y_map,point.x_map,point.color) )
{
GUI_SetTextMode(GUI_DM_TRANS); //设置为透明
GUI_SetFont(&GUI_Font8x16x1x2);
GUI_DispStringAt("win!",250,90);

for(i=0;i<20;i++)
GUI_Delay(1000);
map_initial();

GUI_SetDrawMode(GUI_DM_NORMAL);
GUI_SetColor(GUI_GREEN);
GUI_FillRect(0,0,320,240);
draw_net();
draw_point();
}

}
   break;
case 0x70:
   Led_Display(0x7);
   /*
   point.x_point+=20;
   if(point.x_point>200)
   point.x_point-=20;*/
   break;
default :
   break;
    }
    
    
}
예제 #2
0
파일: text.c 프로젝트: MichielPater/dfc
/*
 * Display percentage
 * @perct: percentage
 */
static void
text_disp_perct(double perct)
{
	change_color(perct);
	(void)printf("%*.1f", max.perctused, perct);
	reset_color();
	(void)printf("%%");
}
예제 #3
0
파일: hook.c 프로젝트: tandrieu42/Fractol
int		key_hook(int keycode, t_init *st)
{
	if (keycode == 53)
		exit(0);
	if (keycode == 123 || keycode == 124 || keycode == 125 || keycode == 126)
		move(keycode, st);
	if (keycode == 65)
		change_color(st);
	return (0);
}
예제 #4
0
void game() {
    set_palette(desktop_palette);
    buffer = create_bitmap(640, 480);
    bc_buffer = create_bitmap(640, 480);
    bmp = create_bitmap(30, 30);
    clear_to_color(bmp, 0);
    clear_to_color(buffer, 1);
    clear_to_color(bc_buffer, 3); 
    change_color(0, 0, 0);
    do_dialog(main_dialog, -1);
    
}
예제 #5
0
static gboolean check_at(GtkText *gtktext, int from_pos) {
	int start, end;
	char buf[BUFSIZE];

	if (!get_word_from_pos(gtktext, from_pos, buf, &start, &end)) {
		return FALSE;
	}

	if (misspelled_test(buf)) {
		if (highlight.pixel == 0) {
			/* add an entry for the highlight in the color map. */
			GdkColormap *gc = gtk_widget_get_colormap(GTK_WIDGET(gtktext));
			gdk_colormap_alloc_color(gc, &highlight, FALSE, TRUE);;
		}
		change_color(gtktext, start, end, &highlight);
		return TRUE;
	} else { 
		change_color(gtktext, start, end, 
				&(GTK_WIDGET(gtktext)->style->fg[0]));
		return FALSE;
	}
}
예제 #6
0
//@@@@@@@@@@@@@@@@@@@@@@  MAIN  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
void Main(void)
{
int i=0,j=0;


GUI_Init();
GUI_SetBkColor(GUI_GREEN);
GUI_Clear();
GUI_SetColor(GUI_BLACK);
point.x_point=20;point.y_point=20;
draw_net();
draw_point();
draw_curcolor(270,50,1);

while(1)
{
store_x=point.x_point;
store_y=point.y_point;


//Button();
key_s3c();
change_point();
draw_point();

if( (store_x!=point.x_point)||(store_y!=point.y_point) )
delete_point();

draw_map();
change_color();
draw_curcolor(270,50,point.color);
change_color();


GUI_Delay(3000);
}

}
예제 #7
0
파일: text.c 프로젝트: MichielPater/dfc
/*
 * Display used, available and total correctly formatted
 * @n: number to print
 * @perct: percentage (useful for finding which color to use)
 * @req_width: required width (used for terminal display, otherwise can be 0)
 */
static void
text_disp_uat(double n, double perct, int req_width)
{
	int i;

	i = 0;

	if (unitflag == 'h')
		i = humanize(&n);

	change_color(perct);
	(void)printf("%*.1f", req_width - 1, n); /* -1 for the unit symbol */
	reset_color();
	print_unit(i, 1);
}
예제 #8
0
파일: main.c 프로젝트: zzjin13/OS_LAB
void printPath(char* path){
	int i = 0;
	change_color();
	char* p = "/";
	while (i < strlen(path)-1){
		if (path[i] != ' '){
			my_print(&path[i], 1);
		}
		if (i % 8 == 7){
			my_print(p, 1);
		}
		i++;
	}
	ret_color();

	my_print("\n",1);
}
int win_settings::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QDialog::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: load_factory_settings(); break;
        case 1: load_general_default_settings(); break;
        case 2: change_color((*reinterpret_cast< QTableWidgetItem*(*)>(_a[1]))); break;
        case 3: timeout(); break;
        case 4: grid_UM_changed((*reinterpret_cast< int(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
예제 #10
0
void Ambient_Light::key_press(bool is_key_press[128], Camera camera)
{
	if (is_key_press['j'])
		change_color(vec4(1.0f * color_speed, 0.0f, 0.0f));
	if (is_key_press['m'])
		change_color(vec4(1.0f * -color_speed, 0.0f, 0.0f));
	if (is_key_press['k'])
		change_color(vec4(0.0f, 1.0f * color_speed, 0.0f));
	if (is_key_press[','])
		change_color(vec4(0.0f, 1.0f * -color_speed, 0.0f));
	if (is_key_press['l'])
		change_color(vec4(0.0f, 0.0f, 1.0f * color_speed));
	if (is_key_press['.'])
		change_color(vec4(0.0f, 0.0f, 1.0f * -color_speed));
}
예제 #11
0
파일: key_hook.c 프로젝트: madeka/fractol
int			key_hook(int keycode, t_env *env)
{
    if (keycode == KEYCODE_ESC)
    {
        mlx_destroy_image(env->mlx, env->img);
        exit(0);
    }
    if (keycode == KEYCODE_H)
        env->menu = (env->menu + 1) % 2;
    else
    {
        move(keycode, env);
        zoom(keycode, env);
        change_fractal(keycode, env);
        change_color(keycode, env);
    }
    mlx_destroy_image(env->mlx, env->img);
    init_img(env);
    draw_fractal(env);
    return (keycode);
}
예제 #12
0
int main()
{
  init_environment();
  init_data();
  init_display();

  cuss::interface i_editor;
  Window w_editor(0, 0, 80, 24);
  if (!i_editor.load_from_file("cuss/i_element_ed.cuss")) {
    debugmsg("Can't load cuss/i_element_ed.cuss");
    end_display();
    return 1;
  }
  std::vector<std::string> element_names;
  std::vector<std::string> transform_names;
  std::vector<std::string> damage_names;
  i_editor.ref_data("list_elements", &element_names);
  i_editor.ref_data("list_transformations", &transform_names);
  i_editor.ref_data("list_damagetypes", &damage_names);
  i_editor.select  ("list_elements");

  bool quit = false;
  while (!quit) {
    element_names = get_names();
    cuss::element* selected = i_editor.selected();
    int ele_num = i_editor.get_int("list_elements");
    element* cur_element = NULL;
    if (ele_num < ELEMENTS_POOL.size()) {
      cur_element = &(ELEMENTS_POOL[ele_num]);
      std::stringstream color_data;
      color_data << "<c=" << color_tag_name(cur_element->color) <<
                    ">************<c=/>";
      i_editor.set_data("text_color", color_data.str());
      i_editor.ref_data("entry_name", &(cur_element->name));
    }
    transform_names = get_tra_names(cur_element);
    damage_names    = get_dmg_names(cur_element);
    i_editor.draw(&w_editor);

    long ch = getch();
    if (selected->name == "entry_name" &&
        ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == ' ')) {
      cur_element->name += ch;

    } else if (selected->name == "entry_name" && is_backspace(ch) &&
               !cur_element->name.empty()) {
      cur_element->name =
       cur_element->name.substr( 0, cur_element->name.length() - 1);

    } else if (ch == 's' || ch == 'S') {
      quit = true;

    } else if (ch == 'c' || ch == 'C') {
      change_color(cur_element);

    } else if (ch == 'a' || ch == 'A') {
// Where are we adding an element?
      if (selected->name == "list_elements") {
        element tmp;
        tmp.name = string_input_popup("Name:");
        ELEMENTS_POOL.push_back(tmp);
        i_editor.set_data("list_elements", 999);
      } else if (selected->name == "list_transformations") {
        add_transformation(cur_element);
        i_editor.set_data("list_transformations", 0);
      } else if (selected->name == "list_damagetypes") {
        add_damagetype(cur_element);
        i_editor.set_data("list_damagetypes", 0);
      }
    } else if (ch == 'd' || ch == 'D') {
// Where are we deleting an element?
      if (selected->name == "list_elements" && cur_element) {
        delete_element(ele_num);
        i_editor.set_data("list_elements", 0);
      } else if (selected->name == "list_transformations") {
        int index = i_editor.get_int("list_transformations");
        if (cur_element && index >= 0 &&
            index < cur_element->transformations.size()) {
          delete_transformation(cur_element, index);
          i_editor.set_data("list_transformations", 0);
        }
      } else if (selected->name == "list_damagetypes") {
        int index = i_editor.get_int("list_damagetypes");
        if (cur_element && index >= 0 &&
            index < cur_element->damages.size()) {
          delete_damagetype(cur_element, index);
          i_editor.set_data("list_damagetypes", 0);
        }
      }
    } else {
      i_editor.handle_action(ch);
    }
  } // while (!quit)

  save_data();
  end_display();
  return 0;
}
예제 #13
0
void set_map(char *name, char *name1, char *name2, struct Cell_head window,
	     int top, int bot, int left, int right)
{
    char cmd[30], cmd1[30], cmd2[30], **sel;
    int i, j, btn, d, class, top0, bot0, right0, left0, paint = 0, method;
    double msc[2], dtmp;


    /* VARIABLES
       IN:
       name = raster map name to be set up
       name1 = overlay vector map name
       name2 = overlay site map name
     */

    colors_old = (struct Colors *)G_malloc(1 * sizeof(struct Colors));
    Rast_init_colors(colors_old);
    Rast_read_colors(name, G_mapset(), colors_old);

    G_system("clear");
    paint_map(name, name1, name2);
    paint = 1;

    /* setup the screen to raster map 
       coordinate conversion system */

    scr_cell(&window, top, bot, left, right, msc);

    top0 = top;
    bot0 = bot;
    left0 = left;
    right0 = right;

    /* display the menu and instructions */
  again:
    if (!paint) {
	if (G_yes
	    ("\n    Refresh the screen before choosing more setup?  ", 1))
	    paint_map(name, name1, name2);
    }
    else
	G_system("clear");

    fprintf(stderr, "\n\n    CHOOSE THE SETUP OPTION:\n\n");
    fprintf(stderr, "       Draw sampling regions                1\n");
    fprintf(stderr, "       Setup a sampling frame               2\n");
    fprintf(stderr, "       Setup sampling units                 3\n");
    fprintf(stderr, "       Setup a moving window                4\n");
    fprintf(stderr, "       Setup group or class limits          5\n");
    fprintf(stderr, "       Change the raster map color table    6\n");
    fprintf(stderr, "       Exit and save setup                  7\n");

    do {
	fprintf(stderr, "\n                                Which Number?   ");
	dtmp = 5.0;
	numtrap(1, &dtmp);
	if ((method = fabs(dtmp)) > 7 || method < 1) {
	    fprintf(stderr, "\n    Choice must between 1-7; try again");
	}
    }
    while (method > 7 || method < 1);

    /* setup regions */
    if (method == 1)
	set_rgn(msc, name, name1, name2);

    /* setup the sampling frame */
    else if (method == 2) {
	top = top0;
	bot = bot0;
	right = right0;
	left = left0;
	set_frame(msc, &top, &bot, &left, &right);
    }

    /* setup sampling units */

    else if (method == 3) {
	sample(top, bot, left, right, name, name1, name2, msc);
    }

    /* setup the moving window */

    else if (method == 4) {
	mov_wind(top, bot, left, right, name, name1, name2, msc);
    }

    /* setup group/class limits */

    else if (method == 5) {

	/* setup the buffer to store the user's input */

	sel = (char **)G_malloc(10 * sizeof(char *));
	for (i = 0; i < 9; i++)
	    sel[i] = (char *)G_calloc(2, sizeof(char));

      back:
	ask_group(sel);

	/* check for no input */

	if (sel[0][0] != 'x' && sel[1][0] != 'x' && sel[2][0] != 'x' &&
	    sel[3][0] != 'x' && sel[4][0] != 'x' && sel[5][0] != 'x' &&
	    sel[6][0] != 'x' && sel[7][0] != 'x' && sel[8][0] != 'x') {
	    G_system("clear");
	    fprintf(stderr,
		    "    Did you mean to not make any attribute group");
	    if (!G_yes("\n    or index class setup choices?   ", 1))
		goto back;
	}

	/* if there is input, then invoke the
	   group/class setup module and then free
	   the memory allocated for selections */

	else {
	    get_group_drv(sel);
	    for (i = 0; i < 9; i++)
		G_free(sel[i]);
	    G_free(sel);
	}
    }

    /* change color tables */

    else if (method == 6)
	change_color(name, name1, name2);

    /* reset the colortable and exit */

    else if (method == 7) {
	Rast_write_colors(name, G_mapset(), colors_old);
	Rast_free_colors(colors_old);
	/*     R_close_driver(); */
	G_system("d.frame -e");
	exit(0);
    }
    paint = 0;
    goto again;
    return;
}
예제 #14
0
//@@@@@@@@@@@@@@@@@@@@@  屏幕上显示的按键  @@@@@@@@@@@@@@@@@@@@@@@@@@
static void Button(void) 
{

 BUTTON_Handle hButton[6];
 int t=0;
 int i=0;
 /* Create the button*/
      //BUTTON_SetBkColor(hButton[0],0,GUI_RED);

 hButton[0] = BUTTON_Create(260, 160, 20, 20, 1, WM_CF_SHOW);
 hButton[1] = BUTTON_Create(240, 180, 20, 20, 2, WM_CF_SHOW);
 hButton[2] = BUTTON_Create(260, 180, 20, 20, 3, WM_CF_SHOW);
 hButton[3] = BUTTON_Create(280, 180, 20, 20, 4, WM_CF_SHOW);
 hButton[4] = BUTTON_Create(260, 220, 20, 20, 5, WM_CF_SHOW);
 //hButton[5] = BUTTON_Create(240, 220, 20, 20, 6, WM_CF_SHOW);

 BUTTON_SetText(hButton[0], "w");
 BUTTON_SetText(hButton[1], "a");
 BUTTON_SetText(hButton[2], "s");
 BUTTON_SetText(hButton[3], "d");
 BUTTON_SetText(hButton[4], "B");
 //BUTTON_SetText(hButton[5], "W");

 t=GUI_WaitKey();
 
 switch( t )
 {
 case 1:
 point.y_point-=20;
 if(point.y_point<20)
 point.y_point+=20;
 break;
 case 2:
 point.x_point-=20;
 if(point.x_point<20)
 point.x_point+=20;
 break;
 case 3:
 point.y_point+=20;
 if(point.y_point>200)
 point.y_point-=20;
 break;
 case 4:
 point.x_point+=20;
 if(point.x_point>200)
 point.x_point-=20;
 break;
 case 5:
 if( map[point.y_map][point.x_map]==0 )
 {
change_color();
map[point.y_map][point.x_map]=point.color;
draw_map();

if( if_won(point.y_map,point.x_map,point.color) )
{
GUI_SetTextMode(GUI_DM_TRANS); //设置为透明
GUI_SetFont(&GUI_Font8x16x1x2);
GUI_DispStringAt("win!",250,90);

for(i=0;i<5;i++)
GUI_Delay(1000);
map_initial();

GUI_SetDrawMode(GUI_DM_NORMAL);
GUI_SetColor(GUI_GREEN);
GUI_FillRect(0,0,320,240);
draw_net();
draw_point();
}

 }
 break;
 case 6:
 /*
 if( map[point.y_map][point.x_map]==0 )
map[point.y_map][point.x_map]=1;
 */
 break;
 default:

 break;
 
 }

 
 
 for(t=0;t<6;t++)
BUTTON_Delete(hButton[t]);
 
}
예제 #15
0
파일: my_main.c 프로젝트: stuydw/mdl
void my_main( int polygons ) {

    int i;
    double step = 0.01;
    double xval, yval, zval;
    double theta; // rotation angle measure
    int xyz; // rotation axis
    double w,h,d; // box dimensions
    double rad; // sphere/torus radius
    double rad2; // torus radius 2
    struct matrix *transform;
    struct matrix *tmp;
    struct stack *s;
    screen t;
    color g;

    g = change_color(6);

    s = new_stack();
    tmp = new_matrix(4, 1000);
    clear_screen( t );

    for (i=0; i<lastop; i++) {
        switch (op[i].opcode) {
        case PUSH:
            //if (i == 0) {
            tmp = new_matrix(4,4);
            ident(tmp);
            //}
            push(s);
            continue;
        case POP:
            pop(s);
            continue;
        case MOVE:
            xval = op[i].op.move.d[0];
            yval = op[i].op.move.d[1];
            zval = op[i].op.move.d[2];
            transform = make_translate(xval, yval, zval);
            matrix_mult(s->data[s->top], transform);
            s->data[s->top] = transform;
            continue;
        case SCALE:
            xval = op[i].op.scale.d[0];
            yval = op[i].op.scale.d[1];
            zval = op[i].op.scale.d[2];
            transform = make_scale(xval, yval, zval);
            matrix_mult(s->data[s->top], transform);
            s->data[s->top] = transform;
            continue;
        case ROTATE:
            xyz = op[i].op.rotate.axis;
            theta = op[i].op.rotate.degrees;
            if (xyz == 0)
                transform = make_rotX(theta);
            if (xyz == 1)
                transform = make_rotY(theta);
            if (xyz == 2)
                transform = make_rotZ(theta);
            matrix_mult(s->data[s->top], transform);
            s->data[s->top] = transform;
            continue;
        case BOX:
            xval = op[i].op.box.d0[0];
            yval = op[i].op.box.d0[1];
            zval = op[i].op.box.d0[2];
            w = op[i].op.box.d1[0];
            h = op[i].op.box.d1[1];
            d = op[i].op.box.d1[2];
            add_box(tmp, xval, yval, zval, w, h, d);
            matrix_mult(s->data[s->top], tmp);
            draw_polygons(tmp, t, g);
            continue;
        case SPHERE:
            xval = op[i].op.sphere.d[0];
            yval = op[i].op.sphere.d[1];
            zval = op[i].op.sphere.d[2];
            rad = op[i].op.sphere.r;
            add_sphere(tmp, xval, yval, zval, rad, step);
            matrix_mult(s->data[s->top], tmp);
            draw_polygons(tmp, t, g);
            continue;
        case TORUS:
            xval = op[i].op.torus.d[0];
            yval = op[i].op.torus.d[1];
            zval = op[i].op.torus.d[2];
            rad = op[i].op.torus.r0;
            rad2 = op[i].op.torus.r1;
            add_torus(tmp, xval, yval, zval, rad, rad2, step);
            matrix_mult(s->data[s->top], tmp);
            draw_polygons(tmp, t, g);
            continue;
        case LINE:
            xval = op[i].op.line.p0[0];
            yval = op[i].op.line.p0[1];
            zval = op[i].op.line.p0[2];
            w = op[i].op.line.p1[0];
            h = op[i].op.line.p1[1];
            d = op[i].op.line.p1[2];
            add_edge(tmp, xval, yval, zval, w, h, d);
            matrix_mult(s->data[s->top], tmp);
            draw_lines(tmp, t, g);
            continue;
        case SAVE:
            save_extension(t, op[i].op.save.p->name);
            continue;
        case DISPLAY:
            display(t);
            continue;
        case COMMENT:
            continue;
        }
    }
}
예제 #16
0
파일: ssx.c 프로젝트: srs51/SRS-3000
static void
process(SSDATA *d,int n,double *t)
{
	PROPERTIES p;
	int choice;

	enum {Next,Time,Mass,Bounds,ComPos,ComVel,AngMom,VelDsp,Color,Units,
			  Offsets,Masses,Radii,End};

	while (/*CONSTCOND*/1) {

		ss_analyze(d,n,&p);

		(void) printf("%2i. Time = %g\n",Time,*t);
		(void) printf("%2i. Total mass = %g\n",Mass,p.total_mass);
		(void) printf("%2i. Bounds: x=[%g,%g]\n"
					  "            y=[%g,%g]\n"
					  "            z=[%g,%g]\n",Bounds,
					  p.bnd_min[X],p.bnd_max[X],
					  p.bnd_min[Y],p.bnd_max[Y],
					  p.bnd_min[Z],p.bnd_max[Z]);
		(void) printf("%2i. Centre-of-mass position = %g %g %g\n",ComPos,
					  p.com_pos[X],p.com_pos[Y],p.com_pos[Z]);
		(void) printf("%2i. Centre-of-mass velocity = %g %g %g\n",ComVel,
					  p.com_vel[X],p.com_vel[Y],p.com_vel[Z]);
		(void) printf("%2i. Specific angular momentum = %g %g %g\n",AngMom,
					  p.ang_mom[X],p.ang_mom[Y],p.ang_mom[Z]);
		(void) printf("%2i. Velocity dispersion = %g %g %g\n",VelDsp,
					  p.vel_dsp[X],p.vel_dsp[Y],p.vel_dsp[Z]);
		(void) printf("%2i. Dominant color = %i (%s)\n",Color,p.color,
					  color_str(p.color));
		(void) printf("%2i. Units\n",Units);
		(void) printf("%2i. Offsets\n",Offsets);
		(void) printf("%2i. Particle masses\n",Masses);
		(void) printf("%2i. Particle radii\n",Radii);

		do {
			(void) printf("Enter number to change (or 0 to continue): ");
			(void) scanf("%i",&choice);
			} while (choice < Next || choice >= End);
		
		(void) getchar();

		if (choice == Next) return;

		switch(choice) {
		case Time:
			do {
				(void) printf("Enter new time: ");
				(void) scanf("%lf",t);
				(void) getchar();
				} while (*t < 0);
			break;
		case Mass:
			{
			double f;
			do get_scaling(&f,NegativeOK);
			while (f == 0);
			if (f < 0) f = -f/p.total_mass;
			scale_mass(d,n,f);
			break;
			}
		case Bounds:
			{
			double f,min,max;
			int i,choice;
			do {
				do {
					(void) printf("%i. Change x bounds (now [%g,%g])\n",X + 1,
								  p.bnd_min[X],p.bnd_max[X]);
					(void) printf("%i. Change y bounds (now [%g,%g])\n",Y + 1,
								  p.bnd_min[Y],p.bnd_max[Y]);
					(void) printf("%i. Change z bounds (now [%g,%g])\n",Z + 1,
								  p.bnd_min[Z],p.bnd_max[Z]);
					(void) printf("Your choice (or 0 when done): ");
					(void) scanf("%i",&choice);
					(void) getchar();
					} while (choice < 0 || choice > N_DIM);
				if (choice == 0) break;
				--choice; /* put back in range [X,Z] */
				if (p.bnd_min[choice] == p.bnd_max[choice]) {
					(void) printf("Chosen dimension is degenerate\n");
					continue;
					}
				do {
					(void) printf("Enter new bounds (min max): ");
					(void) scanf("%lf%lf",&min,&max);
					(void) getchar();
					} while (min > max);
				if (min == max &&
					get_yn("Zero velocities for this component","y"))
					for (i=0;i<n;i++)
						d[i].vel[choice] = 0;
				f = (max - min)/(p.bnd_max[choice] - p.bnd_min[choice]);
				for (i=0;i<n;i++)
					d[i].pos[choice] =
						(d[i].pos[choice] - p.bnd_min[choice])*f + min;
				p.bnd_min[choice] = min;
				p.bnd_max[choice] = max;
				} while (/*CONSTCOND*/1);
			break;
			}
		case ComPos:
			{
			VECTOR v;
			if (MAG(p.com_pos) && get_yn("Scale the magnitude","y")) {
				double f;
				get_scaling(&f,NegativeOK);
				COPY_VEC(p.com_pos,v);
				if (f < 0) f = -f/MAG(v);
				SCALE_VEC(v,f);
				}
			else get_components(v);
			adj_com_pos(d,n,&p,v);
			break;
			}
		case ComVel:
			{
			VECTOR v;
			if (MAG(p.com_vel) && get_yn("Scale the magnitude","y")) {
				double f;
				get_scaling(&f,NegativeOK);
				COPY_VEC(p.com_vel,v);
				if (f < 0) f = -f/MAG(v);
				SCALE_VEC(v,f);
				}
			else get_components(v);
			adj_com_vel(d,n,&p,v);
			break;
			}
		case AngMom:
			{
			VECTOR v;
			(void) printf("NOTE: specific angular momentum is measured with\n"
						  "respect to fixed space frame centred at (0,0,0)\n"
						  "and does not take particle spins into account\n");
			if (MAG(p.ang_mom) && get_yn("Scale the magnitude","y")) {
				double f;
				get_scaling(&f,NegativeOK);
				COPY_VEC(p.ang_mom,v);
				if (f < 0) f = -f/MAG(p.ang_mom);
				SCALE_VEC(v,f);
				}
			else if (get_yn("Scale the components","y")) {
				VECTOR u;
				int k;
				get_component_scaling(u);
				for (k=0;k<N_DIM;k++)
					v[k] = u[k]*p.ang_mom[k];
				}
			else get_components(v);
			adj_ang_mom(d,n,&p,v);
			break;
			}
		case VelDsp:
			{
			VECTOR v;
			(void) printf("NOTE: velocity dispersion is context dependent,\n"
						  "for now relative ONLY to center-of-mass velocity,\n"
						  "i.e. without considering bulk rotation or shear\n");
			if (!MAG(p.vel_dsp)) {
				(void) printf("Zero velocity dispersion -- cannot adjust\n");
				break;
				}
			if (get_yn("Scale the magnitude","y")) {
				double f;
				get_scaling(&f,NegativeOK);
				if (f < 0) f = -f/MAG(p.vel_dsp);
				SET_VEC(v,f,f,f);
				}
			else get_component_scaling(v);
			scale_vel_dsp(d,n,&p,v);
			break;
			}
		case Color:
			{
			int c;
			(void) printf("Color scheme:\n");
			for (c=BLACK;c<FIRST_GRAY;c++)
				(void) printf("%2i. %s\n",c,color_str(c));
			(void) printf("[values from %i to %i are levels of gray]\n",
						  FIRST_GRAY,LAST_GRAY);
			do {
				(void) printf("Enter new color: ");
				(void) scanf("%i",&c);
				(void) getchar();
				} while (c < 0 || c >= NUM_COLORS);
			change_color(d,n,c);
			break;
			}
		case Units:
			{
			enum {N,M,L,T,V,E};
			double f;
			int i,choice;
			(void) printf("NOTE: It is up to you to ensure dimensions are\n"
						  "internally consistent. pkdgrav assumes G == 1.\n");
			do {
				do {
					(void) printf("%i. Mass (particle masses)\n",M);
					(void) printf("%i. Length (particle radii, pos'ns)\n",L);
					(void) printf("%i. Time (time,particle spins)\n",T);
					(void) printf("%i. Velocity (particle velocities)\n",V);
					(void) printf("Select dimension to scale "
								  "(or 0 when done): ");
					(void) scanf("%i",&choice);
					(void) getchar();
					} while (choice < N || choice >= E);
				if (choice == N) break;
				switch (choice) {
				case M:
					(void) printf("M_Sun     = 1.9891e30 kg\n"
								  "M_Earth   = 5.9742e24 kg\n"
								  "M_Jupiter = 1.8992e27 kg\n"
								  "M_Saturn  = 5.6864e26 kg\n");
					get_scaling(&f,PositiveOnly);
					for (i=0;i<n;i++)
						d[i].mass *= f;
					break;
				case L:
					(void) printf("1 AU    = 1.49597892e11 m\n"
								  "R_Earth = 6.37814e6 m\n");
					get_scaling(&f,PositiveOnly);
					for (i=0;i<n;i++) {
						d[i].radius *= f;
						SCALE_VEC(d[i].pos,f);
						}
					break;
				case T:
					(void) printf("1 yr        = 3.15576e7 s\n"
								  "1 yr / 2 pi = 5.02255e6 s\n");
					get_scaling(&f,PositiveOnly);
					*t *= f;
					for (i=0;i<n;i++)
						NORM_VEC(d[i].spin,f);
					break;
				case V:
					(void) printf("V_Earth = 2.97852586e4 m/s\n");
					get_scaling(&f,PositiveOnly);
					for (i=0;i<n;i++)
						SCALE_VEC(d[i].vel,f);
					break;
				default:
					assert(0);
					}
				} while (/*CONSTCOND*/1);
			break;
			}
		case Offsets:
			{
			VECTOR v;
			int i;
			(void) printf("POSITION OFFSET (0 0 0 for none)...\n");
			get_components(v);
			for (i=0;i<n;i++)
				ADD_VEC(d[i].pos,v,d[i].pos);
			(void) printf("VELOCITY OFFSET (0 0 0 for none)...\n");
			get_components(v);
			for (i=0;i<n;i++)
				ADD_VEC(d[i].vel,v,d[i].vel);
			break;
			}
		case Masses:
			{
			double f;
			do get_scaling(&f,NegativeOK);
			while (f == 0);
			scale_masses(d,n,f);
			break;
			}
		case Radii:
			{
			double f;
			do get_scaling(&f,NegativeOK);
			while (f == 0);
			scale_radii(d,n,f);
			break;
			}
		default:
			assert(0);
			}
		}
	}
예제 #17
0
		void blue_pressed() { change_color(Color::blue); hide_menu(); }
main()
{
   int gd = DETECT,gm;

   int maxx,maxy,x,y,button,prevx,prevy,temp1,temp2,key,color;
   char ch = 'f' ;            // default free-hand drawing

   initgraph(&gd,&gm,"C:\\TC\\BGI");

   maxx = getmaxx();
   maxy = getmaxy();

   setcolor(BLUE);
   rectangle(0,0,maxx,maxy);

   setcolor(WHITE);
   settextstyle(SANS_SERIF_FONT,HORIZ_DIR,2);
   outtextxy(maxx/2-180,maxy-28,"<a href="http://www.programmingsimplified.com"">www.programmingsimplified.com"</a>);

   draw_color_panel();
   draw_shape_panel();

   setviewport(1,1,maxx-1,maxy-1,1);

   restrictmouseptr(1,1,maxx-1,maxy-1);
   showmouseptr();
   rectangle(2,2,518,427);
   setviewport(1,1,519,428,1);

   while(1)
   {
      if(kbhit())
      {
         key = get_key();

         if( key == 1 )
         {
            closegraph();
            exit(0);
         }
      }

      getmousepos(&button,&x,&y);

      if( button == 1 )
      {
         if( x > 4 && x < 635 && y > 431 && y < 457 )
            change_color( x, y );
         else if ( x > 529 && x < 625 && y > 40 && y < 250 )
             ch = change_shape( x, y );

         temp1 = x ;
         temp2 = y ;

         if ( ch == 'f' )
         {
            hidemouseptr();
            while( button == 1 )
            {
               line(temp1,temp2,x,y);
               temp1 = x;
               temp2 = y;
               getmousepos(&button,&x,&y);
            }
            showmouseptr();
         }

         while( button == 1)
            getmousepos(&button,&x,&y);

         /* to avoid interference of mouse while drawing */
         hidemouseptr();

         if( ch == 'p')
            putpixel(x,y,getcolor());

         else if ( ch == 'b' )
         {
            setfillstyle(SOLID_FILL,getcolor());
            bar(temp1,temp2,x,y);
         }
         else if ( ch == 'l')
            line(temp1,temp2,x,y);
         else if ( ch == 'e')
            ellipse(temp1,temp2,0,360,abs(x-temp1),abs(y-temp2));
         else if ( ch == 'r' )
            rectangle(temp1,temp2,x,y);
         else if ( ch == 'c' )
         {
            ch = 'f';          // setting to freehand drawing
            clearviewport();
            color = getcolor();
            setcolor(WHITE);
            rectangle(2,2,518,427);
            setcolor(color);
         }

         showmouseptr();
      }
   }
}
예제 #19
0
		void black_pressed() { change_color(Color::black); hide_menu(); }
예제 #20
0
		// コールバックによって呼び出されるアクション
		void red_pressed() { change_color(Color::red); hide_menu(); }
예제 #21
0
파일: my_main.c 프로젝트: stuydw/mdl
void my_main( int polygons ) {

  int i, axis;
  double xval, xval1, yval, yval1, zval, zval1, degrees, width, height, depth, r, r1;
  struct matrix *transform;
  struct matrix *tmp;
  struct stack *s;
  screen t;
  color g;
  
  g = change_color(0);

  s = new_stack();
  tmp = new_matrix(4, 1000);
  clear_screen( t );

  for (i=0;i<lastop;i++) {  
    switch (op[i].opcode) {
    case PUSH:
      push(s);
      break;
    case POP:
      pop(s);
      break;
    case MOVE:
      xval = op[i].op.move.d[0];
      yval = op[i].op.move.d[1];
      zval = op[i].op.move.d[2];
      transform = make_translate(xval, yval, zval);
      matrix_mult(transform, s->data[s->top]);
      break;
    case SCALE:
      xval = op[i].op.scale.d[0];
      yval = op[i].op.scale.d[1];
      zval = op[i].op.scale.d[2];
      transform = make_scale(xval, yval, zval);
      matrix_mult(transform, s->data[s->top]);
      break;
    case ROTATE:
      axis = op[i].op.rotate.axis;
      degrees = op[i].op.rotate.degrees;
      if(axis == 0)
	transform = make_rotX(degrees);
      else if(axis == 1)
	transform = make_rotY(degrees);
      else if(axis == 2)
	transform = make_rotZ(degrees);
      matrix_mult(transform, s->data[s->top]);
      break;
    case BOX:
      free_matrix(tmp);
      tmp = new_matrix(4, 1000);
      xval = op[i].op.box.d0[0];
      yval = op[i].op.box.d0[1];
      zval = op[i].op.box.d0[2];
      width = op[i].op.box.d1[0];
      height = op[i].op.box.d1[1];
      depth = op[i].op.box.d1[2];
      add_box(tmp, xval, yval, zval, width, height, depth);
      matrix_mult(s->data[s->top], tmp);
      draw_polygons(tmp, t, g);
      break;
    case SPHERE:
      free_matrix(tmp);
      tmp = new_matrix(4, 1000);
      xval = op[i].op.sphere.d[0];
      yval = op[i].op.sphere.d[1];
      zval = op[i].op.sphere.d[2];
      r = op[i].op.sphere.r;
      add_sphere(tmp, xval, yval, zval, r, 0.05);
      matrix_mult(s->data[s->top], tmp);
      draw_polygons(tmp, t, g);
      break;
    case TORUS:
      free_matrix(tmp);
      tmp = new_matrix(4, 1000);
      xval = op[i].op.torus.d[0];
      yval = op[i].op.torus.d[1];
      zval = op[i].op.torus.d[2];
      r = op[i].op.torus.r0;
      r1 = op[i].op.torus.r1;
      add_torus(tmp, xval, yval, zval, r, r1, 0.05);
      matrix_mult(s->data[s->top], tmp);
      draw_polygons(tmp, t, g);
      break;
    case LINE:
      free_matrix(tmp);
      tmp = new_matrix(4, 1000);
      xval = op[i].op.line.p0[0];
      yval = op[i].op.line.p0[1];
      zval = op[i].op.line.p0[2];
      xval1 = op[i].op.line.p1[0];
      yval1 = op[i].op.line.p1[1];
      zval1 = op[i].op.line.p1[2];
      add_edge(tmp, xval, yval, zval, xval1, yval1, zval1);
      matrix_mult(s->data[s->top], tmp);
      draw_lines(tmp, t, g);
      break;
    case SAVE:
      save_extension(t, op[i].op.save.p->name);
      break;
    case DISPLAY:
      display(t);
      break;
    }
  }
  free_stack(s);
  free_matrix(tmp);
}
예제 #22
0
void menu_utama()
{
    system("cls");


    //if(no_jabatan==0)
    //{
    header();

    gotoxy(18,5);
    printf("(1) Login");
    gotoxy(18,6);
    printf("(2) Buat Akun Baru");
    gotoxy(18,7);
    printf("(3) Lihat Barang");
    gotoxy(47,5);
    printf("(4) Exit");
    gotoxy(18,11);
    printf("Note:");
    gotoxy(18,12);
    printf("Masukan nomor diatas untuk memilih");
    gotoxy(18,13);
    printf("Ketik 'help' untuk informasi lebih lanjut");
    //tampil();
    gotoxy(18,9);
    printf("Pilihan : ");
    scanf("%s",&pilihan);
    fseek(stdin,0,SEEK_END);
    if(strcmp(pilihan,"change")==0)
    {
        change_color();
        menu_utama();
    }
    if(strcmp(pilihan,"help")==0)
    {
        gotoxy(0,15);
        printf("Help");
        gotoxy(0,16);
        printf("==================================================================================");

        gotoxy(0,18);
        printf("Ketik 'change' untuk Merubah Warna Background dan Font");
        gotoxy(0,19);
        printf("Ketik '1' untuk masuk kesistem sehingga dapat melakukan transaksi");
        gotoxy(0,20);
        printf("Ketik '2' untuk membuat akun baru jika anda belum terdaftar");
        gotoxy(0,21);
        printf("Ketik '3' untuk melihat daftar barang yang dijual");
        getch();
        system("cls");
        menu_utama();
    }
    pilihan1=pilihan[0];
    switch(pilihan1)
    {
    case '1':
    {
        login();
        break;
    }
    case '2':
    {
        registrasi_anggota();
        break;
    }
    case '3':
    {
        break;
    }
    case '4':
    {
        printf("Good Bye..");
        getch();
        exit(0);
        break;
    }
    default:
    {
        printf("Nomor yang anda masukkan tidak ada pada menu..");
        getch();
        system("cls");
        menu_utama();
        break;
    }
    }
    //}
    //else if(no_jabatan==3)
    //{

    //}

}
예제 #23
0
//
// FUNCTION: WndProc (HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Process the message in the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - draw the main window
// WM_DESTROY - send a message to exit and return
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

	int cbIndex;

	static scene sceneSettings = init_scene(hWnd);
	params parameters;

	PAINTSTRUCT ps;
	HDC hdc;
	
	HWND bufHWND;
	TCHAR buf[5];

	switch (message)
	{
	case WM_COMMAND:
	{
		int wmId = LOWORD(wParam);
		switch (wmId)
		{
		case ID_BUTTON_DRAW_ELLIPSE:
			cbIndex = getCurrentItem(GetDlgItem(hWnd, ID_COMBO_ELLIPSE));

			bufHWND = GetDlgItem(hWnd, ID_EDIT_ELLIPSE_CENTER_X);
			GetWindowText(bufHWND, buf, 5);
			parameters.centerX = _wtoi(buf);

			bufHWND = GetDlgItem(hWnd, ID_EDIT_ELLIPSE_CENTER_Y);
			GetWindowText(bufHWND, buf, 5);
			parameters.centerY = _wtoi(buf);

			bufHWND = GetDlgItem(hWnd, ID_EDIT_ELLIPSE_HEIGHT);
			GetWindowText(bufHWND, buf, 5);
			parameters.height = _wtoi(buf);

			bufHWND = GetDlgItem(hWnd, ID_EDIT_ELLIPSE_WIDTH);
			GetWindowText(bufHWND, buf, 5);
			parameters.width = _wtoi(buf);

			draw(ELLIPSE, parameters, cbIndex, sceneSettings);
			break;
		case ID_BUTTON_DRAW_CIRCLE:
			cbIndex = getCurrentItem(GetDlgItem(hWnd, ID_COMBO_CIRCLE));

			bufHWND = GetDlgItem(hWnd, ID_EDIT_CIRCLE_CENTER_X);
			GetWindowText(bufHWND, buf, 5);
			parameters.centerX = _wtoi(buf);

			bufHWND = GetDlgItem(hWnd, ID_EDIT_CIRCLE_CENTER_Y);
			GetWindowText(bufHWND, buf, 5);
			parameters.centerY = _wtoi(buf);

			bufHWND = GetDlgItem(hWnd, ID_EDIT_CIRCLE_RADIUS);
			GetWindowText(bufHWND, buf, 5);
			parameters.radiusMin = _wtoi(buf);
			parameters.radiusMax = _wtoi(buf);

			draw(CIRCLE, parameters, cbIndex, sceneSettings);
			break;
		case ID_BUTTON_DRAW_SPEKTRE:
			cbIndex = getCurrentItem(GetDlgItem(hWnd, ID_COMBO_SPEKTRE));

			bufHWND = GetDlgItem(hWnd, ID_EDIT_SPEKTRE_RADIUS_MIN);
			GetWindowText(bufHWND, buf, 5);
			parameters.radiusMin = _wtoi(buf);

			bufHWND = GetDlgItem(hWnd, ID_EDIT_SPEKTRE_RADIUS_MAX);
			GetWindowText(bufHWND, buf, 5);
			parameters.radiusMax = _wtoi(buf);

			bufHWND = GetDlgItem(hWnd, ID_EDIT_SPEKTRE_RADIUS_STEP);
			GetWindowText(bufHWND, buf, 5);
			parameters.radiusStep = _wtoi(buf);

			draw(SPEKTRE, parameters, cbIndex, sceneSettings);
			break;
		case ID_BUTTON_CLEAR:
			draw_scene(sceneSettings);
			break;
		case ID_BUTTON_LCOLOR:
			change_color(&sceneSettings, TRUE);
			break;
		case ID_BUTTON_BCOLOR:
			change_color(&sceneSettings, FALSE);
			break;
		case IDM_ABOUT:
			DialogBoxW(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}

		SetFocus(hWnd);
	}
	break;
	case WM_PAINT:
	{
		hdc = BeginPaint(hWnd, &ps);
		draw_scene(sceneSettings);
		init_colorpick(sceneSettings);
		init_text(sceneSettings);
		EndPaint(hWnd, &ps);
	}
	break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
예제 #24
0
void menu_owner()
{
    system("cls");
    header();
    gotoxy(18,3);
    printf("Welcome %s",login_s->nama);
    gotoxy(18,5);
    printf("(1) Buat Akun Admin");
    gotoxy(18,6);
    printf("(2) Manajemen Barang");
    gotoxy(18,7);
    printf("(3) Manajemen Akun");
    gotoxy(47,5);
    printf("(4) Lihat Barang");
    gotoxy(47,6);
    printf("(5) Perpesanan/Message");
    gotoxy(47,7);
    printf("(6) Laporan Pelanggaran");
    gotoxy(18,11);
    printf("Note:");
    gotoxy(18,12);
    printf("Masukan nomor diatas untuk memilih");
    gotoxy(18,13);
    printf("Ketik 'help' untuk informasi lebih lanjut");
    //tampil();
    gotoxy(18,9);
    printf("Pilihan : ");
    scanf("%s",&pilihan);
    fseek(stdin,0,SEEK_END);
    if(strcmp(pilihan,"change")==0)
    {
        change_color();
        menu_owner();
    }
    else if(strcmp(pilihan,"logout")==0)
    {
        //no_jabatan=0;
        menu_utama();
    }
    if(strcmp(pilihan,"help")==0)
    {
        gotoxy(0,15);
        printf("Help");
        gotoxy(0,16);
        printf("==================================================================================");

        gotoxy(0,18);
        printf("Ketik 'logout' untuk keluar dari akun");
        gotoxy(0,19);
        printf("Ketik 'change' untuk Merubah Warna Background dan Font");
        gotoxy(0,20);
        printf("Ketik '1' untuk membuat akun admin");
        gotoxy(0,21);
        printf("Ketik '2' untuk memanajemen barang");
        gotoxy(0,22);
        printf("Ketik '3' untuk memanajemen akun");
        gotoxy(0,23);
        printf("Ketik '4' untuk melihat daftar barang yang dijual");
        gotoxy(0,24);
        printf("Ketik '5' untuk melihat atau mengirim pesan");
        gotoxy(0,25);
        printf("Ketik '6' untuk melihat laporan pelanggaran");
        getch();
        system("cls");
        menu_owner();
    }
    pilihan1=pilihan[0];
    switch(pilihan1)
    {
    case '1':
    {
        //login();
        break;
    }
    case '2':
    {
        //registrasi_anggota();
        break;
    }
    case '3':
    {
        break;
    }
    case '4':
    {
        printf("Good Bye..");
        getch();
        exit(0);
        break;
    }
    default:
    {
        printf("Nomor yang anda masukkan tidak ada pada menu..");
        getch();
        system("cls");
        menu_owner();
        break;
    }
    }
}
예제 #25
0
void print_data(unsigned long long address, const void* _data,
    const void* _prev, unsigned long long data_size, int flags) {

  if (data_size == 0)
    return;

  // if color is disabled or no diff source is given, disable diffing
  const uint8_t* data = (const uint8_t*)_data;
  const uint8_t* prev = (const uint8_t*)((_prev && use_color) ? _prev : _data);

  char data_ascii[20];
  char prev_ascii[20]; // actually only 16 is necessary but w/e

  // start_offset is how many blank spaces to print before the first byte
  int start_offset = address & 0x0F;
  address &= ~0x0F;
  data_size += start_offset;

  // if nonzero, print the address here (the loop won't do it for the 1st line)
  if (start_offset)
    printf("%016llX | ", address);

  // print initial spaces, if any
  unsigned long long x, y;
  for (x = 0; x < start_offset; x++) {
    printf("   ");
    data_ascii[x] = ' ';
    prev_ascii[x] = ' ';
  }

  // print the data
  for (; x < data_size; x++) {

    int line_offset = x & 0x0F;
    int data_offset = x - start_offset;
    data_ascii[line_offset] = data[data_offset];
    prev_ascii[line_offset] = prev[data_offset];

    // first byte on the line? then print the address
    if ((x & 0x0F) == 0)
      printf("%016llX | ", address + x);

    // print the byte itself
    if (prev[data_offset] != data[data_offset])
      change_color(FORMAT_BOLD, FORMAT_FG_RED, FORMAT_END);
    printf("%02X ", data[data_offset]);
    if (prev[data_offset] != data[data_offset])
      change_color(FORMAT_NORMAL, FORMAT_END);

    // last byte on the line? then print the ascii view and a \n
    if ((x & 0x0F) == 0x0F) {
      printf("| ");
      for (y = 0; y < 16; y++) {
        if (prev_ascii[y] != data_ascii[y])
          change_color(FORMAT_FG_RED, FORMAT_END);

        if (data_ascii[y] < 0x20 || data_ascii[y] == 0x7F) {
          if (use_color)
            change_color(FORMAT_INVERSE, FORMAT_END);
          putc(' ', stdout);
          if (use_color)
            change_color(FORMAT_NORMAL, FORMAT_END);
        } else
          putc(data_ascii[y], stdout);

        if (prev_ascii[y] != data_ascii[y])
          change_color(FORMAT_NORMAL, FORMAT_END);
      }

      printf("\n");
    }
  }

  // if the last line is a partial line, print the remaining ascii chars
  if (x & 0x0F) {
    for (y = x; y & 0x0F; y++)
      printf("   ");
    printf("| ");
    for (y = 0; y < (x & 0x0F); y++) {
      if (prev_ascii[y] != data_ascii[y])
        change_color(FORMAT_FG_RED, FORMAT_END);

      if (data_ascii[y] < 0x20 || data_ascii[y] == 0x7F) {
        if (use_color)
          change_color(FORMAT_INVERSE, FORMAT_END);
        putc(' ', stdout);
        if (use_color)
          change_color(FORMAT_NORMAL, FORMAT_END);
      } else
        putc(data_ascii[y], stdout);

      if (prev_ascii[y] != data_ascii[y])
        change_color(FORMAT_NORMAL, FORMAT_END);
    }
    printf("\n");
  }
}
예제 #26
0
파일: my_main.c 프로젝트: stuydw/mdl
void my_main( int polygons ) {

  int i, j;
  double step = 0.05; // Decided to make step this value
  double xval, yval, zval;
  struct matrix *transform;
  struct matrix *tmp;
  struct stack *s;
  screen t;
  color g;

  g = change_color(2);

  int axis; // 0,1,2 correspond to x,y,z axes of rotation, respectively
  double measure; // corresponds to angle of rotation

  double width, height, depth; // For box

  double radius; // For sphere

  double r1, r2; // For torus

  double x2,y2,z2; // For line
  
  s = new_stack();
  tmp = new_matrix(4, 1000);
  clear_screen( t );

  for (i=0;i<lastop;i++) {  
    switch (op[i].opcode) {

    case COMMENT:
      break;

    case PUSH:
      push(s);
      break;

    case POP:
      pop(s);
      break;

    case MOVE:
      xval = op[i].op.move.d[0];
      yval = op[i].op.move.d[1];
      zval = op[i].op.move.d[2];

      transform = make_translate(xval, yval, zval);      
      matrix_mult(s->data[s->top], transform);
      s->data[s->top] = transform;
      break;

    case SCALE:
      xval = op[i].op.scale.d[0];
      yval = op[i].op.scale.d[1];
      zval = op[i].op.scale.d[2];

      transform = make_scale(xval, yval, zval);
      matrix_mult(s->data[s->top], transform);
      s->data[s->top] = transform;
      break;

    case ROTATE:
      axis = op[i].op.rotate.axis;
      measure = op[i].op.rotate.degrees;

      if(axis == 0){
	transform = make_rotX(measure);}
      if(axis == 1){
	transform = make_rotY(measure);}
      if(axis == 2){
	transform = make_rotZ(measure);}

      matrix_mult(s->data[s->top], transform);
      s->data[s->top] = transform;
      break;

    case BOX:
      for(j = 0; j < tmp->lastcol; j++){
	tmp->m[0][j] = 0;
	tmp->m[1][j] = 0;
	tmp->m[2][j] = 0;
      }
      tmp->lastcol = 0;

      xval = op[i].op.box.d0[0];
      yval = op[i].op.box.d0[1];
      zval = op[i].op.box.d0[2];

      width = op[i].op.box.d1[0];
      height = op[i].op.box.d1[1];
      depth = op[i].op.box.d1[2];

      add_box(tmp, xval, yval, zval, width, height, depth);
      matrix_mult(s->data[s->top], tmp);
      //matrix_mult(transform, tmp);
      draw_polygons(tmp, t, g);
      //free_matrix(tmp);
      break;

    case SPHERE:
      for(j = 0; j < tmp->lastcol; j++){
	tmp->m[0][j] = 0;
	tmp->m[1][j] = 0;
	tmp->m[2][j] = 0;
      }
      tmp->lastcol = 0;

      xval = op[i].op.sphere.d[0];
      yval = op[i].op.sphere.d[1];
      zval = op[i].op.sphere.d[2];

      radius = op[i].op.sphere.r;

      add_sphere(tmp, xval, yval, zval, radius, step);
      matrix_mult(s->data[s->top], tmp);
      draw_polygons(tmp, t, g);
      break;

    case TORUS:
      for(j = 0; j < tmp->lastcol; j++){
	tmp->m[0][j] = 0;
	tmp->m[1][j] = 0;
	tmp->m[2][j] = 0;
      }
      tmp->lastcol = 0;

      xval = op[i].op.torus.d[0];
      yval = op[i].op.torus.d[1];
      zval = op[i].op.torus.d[2];

      r1 = op[i].op.torus.r0;
      r2 = op[i].op.torus.r1;

      add_torus(tmp, xval, yval, zval, r1, r2, step);
      matrix_mult(s->data[s->top], tmp);
      draw_polygons(tmp, t, g);
      break;

    case LINE:
      for(j = 0; j < tmp->lastcol; j++){
	tmp->m[0][j] = 0;
	tmp->m[1][j] = 0;
	tmp->m[2][j] = 0;
      }
      tmp->lastcol = 0;

      xval = op[i].op.line.p0[0];
      yval = op[i].op.line.p0[1];
      zval = op[i].op.line.p0[2];

      x2 = op[i].op.line.p1[0];
      y2 = op[i].op.line.p1[1];
      z2 = op[i].op.line.p1[2];

      add_edge(tmp, xval, yval, zval, x2, y2, z2);
      matrix_mult(s->data[s->top], tmp);
      draw_lines(tmp, t, g);
      break;

    case SAVE:
      save_extension(t, op[i].op.save.p->name);
      break;
      
    case DISPLAY:
      display(t);
      break;
      
    }
  }

  //free_stack(s);
  //free_matrix(transform);
}
예제 #27
0
파일: 3.cpp 프로젝트: keipa/bsuir-labs
void interrupt new_int9(...)
{
  get_register();	
  change_color();
  (*std_int9)();
}
예제 #28
0
파일: my_main.c 프로젝트: stuydw/mdl
void my_main( int polygons ) {

  int i;
  double step = .05;
  double xval, yval, zval;
  struct matrix *transform;
  struct matrix *tmp;
  struct stack *s;
  screen t;
  color g;

  g = change_color(4);

  s = new_stack();
  tmp = new_matrix(4, 1000);
  clear_screen( t );

  for (i=0;i<lastop;i++) {  
    switch (op[i].opcode) {
      
    case COMMENT:
      break;

    case PUSH:
      push(s);
      break;

    case POP:
      pop(s);
      break;

    case MOVE:
      xval = op[i].op.move.d[0];
      yval = op[i].op.move.d[1];
      zval = op[i].op.move.d[2];

      transform = make_translate(xval, yval, zval);
      matrix_mult(s->data[s->top], transform);
      s->data[s->top] = transform;
      break;
      
    case SCALE:
      xval = op[i].op.scale.d[0];
      yval = op[i].op.scale.d[1];
      zval = op[i].op.scale.d[2];
      
      transform - make_scale(xval, yval, zval);
      matrix_mult(s->data[s->top], transform);
      s->data[s->top] = transform;
      break;
 
    case ROTATE:
      switch ((int)op[i].op.rotate.axis) 
	{

	  double theta = op[i].op.rotate.degrees;

	case 0:
	  transform = make_rotX(theta);
	  break;
	case 1:
	  transform = make_rotY(theta);
	  break;
	case 2:
	  transform = make_rotZ(theta);
	  break;
      }
      
      matrix_mult(s->data[s->top], transform);
      s->data[s->top] = transform;
      break;

    case BOX:
      empty_matrix(tmp);

      xval = op[i].op.box.d0[0];
      yval = op[i].op.box.d0[1];
      zval = op[i].op.box.d0[2];

      double width = op[i].op.box.d1[0];
      double height = op[i].op.box.d1[1];
      double depth = op[i].op.box.d1[2];
      
      add_box(tmp, xval, yval, zval, width, height, depth);
      matrix_mult(s->data[s->top], tmp);
      draw_polygons(tmp, t, g);
      break;

    case SPHERE:
      empty_matrix(tmp);
      
      xval = op[i].op.sphere.d[0];
      yval = op[i].op.sphere.d[1];
      zval = op[i].op.sphere.d[2];
      
      double radius = op[i].op.sphere.r;

      add_sphere(tmp, xval, yval, zval, radius, step);
      matrix_mult(s->data[s->top], tmp);
      draw_polygons(tmp, t, g);
      break;

    case TORUS:
      empty_matrix(tmp);

      xval = op[i].op.torus.d[0];
      yval = op[i].op.torus.d[1];
      zval = op[i].op.torus.d[2];

      double r1 = op[i].op.torus.r0;
      double r2 = op[i].op.torus.r1;

      add_torus(tmp, xval, yval, zval, r1, r2, step);
      matrix_mult(s->data[s->top], tmp);
      draw_polygons(tmp, t, g);
      break;

    case LINE:
      empty_matrix(tmp);

      add_edge(tmp,
	       op[i].op.line.p0[0],
	       op[i].op.line.p0[1],
	       op[i].op.line.p0[2],
	       op[i].op.line.p1[0],
	       op[i].op.line.p1[1],
	       op[i].op.line.p1[2]);
      
      draw_lines(tmp, t, g);
      break;

    case SAVE:
      save_extension(t, op[i].op.save.p->name);
      break;

    case DISPLAY:
      display(t);
      break;
    
    }
  }
}
예제 #29
0
static void change_color_0( GtkColorButton * button, CPUGraph * base )
{
	change_color( button, base, 0);
}
예제 #30
0
static void change_color_out(GtkWidget *button, t_global_monitor *global)
{
    change_color(button, global, OUT);
}