Exemple #1
0
void
draw_orientation_instruments (carmen_orientation_3D_t orientation, double r, double g, double b)
{
    glPushMatrix ();

    glColor3d (r, g, b);

    glLoadIdentity ();

    glTranslated (-0.16, -0.16, -0.5);

    glPushMatrix ();
    glRotated (carmen_radians_to_degrees (orientation.yaw), 0.0, 0.0, 1.0);
    draw_arrow (0.05);
    glPopMatrix ();

    glTranslated (0.1, 0.0, 0.0);

    glPushMatrix ();
    glRotated (carmen_radians_to_degrees (orientation.pitch), 0.0, 0.0, -1.0);
    draw_arrow (0.05);
    glPopMatrix ();

    glTranslated (0.1, 0.0, 0.0);

    glPushMatrix ();
    glRotated (carmen_radians_to_degrees (orientation.roll), 0.0, 0.0, 1.0);
    draw_arrow (0.05);
    glPopMatrix ();

    glPopMatrix ();
}
Exemple #2
0
/**
 * Draws cursor
 */
void draw_cursor() {
	if (holding_atom) {
		sprites[SPRITE_CURSOR].tileIndex = holding_atom;
		draw_arrow(cursor_x, cursor_y - 1, TILE_ARROW_UP);
		draw_arrow(cursor_x + 1, cursor_y, TILE_ARROW_RIGHT);
		draw_arrow(cursor_x, cursor_y + 1, TILE_ARROW_DOWN);
		draw_arrow(cursor_x - 1, cursor_y, TILE_ARROW_LEFT);
	} else {
		cursor_animation = (cursor_animation + 1) % 4;
		sprites[SPRITE_CURSOR].tileIndex = TILE_FIRST_CURSOR + cursor_animation;
		sprites[SPRITE_CURSOR].x = (cursor_x + SCREEN_FIELD_X) * TILE_WIDTH;
		sprites[SPRITE_CURSOR].y = (cursor_y + SCREEN_FIELD_Y) * TILE_HEIGHT;
	}
}
Exemple #3
0
void draw(const Cannon& c) {
//    image::target_image->activate();
//    draw_rect(c.start.x-20, c.start.y-75, 40, 150);
//    image::target_image->deactivate();
    glColor4fv(color::cannon_color);
    Vec e = c.start + (c.end - c.start)*25;
    draw_arrow(c.start, e, 1);
}
Exemple #4
0
void El_Window::draw_arrow
     (
         Pt2dr p0, Pt2dr p1, Line_St lst,
         REAL size_pointe, REAL pos , REAL teta
     )
{
     draw_arrow(p0,p1,lst,lst,size_pointe,pos,teta);
}
Exemple #5
0
static void
goc_line_draw (GocItem const *item, cairo_t *cr)
{
	GocLine *line = GOC_LINE (item);
	GOStyle *style = go_styled_object_get_style (GO_STYLED_OBJECT (item));
	double sign = (goc_canvas_get_direction (item->canvas) == GOC_DIRECTION_RTL)? -1: 1;
	double endx = (line->endx - line->startx) * sign, endy = line->endy - line->starty;
	double hoffs, voffs = ceil (style->line.width);
	double startx = 0, starty = 0;
	double phi;

	if (line->startx == line->endx && line->starty == line->endy)
		return;

	if (voffs <= 0.)
		voffs = 1.;

	hoffs = ((int) voffs & 1)? .5: 0.;
	voffs = (line->starty == line->endy)? hoffs: 0.;
	if (line->startx != line->endx)
	                hoffs = 0.;

	cairo_save (cr);
	_goc_item_transform (item, cr, TRUE);
	goc_group_cairo_transform (item->parent, cr,
				   hoffs + floor (line->startx),
				   voffs + floor (line->starty));

	endx = (endx > 0.)? ceil (endx): floor (endx);
	endy = (endy > 0.)? ceil (endy): floor (endy);

	phi = atan2 (endy, endx);
	draw_arrow (&line->start_arrow, cr, style,
		    &startx, &starty, phi + M_PI);
	draw_arrow (&line->end_arrow, cr, style,
		    &endx, &endy, phi);

        if ((endx != 0. || endy!= 0.) &&
	    go_styled_object_set_cairo_line (GO_STYLED_OBJECT (item), cr)) {
		/* try to avoid horizontal and vertical lines between two pixels */
		cairo_move_to (cr, startx, starty);
		cairo_line_to (cr, endx, endy);
		cairo_stroke (cr);
	}
	cairo_restore (cr);
}
Exemple #6
0
void InterpolateVideo::draw_vectors(int processed)
{
// Draw arrows
	if(config.draw_vectors)
	{
		create_macroblocks();

		for(int i = 0; i < total_macroblocks; i++)
		{
			OpticFlowMacroblock *mb = macroblocks.get(i);
// 		    printf("InterpolateVideo::optic_flow %d x=%d y=%d dx=%d dy=%d\n",
// 		  	    __LINE__,
// 			    mb->x,
// 			    mb->y,
// 			    mb->dx / OVERSAMPLE,
// 			    mb->dy / OVERSAMPLE);

			if(processed)
			{
				draw_arrow(get_output(),
					mb->x,
					mb->y,
					mb->x - mb->dx / OVERSAMPLE,
					mb->y - mb->dy / OVERSAMPLE);

// debug
// 				if(mb->is_valid && mb->visible)
// 				{
// 					draw_arrow(get_output(),
// 						mb->x + 1,
// 						mb->y + 1,
// 						mb->x - mb->dx / OVERSAMPLE + 1,
// 						mb->y - mb->dy / OVERSAMPLE + 1);
// 				}
			}
			else
			{
				draw_pixel(get_output(),
					mb->x,
					mb->y);
			}
		}
		
// Draw center macroblock
		OpticFlowMacroblock *mb = macroblocks.get(
			x_macroblocks / 2 + y_macroblocks / 2 * x_macroblocks);
		draw_rect(get_output(),
			mb->x - config.macroblock_size / 2,
			mb->y - config.macroblock_size / 2,
			mb->x + config.macroblock_size / 2,
			mb->y + config.macroblock_size / 2);
		draw_rect(get_output(),
			mb->x - config.macroblock_size / 2 - config.search_radius,
			mb->y - config.macroblock_size / 2 - config.search_radius,
			mb->x + config.macroblock_size / 2 + config.search_radius,
			mb->y + config.macroblock_size / 2 + config.search_radius);
	}
}
Exemple #7
0
int main(void)
{
clrscr();
   /* request autodetection */
   int gdriver = DETECT, gmode, errorcode;
   void *arrow;
   int x, y, maxx;
   unsigned int size;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "d:\\tc\\bgi");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }

   maxx = getmaxx();
   x = 0;
   y = getmaxy() / 2;

   /* draw the image to be grabbed */
   draw_arrow(x, y);

   /* calculate the size of the image */
   size = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE);

   /* allocate memory to hold the image */
   arrow = malloc(size);

   /* grab the image */
   getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow);

   /* repeat until a key is pressed */
   while (!kbhit())
   {
      /* erase old image */
      putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);

      x += ARROW_SIZE;
      if (x >= maxx)
          x = 0;

      /* plot new image */
      putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);
   }

   /* clean up */
   free(arrow);
   closegraph();
   return 0;
}
void
EditorScroller::draw(DrawingContext& context) {
  if (!rendered) return;

  context.draw_filled_rect(Rectf(Vector(0, 0), Vector(SIZE, SIZE)),
                           Color(0.9f, 0.9f, 1.0f, 0.6f),
                           MIDDLE, LAYER_GUI-10);
  context.draw_filled_rect(Rectf(Vector(40, 40), Vector(56, 56)),
                           Color(0.9f, 0.9f, 1.0f, 0.6f),
                           8, LAYER_GUI-20);
  if (can_scroll()) {
    draw_arrow(context, mouse_pos);
  }

  draw_arrow(context, Vector(TOPLEFT, MIDDLE));
  draw_arrow(context, Vector(BOTTOMRIGHT, MIDDLE));
  draw_arrow(context, Vector(MIDDLE, TOPLEFT));
  draw_arrow(context, Vector(MIDDLE, BOTTOMRIGHT));
}
Exemple #9
0
static int gscrollbar_expose(GWindow pixmap, GGadget *g, GEvent *event) {
    GScrollBar *gsb = (GScrollBar *) g;
    GBox box = *(g->box);
    GRect old1;
    GRect r;
    int ar;

    if ( g->state == gs_invisible )
return( false );

    /* In case border was changed in resource editor, */
    /* the scrollbar thumb inside must be refitted. */
    GScrollBarFit(gsb);

    GDrawPushClip(pixmap,&g->r,&old1);

    r = g->r;
    ar = gsb->arrowsize - gsb->sbborder;
    if ( gsb->g.vert ) { r.y += ar ; r.height -= 2*ar; }
    else { r.x += ar; r.width -= 2*ar; }

    /* Mimick old border behavior to retain compatibility with older themes, */
    /* but match border shape with that of background. */
    box.flags = box_foreground_border_outer;
    box.border_width = 0;
    GBoxDrawBackground(pixmap,&g->r,g->box,g->state,false);
    GBoxDrawBackground(pixmap,&r,g->box,gs_pressedactive,false);
    GBoxDrawBorder(pixmap,&g->r,&box,g->state,false);
    GBoxDrawBorder(pixmap,&r,g->box,g->state,false);

    draw_thumb(pixmap,gsb); /* sets line width for arrows too */
    draw_arrow(pixmap,gsb,gsb->g.vert);
    draw_arrow(pixmap,gsb,gsb->g.vert|2);

    GDrawPopClip(pixmap,&old1);
return( true );
}
Exemple #10
0
gboolean on_buttonrelease (GtkWidget *win, 
			   GdkEventButton *ev, 
			   gpointer user_data)
{
  GromitData *data = (GromitData *) user_data;

  /* get the data for this device */
  GdkDevice *master = ev->device;
  GromitDeviceData *masterdata =
    g_hash_table_lookup(data->devdatatable, master);
  GdkDevice *slave =
    gdk_event_get_source_device ((GdkEvent *) ev);
  GromitDeviceData *slavedata =
    g_hash_table_lookup(data->devdatatable, slave);

  if(data->debug)
    g_printerr("DEBUG: Device '%s': Button %i Up at (x,y)=(%.2f : %.2f)\n", 
	       gdk_device_get_name(slave), ev->button, ev->x, ev->y);

  gfloat direction = 0;
  gint width = 0;
  if(slavedata->cur_context)
    width = slavedata->cur_context->arrowsize *
      slavedata->cur_context->width / 2;

  if ((ev->x != slavedata->lastx) ||
      (ev->y != slavedata->lasty))
    on_motion(win, (GdkEventMotion *) ev, user_data);


  if (!masterdata->is_grabbed)
    return FALSE;

  if (slavedata->cur_context->arrowsize != 0 &&
      coord_list_get_arrow_param (data, slave, width * 3,
				  &width, &direction))
    draw_arrow (data, slave, ev->x, ev->y, width, direction);

  coord_list_free (data, slave);

  return TRUE;
}
void draw_vehicles( Road* r, int x5, int y5, int ratio, CDC* pDC )
{

	int veh_line_start_x = get_x2(x5,(LINE_WIDTH-VEH_WIDTH)/2,ratio);
	int veh_line_start_y = get_y2(y5,(LINE_WIDTH-VEH_WIDTH)/2,ratio);
	int line_start_x = x5;
	int line_start_y = y5;
	for (int line_index=0; line_index<r->num_of_lines(); ++line_index) {
		draw_arrow(r->line_at(line_index),line_start_x,line_start_y,ratio,pDC);
		for (int veh_index=0; veh_index<r->line_at(line_index)->num_of_vehicles(); ++veh_index) {
			Vehicle& v=r->line_at(line_index)->vehicle_at(veh_index);
			draw_vehicle(v,
				get_x4(veh_line_start_x,v.m_to_cross()*VIRTUAL_RATIO,ratio),
				get_y4(veh_line_start_y,v.m_to_cross()*VIRTUAL_RATIO,ratio),
				ratio,
				pDC
				);
		}
		line_start_x = get_x2(line_start_x,LINE_WIDTH,ratio);
		line_start_y = get_y2(line_start_y,LINE_WIDTH,ratio);
		veh_line_start_x = get_x2(veh_line_start_x,LINE_WIDTH,ratio);
		veh_line_start_y = get_y2(veh_line_start_y,LINE_WIDTH,ratio);
	}
}
Exemple #12
0
void MazePlugin::syscall(State *s, int status, int syscallNo, int valueOfa0) {
   Q_UNUSED(status);

   switch(syscallNo) {
      case S_MAZE_INIT:
         s->setRegister(v0, init_maze(s));
         break;
      case S_MAZE_DEFEAT:
         defeat();
         break;
      case S_MAZE_VICTORY:
         victory();
         break;
      case S_MAZE_IS_GOAL:
         s->setRegister(v0, is_goal(s, valueOfa0));
         break;
      case S_MAZE_NEIGHBOR:
         {
            int results[4];
            get_neighbors(s, valueOfa0, results);
            unsigned int addr = s->getRegister(a1);

            for(int i = 0; i < 4; ++i)
               s->setMemoryWord(addr + (i << 2), results[i]);
         }
         break;
      case S_MAZE_DRAW_ARROW:
         draw_arrow(s, status, valueOfa0, s->getRegister(a1));
         break;
      case S_MAZE_IS_SEARCHED:
         s->setRegister(v0, is_searched(s, valueOfa0));
         break;
      default:
         break;
   }
}
Exemple #13
0
void Arrow_widget::paintEvent(QPaintEvent*)
{
    QPainter p(this);
    
    p.setRenderHint(QPainter::Antialiasing);
    
    int base_x = 550;
    int base_y = 200;

    if (color_ == 0)   
        p.setBrush(Qt::black);
    else if (color_ == 1)
        p.setBrush(Qt::green);
    else if (color_ == 2)
        p.setBrush(Qt::yellow);
    else
        p.setBrush(Qt::black);
    
    for (int x_step = 0; x_step < 6; ++x_step)
    {
        for (int y_step = 1; y_step <= 3; ++y_step)
        {
            draw_arrow(base_x, base_y, base_x+x_step*100, 
                       base_y - y_step*50, p);
            
            draw_arrow(base_x, base_y, base_x+x_step*100, 
                       base_y + y_step*50, p);
            
            draw_arrow(base_x, base_y, base_x-x_step*100, 
                       base_y + y_step*50, p);
            
            draw_arrow(base_x, base_y, base_x-x_step*100, 
                       base_y - y_step*50, p);
        }
    }

    draw_arrow(50, 400, 1000, 450, p);
    draw_arrow(1000, 400, 50, 450, p);
    
}
void RNDFEditGLView::drawSelected(double center_x, double center_y) {
    rndf::WayPoint* w = NULL, *w_next = NULL;
    rndf::PerimeterPoint* p = NULL, *p_next = NULL;
    rndf::TWayPointVec::const_iterator wpit, wpit_end, wpit_next;
    rndf::TPerimeterPointVec::const_iterator ppit, ppit_end, ppit_next;
    int blend = 1;

    // draw the selected lane in yellow
    if (gui->re_lane_->current()) {
        glLineWidth(2);
        glColor4f(1, 0.5, 0, blend);
        for (wpit = gui->re_lane_->current()->wayPoints().begin(), wpit_end = gui->re_lane_->current()->wayPoints().end();
                wpit != wpit_end; ++wpit) {
            w = *wpit;
            wpit_next = wpit;
            wpit_next++;
            if (wpit_next != wpit_end) {
                w_next = *wpit_next;
                draw_arrow(w->utmX() - center_x, w->utmY() - center_y, w_next->utmX() - center_x, w_next->utmY() - center_y, 0.5, 2.0);
                // std::cout << "lane at " << w->utmX() << " " << w->utmY() << std::endl;
            }
        }

        drawSmoothedLaneStack(center_x, center_y);
    }

    // draw the selected waypoint in yellow
    if (gui->re_wp_->current()) {
        glPointSize(5.0);
        glColor4f(1, 0.5, 0, blend);
        glPushMatrix();
        glColor4f(1, 0.5, 0, blend);
        glTranslatef(0, 0, -0.005);
        draw_circle(gui->re_wp_->current()->utmX() - center_x, gui->re_wp_->current()->utmY() - center_y, 0.5, 1);
        render_stroke_text_centered_2D(gui->re_wp_->current()->utmX() - center_x - 1.5,
                gui->re_wp_->current()->utmY() - center_y - 1, GLUT_STROKE_ROMAN, 0.5,
                gui->re_wp_->current()->name().c_str());

        //	fr.drawString2D(gui->re_wp_->current()->name(), gui->re_wp_->current()->utmX() - center_x - 1.5, gui->re_wp_->current()->utmY() - center_y - 1);

        glPointSize(1.0);
        glPopMatrix();
    }

    // draw exit arrow
    double x1, y1, x2, y2, angle;
    if ((gui->current_element == RNDF_ELEMENT_EXIT) && gui->gotFromPoint) {
        if (gui->re_wp_->current() || gui->re_pp_->current()) {
            if (gui->re_wp_->current()) {
                x1 = gui->re_wp_->current()->utmX();
                y1 = gui->re_wp_->current()->utmY();
            }
            else {
                x1 = gui->re_pp_->current()->utmX();
                y1 = gui->re_pp_->current()->utmY();
            }

            x2 = gui->last_utm_x;
            y2 = gui->last_utm_y;
            glColor4f(1, 0, 1, blend);
            draw_dashed_line(x1 - center_x, y1 - center_y, x2 - center_x, y2 - center_y, 1.0);
            angle = atan2(y2 - y1, x2 - x1);
            draw_arrowhead_2D(x2 - center_x, y2 - center_y, angle);
        }
    }

    if (gui->re_perimeter_->current()) {
        glLineWidth(2);
        glColor4f(0, 0.5, 1, blend);
        for (ppit = gui->re_perimeter_->current()->perimeterPoints().begin(), ppit_end
                = gui->re_perimeter_->current()->perimeterPoints().end(); ppit != ppit_end; ++ppit) {
            p = *ppit;
            ppit_next = ppit;
            ppit_next++;
            if (ppit_next != ppit_end) {
                p_next = *ppit_next;
                draw_arrow(p->utmX() - center_x, p->utmY() - center_y, p_next->utmX() - center_x, p_next->utmY()
                        - center_y, 0.5, 2.0);
                //			 std::cout << "Perimeter at " << p->utmX() << " " << p->utmY() << std::endl;
            }
        }

    }

    if (gui->re_pp_->current()) {
        glPointSize(5.0);
        glColor4f(0, 0.5, 1, blend);
        glPushMatrix();
        glTranslatef(0, 0, -0.005);
        draw_circle(gui->re_pp_->current()->utmX() - center_x, gui->re_pp_->current()->utmY()
                - center_y, 0.5, 1);
        render_stroke_text_centered_2D(gui->re_pp_->current()->utmX() - center_x - 1.5,
                gui->re_pp_->current()->utmY() - center_y - 1, GLUT_STROKE_ROMAN, 0.5,
                (char*) gui->re_pp_->current()->name().c_str());
        glPointSize(1.0);
        glPopMatrix();
        //	 std::cout << "Perimeter point at " << p->utmX() << " " << p->utmY() << std::endl;
    }

}
Exemple #15
0
void ui_menu::draw(bool customonly)
{
	float line_height = machine().ui().get_line_height();
	float lr_arrow_width = 0.4f * line_height * machine().render().ui_aspect();
	float ud_arrow_width = line_height * machine().render().ui_aspect();
	float gutter_width = lr_arrow_width * 1.3f;
	float x1, y1, x2, y2;

	float effective_width, effective_left;
	float visible_width, visible_main_menu_height;
	float visible_extra_menu_height;
	float visible_top, visible_left;
	int selected_subitem_too_big = FALSE;
	int visible_lines;
	int top_line;
	int itemnum, linenum;
	bool mouse_hit, mouse_button;
	render_target *mouse_target;
	INT32 mouse_target_x, mouse_target_y;
	float mouse_x = -1, mouse_y = -1;

	// compute the width and height of the full menu
	visible_width = 0;
	visible_main_menu_height = 0;
	for (itemnum = 0; itemnum < numitems; itemnum++)
	{
		const ui_menu_item &pitem = item[itemnum];
		float total_width;

		// compute width of left hand side
		total_width = gutter_width + machine().ui().get_string_width(pitem.text) + gutter_width;

		// add in width of right hand side
		if (pitem.subtext)
			total_width += 2.0f * gutter_width + machine().ui().get_string_width(pitem.subtext);

		// track the maximum
		if (total_width > visible_width)
			visible_width = total_width;

		// track the height as well
		visible_main_menu_height += line_height;
	}

	// account for extra space at the top and bottom
	visible_extra_menu_height = customtop + custombottom;

	// add a little bit of slop for rounding
	visible_width += 0.01f;
	visible_main_menu_height += 0.01f;

	// if we are too wide or too tall, clamp it down
	if (visible_width + 2.0f * UI_BOX_LR_BORDER > 1.0f)
		visible_width = 1.0f - 2.0f * UI_BOX_LR_BORDER;

	// if the menu and extra menu won't fit, take away part of the regular menu, it will scroll
	if (visible_main_menu_height + visible_extra_menu_height + 2.0f * UI_BOX_TB_BORDER > 1.0f)
		visible_main_menu_height = 1.0f - 2.0f * UI_BOX_TB_BORDER - visible_extra_menu_height;

	visible_lines = floor(visible_main_menu_height / line_height);
	visible_main_menu_height = (float)visible_lines * line_height;

	// compute top/left of inner menu area by centering
	visible_left = (1.0f - visible_width) * 0.5f;
	visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f;

	// if the menu is at the bottom of the extra, adjust
	visible_top += customtop;

	// first add us a box
	x1 = visible_left - UI_BOX_LR_BORDER;
	y1 = visible_top - UI_BOX_TB_BORDER;
	x2 = visible_left + visible_width + UI_BOX_LR_BORDER;
	y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER;
	if (!customonly)
		machine().ui().draw_outlined_box(container, x1, y1, x2, y2, UI_BACKGROUND_COLOR);

	// determine the first visible line based on the current selection
	top_line = selected - visible_lines / 2;
	if (top_line < 0)
		top_line = 0;
	if (top_line + visible_lines >= numitems)
		top_line = numitems - visible_lines;

	// determine effective positions taking into account the hilighting arrows
	effective_width = visible_width - 2.0f * gutter_width;
	effective_left = visible_left + gutter_width;

	// locate mouse
	mouse_hit = false;
	mouse_button = false;
	if (!customonly)
	{
		mouse_target = ui_input_find_mouse(machine(), &mouse_target_x, &mouse_target_y, &mouse_button);
		if (mouse_target != nullptr)
			if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, *container, mouse_x, mouse_y))
				mouse_hit = true;
	}

	// loop over visible lines
	hover = numitems + 1;
	if (!customonly)
		for (linenum = 0; linenum < visible_lines; linenum++)
		{
			float line_y = visible_top + (float)linenum * line_height;
			itemnum = top_line + linenum;
			const ui_menu_item &pitem = item[itemnum];
			const char *itemtext = pitem.text;
			rgb_t fgcolor = UI_TEXT_COLOR;
			rgb_t bgcolor = UI_TEXT_BG_COLOR;
			rgb_t fgcolor2 = UI_SUBITEM_COLOR;
			rgb_t fgcolor3 = UI_CLONE_COLOR;
			float line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
			float line_y0 = line_y;
			float line_x1 = x2 - 0.5f * UI_LINE_WIDTH;
			float line_y1 = line_y + line_height;

			// set the hover if this is our item
			if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && pitem.is_selectable())
				hover = itemnum;

			// if we're selected, draw with a different background
			if (itemnum == selected)
			{
				fgcolor = UI_SELECTED_COLOR;
				bgcolor = UI_SELECTED_BG_COLOR;
				fgcolor2 = UI_SELECTED_COLOR;
				fgcolor3 = UI_SELECTED_COLOR;
			}

			// else if the mouse is over this item, draw with a different background
			else if (itemnum == hover)
			{
				fgcolor = UI_MOUSEOVER_COLOR;
				bgcolor = UI_MOUSEOVER_BG_COLOR;
				fgcolor2 = UI_MOUSEOVER_COLOR;
				fgcolor3 = UI_MOUSEOVER_COLOR;
			}

			// if we have some background hilighting to do, add a quad behind everything else
			if (bgcolor != UI_TEXT_BG_COLOR)
				highlight(container, line_x0, line_y0, line_x1, line_y1, bgcolor);

			// if we're on the top line, display the up arrow
			if (linenum == 0 && top_line != 0)
			{
				draw_arrow(
									container,
									0.5f * (x1 + x2) - 0.5f * ud_arrow_width,
									line_y + 0.25f * line_height,
									0.5f * (x1 + x2) + 0.5f * ud_arrow_width,
									line_y + 0.75f * line_height,
									fgcolor,
									ROT0);
				if (hover == itemnum)
					hover = -2;
			}

			// if we're on the bottom line, display the down arrow
			else if (linenum == visible_lines - 1 && itemnum != numitems - 1)
			{
				draw_arrow(
									container,
									0.5f * (x1 + x2) - 0.5f * ud_arrow_width,
									line_y + 0.25f * line_height,
									0.5f * (x1 + x2) + 0.5f * ud_arrow_width,
									line_y + 0.75f * line_height,
									fgcolor,
									ROT0 ^ ORIENTATION_FLIP_Y);
				if (hover == itemnum)
					hover = -1;
			}

			// if we're just a divider, draw a line
			else if (strcmp(itemtext, MENU_SEPARATOR_ITEM) == 0)
				container->add_line(visible_left, line_y + 0.5f * line_height, visible_left + visible_width, line_y + 0.5f * line_height, UI_LINE_WIDTH, UI_BORDER_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));

			// if we don't have a subitem, just draw the string centered
			else if (pitem.subtext == nullptr)
				machine().ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width,
							JUSTIFY_CENTER, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, nullptr, nullptr);

			// otherwise, draw the item on the left and the subitem text on the right
			else
			{
				int subitem_invert = pitem.flags & MENU_FLAG_INVERT;
				const char *subitem_text = pitem.subtext;
				float item_width, subitem_width;

				// draw the left-side text
				machine().ui().draw_text_full(container, itemtext, effective_left, line_y, effective_width,
							JUSTIFY_LEFT, WRAP_TRUNCATE, DRAW_NORMAL, fgcolor, bgcolor, &item_width, nullptr);

				// give 2 spaces worth of padding
				item_width += 2.0f * gutter_width;

				// if the subitem doesn't fit here, display dots
				if (machine().ui().get_string_width(subitem_text) > effective_width - item_width)
				{
					subitem_text = "...";
					if (itemnum == selected)
						selected_subitem_too_big = TRUE;
				}

				// draw the subitem right-justified
				machine().ui().draw_text_full(container, subitem_text, effective_left + item_width, line_y, effective_width - item_width,
							JUSTIFY_RIGHT, WRAP_TRUNCATE, DRAW_NORMAL, subitem_invert ? fgcolor3 : fgcolor2, bgcolor, &subitem_width, nullptr);

				// apply arrows
				if (itemnum == selected && (pitem.flags & MENU_FLAG_LEFT_ARROW))
				{
					draw_arrow(
										container,
										effective_left + effective_width - subitem_width - gutter_width,
										line_y + 0.1f * line_height,
										effective_left + effective_width - subitem_width - gutter_width + lr_arrow_width,
										line_y + 0.9f * line_height,
										fgcolor,
										ROT90 ^ ORIENTATION_FLIP_X);
				}
				if (itemnum == selected && (pitem.flags & MENU_FLAG_RIGHT_ARROW))
				{
					draw_arrow(
										container,
										effective_left + effective_width + gutter_width - lr_arrow_width,
										line_y + 0.1f * line_height,
										effective_left + effective_width + gutter_width,
										line_y + 0.9f * line_height,
										fgcolor,
										ROT90);
				}
			}
		}

	// if the selected subitem is too big, display it in a separate offset box
	if (selected_subitem_too_big)
	{
		const ui_menu_item &pitem = item[selected];
		int subitem_invert = pitem.flags & MENU_FLAG_INVERT;
		linenum = selected - top_line;
		float line_y = visible_top + (float)linenum * line_height;
		float target_width, target_height;
		float target_x, target_y;

		// compute the multi-line target width/height
		machine().ui().draw_text_full(container, pitem.subtext, 0, 0, visible_width * 0.75f,
					JUSTIFY_RIGHT, WRAP_WORD, DRAW_NONE, ARGB_WHITE, ARGB_BLACK, &target_width, &target_height);

		// determine the target location
		target_x = visible_left + visible_width - target_width - UI_BOX_LR_BORDER;
		target_y = line_y + line_height + UI_BOX_TB_BORDER;
		if (target_y + target_height + UI_BOX_TB_BORDER > visible_main_menu_height)
			target_y = line_y - target_height - UI_BOX_TB_BORDER;

		// add a box around that
		machine().ui().draw_outlined_box(container, target_x - UI_BOX_LR_BORDER,
							target_y - UI_BOX_TB_BORDER,
							target_x + target_width + UI_BOX_LR_BORDER,
							target_y + target_height + UI_BOX_TB_BORDER, subitem_invert ? UI_SELECTED_BG_COLOR : UI_BACKGROUND_COLOR);
		machine().ui().draw_text_full(container, pitem.subtext, target_x, target_y, target_width,
					JUSTIFY_RIGHT, WRAP_WORD, DRAW_NORMAL, UI_SELECTED_COLOR, UI_SELECTED_BG_COLOR, nullptr, nullptr);
	}

	// if there is something special to add, do it by calling the virtual method
	custom_render((selected >= 0 && selected < numitems) ? item[selected].ref : nullptr, customtop, custombottom, x1, y1, x2, y2);

	// return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow
	visitems = visible_lines - (top_line != 0) - (top_line + visible_lines != numitems);
}
Exemple #16
0
void game_render(Game* game){
	game->render(game);
	int time_render_begin = SDL_GetTicks();
	
	//RENDER AN INVISIBLE PLANE FOR GROUND DEPTH
	glPushMatrix();
		glTranslated(-game->player->x,-game->player->y,0);
		glTranslated(0,0,-4);
		glRotated(90,0,1,0);
		glColor4d(0,0,0,0);
		draw_face(600,0);
	glPopMatrix();
	GLfloat bkColor[3];
	glGetFloatv(GL_COLOR_CLEAR_VALUE, bkColor);

	//=======================LOOP TEST=========================
	//=======================LOOP TEST=========================
	//=======================LOOP TEST=========================
	// glPushMatrix();
	// 	glTranslated(-game->player->x,-game->player->y,-4);
	// 	glRotated(90,0,1,0);
	// 	glScaled(1,game->world_y_size,game->world_x_size);
	// 	glLineWidth(5);
	// 	glColor4d(0,0,1,1);
	// 	draw_square(.5,0);
	// glPopMatrix();


	Arrow* arrow;
	Mechant* mechant;

	//REFLEXIONS
	glDepthFunc(GL_GREATER);
	glDepthMask(GL_FALSE);
	glPushMatrix();
		//TO THE GROUND
		glTranslated(0,0,-8);


		//=======================ARROWS=======================
		//=======================ARROWS=======================
		//=======================ARROWS=======================
		if(game->sorting){
			game_sort_arrow_distance(game);
		}
		double r_color=.5+.5*bkColor[0];
		double g_color=0+.5*bkColor[1];
		double b_color=0+.5*bkColor[2];
		if(game->stereo){
			r_color=.35+.5*bkColor[0];
			g_color=.1+.5*bkColor[1];
			b_color=.1+.5*bkColor[2];

		}

		glColor4d(r_color,g_color,b_color,1);
		arrow=game->arrows;
		void (*draw_arrow)(Arrow * arrow, Game* game);
		if(game->color_debug){
			draw_arrow=game_render_one_arrow_color;
		}else{
			draw_arrow=game_render_one_arrow;
		}
		int i=0;
		// double last_rendered_total_arrow_copy=last_rendered_total_arrow;
		// last_rendered_total_arrow=0;
		while(arrow!=NULL){
			// glColor4d(r_color,g_color,b_color,1-i/last_rendered_total_arrow_copy);
			// i++;
			
			double xx=arrow->x+game->player->x;
			double yy=arrow->y+game->player->y;
			double zz=arrow->z+game->player->z;
			arrow->dist=xx*xx+yy*yy+zz*zz;

			if(arrow->dist<90000){
				// glDepthFunc(GL_ALWAYS);//debug
				glPushMatrix();
					glTranslated(arrow->x,arrow->y,-arrow->z);
					glScaled(1,1,-1);
					draw_arrow(arrow,game);
				glPopMatrix();
			}
			arrow=arrow->next;
		}
		arrow_high_quality_count=ARROW_MAX_HIGH_QUALITY;
		arrow_low_quality_count=ARROW_MAX_LOW_QUALITY;
		arrow_count=ARROW_MAX;
		//======================MECHANTS======================
		//======================MECHANTS======================
		//======================MECHANTS======================
		mechant=game->mechants;
		while(mechant!=NULL){
			// WORLD LOOP
			while(mechant->x+game->player->x+game->world_x_size/2.>0)
				mechant->x-=game->world_x_size;
			while(mechant->x+game->player->x+game->world_x_size/2.<0)
				mechant->x+=game->world_x_size;
			while(mechant->y+game->player->y+game->world_y_size/2.>0)
				mechant->y-=game->world_y_size;
			while(mechant->y+game->player->y+game->world_y_size/2.<0)
				mechant->y+=game->world_y_size;

			double xx=mechant->x+game->player->x;
			double yy=mechant->y+game->player->y;
			double zz=mechant->z+game->player->z;
			mechant->dist=xx*xx+yy*yy+zz*zz;

			glPushMatrix();
				glScaled(1,1,-1);
				glTranslated(mechant->x,mechant->y,mechant->z+1);
				game_render_one_mechant(mechant,game,r_color,g_color,b_color,1);
			glPopMatrix();

			mechant=mechant->next;
		}

	glPopMatrix();
	glDepthMask(GL_TRUE);
	glDepthFunc(GL_LESS);




	//REAL WORLD
	r_color=1;
	g_color=0;
	b_color=0;
	if(game->stereo){
		r_color=.7;
		g_color=.2;
		b_color=.2;
	}
	glColor4d(r_color,g_color,b_color,1);
	arrow=game->arrows;
	// i=0;
	while(arrow!=NULL){
		if(arrow->dist<90000){
			// glColor4d(r_color,g_color,b_color,1-i/last_rendered_total_arrow_copy);
			// i++;
			glPushMatrix();
				glTranslated(arrow->x,arrow->y,arrow->z);
				draw_arrow(arrow,game);
			glPopMatrix();
		}
		arrow=arrow->next;
	}
	arrow_high_quality_count=ARROW_MAX_HIGH_QUALITY;
	arrow_low_quality_count=ARROW_MAX_LOW_QUALITY;
	arrow_count=ARROW_MAX;
	//======================MECHANTS======================
	//======================MECHANTS======================
	//======================MECHANTS======================
	mechant=game->mechants;
	while(mechant!=NULL){
		// WORLD LOOP
		while(mechant->x+game->player->x+game->world_x_size/2.>0)
			mechant->x-=game->world_x_size;
		while(mechant->x+game->player->x+game->world_x_size/2.<0)
			mechant->x+=game->world_x_size;
		while(mechant->y+game->player->y+game->world_y_size/2.>0)
			mechant->y-=game->world_y_size;
		while(mechant->y+game->player->y+game->world_y_size/2.<0)
			mechant->y+=game->world_y_size;

		double xx=mechant->x+game->player->x;
		double yy=mechant->y+game->player->y;
		double zz=mechant->z+game->player->z;
		mechant->dist=xx*xx+yy*yy+zz*zz;

		glPushMatrix();
			// glScaled(1,1,-1);
			glTranslated(mechant->x,mechant->y,mechant->z+1);
			game_render_one_mechant(mechant,game,r_color,g_color,b_color,0);
		glPopMatrix();

		mechant=mechant->next;
	}




	Particle* p=game->particles;
	glDisable(GL_POINT_SMOOTH);
	glPointSize(7);
	if(game->stereo){
		glColor4d(.7,.2,.2,1);
	}else{
		glColor4d(1,0,0,1);
	}
	while(p!=NULL){
		// double xx=p->x+game->player->x;
		// double yy=p->y+game->player->y;
		// double zz=p->z+game->player->z;
		// double dist = sqrt(xx*xx+yy*yy+zz*zz);
		// dist=50-dist;
		// if(dist<7)dist=7;
		// if(dist>30)dist=30;
		// glPointSize(dist);
		glBegin(GL_POINTS);
			glVertex3d(p->x,p->y,p->z);
		glEnd();
		p=p->next;
	}
	glEnable(GL_POINT_SMOOTH);




	//==================================================
	//==================================================
	//==================================================
	int duration=SDL_GetTicks()-time_render_begin;
	if(duration>20){
		// printf("reducing arrow limits\n");
		ARROW_MAX_HIGH_QUALITY-=random(1,10)+ARROW_MAX_HIGH_QUALITY/16.;
		ARROW_MAX_LOW_QUALITY -=random(1,10)+ARROW_MAX_LOW_QUALITY/16.;
		ARROW_MAX             -=random(1,10)+ARROW_MAX/16.;
		if(ARROW_MAX_HIGH_QUALITY<70)ARROW_MAX_HIGH_QUALITY=70;
		if(ARROW_MAX_LOW_QUALITY<70)ARROW_MAX_LOW_QUALITY=70;
		// if(ARROW_MAX<50)ARROW_MAX=50;
		// printf("%i,%i,%i\n",ARROW_MAX_HIGH_QUALITY,ARROW_MAX_LOW_QUALITY,ARROW_MAX);

	}else if(duration<15){
		// printf("unreducing arrow limits\n");
		// ARROW_MAX_HIGH_QUALITY+=log(1+ARROW_MAX_HIGH_QUALITY*.2);
		// ARROW_MAX_LOW_QUALITY+=log(1+ARROW_MAX_LOW_QUALITY*.2);
		// ARROW_MAX+=log(1+ARROW_MAX*.2);
		ARROW_MAX_HIGH_QUALITY+=random(10,10)+ARROW_MAX_HIGH_QUALITY/128.;
		ARROW_MAX_LOW_QUALITY +=random(10,10)+ARROW_MAX_LOW_QUALITY/128.;
		ARROW_MAX             +=random(10,10)+ARROW_MAX/128.;
		if(ARROW_MAX_HIGH_QUALITY>10000)ARROW_MAX_HIGH_QUALITY=10000;
		if(ARROW_MAX_LOW_QUALITY>10000)ARROW_MAX_LOW_QUALITY=10000;
		if(ARROW_MAX>10000)ARROW_MAX=10000;
		// if(ARROW_MAX!=10000)
		// 	printf("%i,%i,%i\n",ARROW_MAX_HIGH_QUALITY,ARROW_MAX_LOW_QUALITY,ARROW_MAX);
	}
}
Exemple #17
0
void menu_dats_view::draw(uint32_t flags)
{
	auto line_height = ui().get_line_height();
	auto ud_arrow_width = line_height * machine().render().ui_aspect();
	auto gutter_width = 0.52f * line_height * machine().render().ui_aspect();
	mouse_x = -1, mouse_y = -1;
	float visible_width = 1.0f - 2.0f * UI_BOX_LR_BORDER;
	float visible_left = (1.0f - visible_width) * 0.5f;

	draw_background();

	hover = item.size() + 1;
	visible_items = item.size() - 2;
	float extra_height = 2.0f * line_height;
	float visible_extra_menu_height = customtop + custombottom + extra_height;

	// locate mouse
	mouse_hit = false;
	mouse_button = false;
	mouse_target = machine().ui_input().find_mouse(&mouse_target_x, &mouse_target_y, &mouse_button);
	if (mouse_target != nullptr)
		if (mouse_target->map_point_container(mouse_target_x, mouse_target_y, container(), mouse_x, mouse_y))
			mouse_hit = true;

	// account for extra space at the top and bottom
	float visible_main_menu_height = 1.0f - 2.0f * UI_BOX_TB_BORDER - visible_extra_menu_height;
	m_visible_lines = int(std::trunc(visible_main_menu_height / line_height));
	visible_main_menu_height = float(m_visible_lines) * line_height;

	// compute top/left of inner menu area by centering
	float visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f;

	// if the menu is at the bottom of the extra, adjust
	visible_top += customtop;

	// compute left box size
	float x1 = visible_left;
	float y1 = visible_top - UI_BOX_TB_BORDER;
	float x2 = x1 + visible_width;
	float y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER + extra_height;
	float line = visible_top + float(m_visible_lines) * line_height;

	ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR);

	m_visible_lines = (std::min)(visible_items, m_visible_lines);
	top_line = (std::max)(0, top_line);
	if (top_line + m_visible_lines >= visible_items)
		top_line = visible_items - m_visible_lines;

	// determine effective positions taking into account the hilighting arrows
	float effective_width = visible_width - 2.0f * gutter_width;
	float effective_left = visible_left + gutter_width;

	int const n_loop = (std::min)(visible_items, m_visible_lines);
	for (int linenum = 0; linenum < n_loop; linenum++)
	{
		float line_y = visible_top + (float)linenum * line_height;
		int itemnum = top_line + linenum;
		const menu_item &pitem = item[itemnum];
		const char *itemtext = pitem.text.c_str();
		rgb_t fgcolor = UI_TEXT_COLOR;
		rgb_t bgcolor = UI_TEXT_BG_COLOR;
		float line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
		float line_y0 = line_y;
		float line_x1 = x2 - 0.5f * UI_LINE_WIDTH;
		float line_y1 = line_y + line_height;

		// if we're on the top line, display the up arrow
		if (linenum == 0 && top_line != 0)
		{
			draw_arrow(0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height,
				0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0);

			if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y)
			{
				fgcolor = UI_MOUSEOVER_COLOR;
				bgcolor = UI_MOUSEOVER_BG_COLOR;
				highlight(line_x0, line_y0, line_x1, line_y1, bgcolor);
				hover = HOVER_ARROW_UP;
			}
		}
		// if we're on the bottom line, display the down arrow
		else if (linenum == m_visible_lines - 1 && itemnum != visible_items - 1)
		{
			draw_arrow(0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height,
				0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0 ^ ORIENTATION_FLIP_Y);

			if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y)
			{
				fgcolor = UI_MOUSEOVER_COLOR;
				bgcolor = UI_MOUSEOVER_BG_COLOR;
				highlight(line_x0, line_y0, line_x1, line_y1, bgcolor);
				hover = HOVER_ARROW_DOWN;
			}
		}

		// draw dats text
		else if (pitem.subtext.empty())
		{
			ui().draw_text_full(container(), itemtext, effective_left, line_y, effective_width, ui::text_layout::LEFT, ui::text_layout::NEVER,
				mame_ui_manager::NORMAL, fgcolor, bgcolor, nullptr, nullptr);
		}
	}

	for (size_t count = visible_items; count < item.size(); count++)
	{
		const menu_item &pitem = item[count];
		const char *itemtext = pitem.text.c_str();
		float line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
		float line_y0 = line;
		float line_x1 = x2 - 0.5f * UI_LINE_WIDTH;
		float line_y1 = line + line_height;
		rgb_t fgcolor = UI_SELECTED_COLOR;
		rgb_t bgcolor = UI_SELECTED_BG_COLOR;

		if (mouse_hit && line_x0 <= mouse_x && line_x1 > mouse_x && line_y0 <= mouse_y && line_y1 > mouse_y && is_selectable(pitem))
			hover = count;

		if (pitem.type == menu_item_type::SEPARATOR)
			container().add_line(visible_left, line + 0.5f * line_height, visible_left + visible_width, line + 0.5f * line_height,
				UI_LINE_WIDTH, UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
		else
		{
			highlight(line_x0, line_y0, line_x1, line_y1, bgcolor);
			ui().draw_text_full(container(), itemtext, effective_left, line, effective_width, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
				mame_ui_manager::NORMAL, fgcolor, bgcolor, nullptr, nullptr);
		}
		line += line_height;
	}

	// if there is something special to add, do it by calling the virtual method
	custom_render(get_selection_ref(), customtop, custombottom, x1, y1, x2, y2);

	// return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow
	m_visible_items = m_visible_lines - (top_line != 0) - (top_line + m_visible_lines != visible_items);
}
Exemple #18
0
PyObject* draw_path_arrow( PyObject* self, PyObject* args )
{
    PyObject* pobj;
    PyObject* endarrow = NULL;
    PyObject* startarrow = NULL;
    int endsonly = 0;
    
    int endstyle, startstyle;
    double endwidth, startwidth;
    double endlength, startlength;
    
    PyObject* plist = NULL;
    int i;
    int size;
    PyObject* item;

    int cset = 0;    // is there a current point?
    double sx, sy, stx, sty;
    double cx, cy;   // current point
    double nx, ny;
    int open = 0, first = 1;
    
    double tx, ty;
    
    
    if ( !PyArg_ParseTuple( args, "OO|Oi", &pobj, &endarrow, &startarrow, &endsonly ) )
	return NULL;

    if ( endarrow == Py_None )
 	endarrow = NULL; 
    
    if ( endarrow )
    {
	if ( !PyTuple_Check( endarrow ) || PyTuple_Size( endarrow ) != 3 )
	{
	    PyErr_SetString( PyExc_ValueError, "bad value for endarrow" );
	    return NULL;
	}
	endstyle = PyInt_AsLong( PyTuple_GetItem( endarrow, 0 ) );
	endwidth = PyFloat_AsDouble( PyTuple_GetItem( endarrow, 1 ) );
	endlength = PyFloat_AsDouble( PyTuple_GetItem( endarrow, 2 ) );
    }
	
    if ( startarrow == Py_None ) 
	startarrow = NULL;
    
    if ( startarrow )
    {
	if ( !PyTuple_Check( startarrow ) || PyTuple_Size( startarrow ) != 3 )
	{
	    PyErr_SetString( PyExc_ValueError, "bad value for startarrow" );
	    return NULL;
	}
	startstyle = PyInt_AsLong( PyTuple_GetItem( startarrow, 0 ) );
	startwidth = PyFloat_AsDouble( PyTuple_GetItem( startarrow, 1 ) );
	startlength = PyFloat_AsDouble( PyTuple_GetItem( startarrow, 2 ) );
    }
    
    delete_invalid_lists( pobj );

    plist = PyObject_GetAttrString( pobj, "raw" );
    if ( plist == NULL || !PyList_Check( plist ) )
    {
	Py_XDECREF( plist );
	PyErr_SetString( DrawError, "bad path object" );
	return NULL;
    }
    
    size = PyList_Size( plist );

    open = 0;
    for ( i = 0; i < size; ++i )
    {
	item = PyList_GetItem( plist, i );
	
	switch( PyInt_AsLong( PyList_GetItem( item, 0 ) ) )
	{
	  case S_CLOSE:
	    open = 0;
	    break;
	    
	  case S_MOVE:
	    if ( open )
	    {
		if ( startarrow && (first || !endsonly) )
		    draw_arrow( sx, sy, stx, sty, startstyle, startwidth, startlength );
		if ( endarrow && !endsonly )
		    draw_arrow( cx, cy, tx, ty, endstyle, endwidth, endlength );
		first = 0;
	    }
	    cx = PyFloat_AsDouble( PyList_GetItem( item, 1 ) );
	    cy = PyFloat_AsDouble( PyList_GetItem( item, 2 ) );
	    open = 0;
	    break;
	    
	  case S_LINE:
	    nx = PyFloat_AsDouble( PyList_GetItem( item, 1 ) );
	    ny = PyFloat_AsDouble( PyList_GetItem( item, 2 ) );
	    tx = nx - cx;
	    ty = ny - cy;
	    if ( !open )
	    {
		sx = cx;
		sy = cy;
		stx = -tx;
		sty = -ty;
	    }
	    cx = nx;
	    cy = ny;
	    open = 1;
	    break;
	    
	  case S_CURVE:
	    if ( !open )
	    {
		sx = cx;
		sy = cy;
		stx = cx - PyFloat_AsDouble( PyList_GetItem( item, 1 ) );
		sty = cy - PyFloat_AsDouble( PyList_GetItem( item, 2 ) );
	    }
		
	    cx = PyFloat_AsDouble( PyList_GetItem( item, 5 ) );
	    cy = PyFloat_AsDouble( PyList_GetItem( item, 6 ) );
	    tx = cx - PyFloat_AsDouble( PyList_GetItem( item, 3 ) );
	    ty = cy - PyFloat_AsDouble( PyList_GetItem( item, 4 ) );
	    open = 1;
	    break;
	    
	  case S_QCURVE:
	    nx = PyFloat_AsDouble( PyList_GetItem( item, 1 ) );
	    ny = PyFloat_AsDouble( PyList_GetItem( item, 2 ) );
	    if ( !open )
	    {
		sx = cx;
		sy = cy;
		stx = cx - nx;
		sty = cy - ny;
	    }
	    cx = PyFloat_AsDouble( PyList_GetItem( item, 3 ) );
	    cy = PyFloat_AsDouble( PyList_GetItem( item, 4 ) );
	    tx = cx - nx;
	    ty = cy - ny;
	    open = 1;
	    break;
	}
    }

    if ( open )
    {
	if ( startarrow && (first || !endsonly) )
	    draw_arrow( sx, sy, stx, sty, startstyle, startwidth, startlength );
	if ( endarrow )
	    draw_arrow( cx, cy, tx, ty, endstyle, endwidth, endlength );
    }
    
    Py_XDECREF( plist );

    Py_INCREF( Py_None );
    return Py_None;
}
Exemple #19
0
void VPythonFile::draw_axes(const double shaft_width)
{
    draw_arrow(Vector3d(0.0), Vector3d(1.0, 0.0, 0.0), "color.red", shaft_width);
    draw_arrow(Vector3d(0.0), Vector3d(0.0, 1.0, 0.0), "color.green", shaft_width);
    draw_arrow(Vector3d(0.0), Vector3d(0.0, 0.0, 1.0), "color.blue", shaft_width);
}
Exemple #20
0
void simulation_render(simulation_t* sim)
{
const color_t red=get_color(255,0,0);
const color_t white=get_color(255,255,255);

orbit_t* current_orbit=&sim->current_spacecraft->orbit;


//Calculate camera position and orientation
sim->camera.position=sim->current_spacecraft->base.position;
//vector_t primary_to_cam=vector_subtract(sim->camera.position,current_orbit->primary->base.position);
sim->camera.rotation=0;//atan2(primary_to_cam.y,primary_to_cam.x)+M_PI_2;



//Plot apoapsis and periapsis
vector_t apoapsis=vector_transform(orbit_get_position(current_orbit,current_orbit->longitude_of_periapsis+M_PI),sim->camera);
vector_t periapsis=vector_transform(orbit_get_position(current_orbit,current_orbit->longitude_of_periapsis),sim->camera);
draw_cross(apoapsis,red);
draw_cross(periapsis,red);
draw_text(apoapsis.x-20,apoapsis.y-20,"Apoapsis");
draw_text(periapsis.x-20,periapsis.y-20,"Periapsis");
//Render arrow on spacecraft
draw_arrow(vector_transform(sim->current_spacecraft->base.position,sim->camera),sim->current_spacecraft->base.rotation+sim->camera.rotation,get_color(0,255,255));
//Show orbit
orbit_show(current_orbit,sim->camera,get_color(0,255,0));

char str[64];
//Show speedup
	if(sim->speedup==1)draw_text(20,650,"Real time");
	else
	{
	sprintf(str,"Fast forward: %dx",sim->speedup);

	draw_text(20,650,str);
	}


int i;
	for(i=0;i<sim->num_celestial_bodies;i++)
	{
	//Show orbit
		if(sim->celestial_bodies[i].orbit.primary!=NULL)
        {
        orbit_show(&sim->celestial_bodies[i].orbit,sim->camera,get_color(255,255,0));
        simulation_render_lagrange_points(sim,&sim->celestial_bodies[i]);
        }
	//Draw planet
	object_render((object_t*)(&sim->celestial_bodies[i]),sim->camera);
	//Show name
	vector_t position=vector_transform(sim->celestial_bodies[i].base.position,sim->camera);
	draw_text(position.x,position.y,sim->celestial_bodies[i].name);
	//Draw sphere of influence
	int j;
	double theta=0;
		for(j=0;j<32;j++)
		{
		vector_t line_start=sim->celestial_bodies[i].base.position;
		line_start.x+=sim->celestial_bodies[i].sphere_of_influence*sin(theta);
		line_start.y+=sim->celestial_bodies[i].sphere_of_influence*cos(theta);
		line_start=vector_transform(line_start,sim->camera);
		theta+=M_PI/32;
		vector_t line_end=sim->celestial_bodies[i].base.position;
		line_end.x+=sim->celestial_bodies[i].sphere_of_influence*sin(theta);
		line_end.y+=sim->celestial_bodies[i].sphere_of_influence*cos(theta);
		line_end=vector_transform(line_end,sim->camera);
		theta+=M_PI/32;
		draw_line(line_start.x,line_start.y,line_end.x,line_end.y,white);
		}
	}
	for(i=0;i<sim->num_spacecraft;i++)
	{
	object_render((object_t*)(&sim->spacecraft[i]),sim->camera);
	}
render_spacecraft_info(sim->current_spacecraft,50,50);
//render_celestial_body_info(sim->current_spacecraft->orbit.primary,500,50);
//render_celestial_body_info(&sim->celestial_bodies[5],950,50);
}
void draw_frustum(
	float l, float r, float b, float t,
	float n, float f )
{
	GLfloat const kf = f/n;
	GLfloat const pos[][3] = {
		{0,0,0},
		{l, b, -n},
		{r, b, -n},
		{r, t, -n},
		{l, t, -n},
		{kf*l, kf*b, -f},
		{kf*r, kf*b, -f},
		{kf*r, kf*t, -f},
		{kf*l, kf*t, -f}
	};
	GLushort const idx_tip[][2] = {
		{0, 1},
		{0, 2},
		{0, 3},
		{0, 4}
	};
	GLushort const idx_vol[][2] = {
		{1, 5}, {2, 6},	{3, 7},	{4, 8},
		{1, 2},	{2, 3},	{3, 4},	{4, 1},
		{5, 6},	{6, 7},	{7, 8},	{8, 5}
	};

	glDisableClientState(GL_COLOR_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, pos);

	glLineWidth(1);
	glLineStipple(2, 0xf3cf);
	glEnable(GL_LINE_STIPPLE);
	glDrawElements(GL_LINES, 2*4, GL_UNSIGNED_SHORT, idx_tip);

	glLineWidth(2);
	glLineStipple(1, 0xffff);
	glDisable(GL_LINE_STIPPLE);
	glDrawElements(GL_LINES, 2*4*3, GL_UNSIGNED_SHORT, idx_vol);
	glDisableClientState(GL_VERTEX_ARRAY);

	glLineWidth(1.5);

	float const text_size = 0.15f;

	draw_arrow(l, 0, 0, 0, 0, 0, 0.1, 0.0, "left",   text_size);
	draw_arrow(0, 0, 0, r, 0, 0, 0.0, 0.1, "right",  text_size);
	draw_arrow(0, b, 0, 0, 0, 0, 0.1, 0.0, "bottom", text_size);
	draw_arrow(0, 0, 0, 0, t, 0, 0.0, 0.1, "top",    text_size);

	draw_arrow(r, 0, 0, r, 0, -n, 0.1, 0.1, "near", text_size);
	draw_arrow(l, 0, 0, l, 0, -n, 0.1, 0.1, "near", text_size);
	draw_arrow(0, t, 0, 0, t, -n, 0.1, 0.1, "near", text_size);
	draw_arrow(0, b, 0, 0, b, -n, 0.1, 0.1, "near", text_size);

	draw_arrow(0, f*t/n, 0, 0, f*t/n, -f, 0.1, 0.1, "far", text_size);
	draw_arrow(0, f*b/n, 0, 0, f*b/n, -f, 0.1, 0.1, "far", text_size);
	draw_arrow(f*l/n, 0, 0, f*l/n, 0, -f, 0.1, 0.1, "far", text_size);
	draw_arrow(f*r/n, 0, 0, f*r/n, 0, -f, 0.1, 0.1, "far", text_size);
}
Exemple #22
0
void dashboard_draw_func(handle_t obj)
{
    gui_widget_t *w = (gui_widget_t *) obj;

    gfx_set_color(COLOR_BLACK);
    gfx_fill_rectangle(w->left, w->top, w->width, w->height);

    if(gui_widget_get_state(w, STATE_FOCUSED))
        gfx_set_color(COLOR_YELLOW);
    else
        gfx_set_color(COLOR_DARK_YELLOW);

    gfx_draw_rectangle(w->left, w->top, w->width, w->height);

    gfx_set_color(COLOR_WHITE);
    gfx_set_font(&FONT_DIALOG_12);
    gfx_set_text_pos(w->left + 10, w->top + 10);
    gfx_outtext("Pressure:", 100);
    gfx_set_text_pos(w->left + 10, w->top + 90);
    gfx_outtext("Humidity:", 100);
    gfx_set_text_pos(w->left + 10, w->top + 170);
    gfx_outtext("Temperature:", 100);

    if(w->extra != NULL)
    {
        dashboard_data_t *data = (dashboard_data_t*) w->extra;
        char buf[16];
        int16_t trend;

        // Min & max

        gfx_set_text_pos(w->left + 10, w->top + 60);
        gfx_set_color(COLOR_CYAN);
        gfx_outtext("min: ", 10);
        if(data->pressure.min != 0x8000)
            tiny_sprintf(stringCache, "%d1 hPa", data->pressure.min);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MIN_P ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        gfx_set_color(COLOR_CYAN);
        gfx_outtext(", max: ", 10);
        if(data->pressure.max != 0x8000)
            tiny_sprintf(stringCache, "%d1 hPa", data->pressure.max);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MAX_P ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        
        gfx_set_text_pos(w->left + 10, w->top + 140);
        gfx_set_color(COLOR_MAGENTA);
        gfx_outtext("min: ", 10);
        if(data->humidity.min != 0x8000)
            tiny_sprintf(stringCache, "%d2 %%RH", data->humidity.min);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MIN_H ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        gfx_set_color(COLOR_MAGENTA);
        gfx_outtext(", max: ", 10);
        if(data->humidity.max != 0x8000)
            tiny_sprintf(stringCache, "%d2 %%RH", data->humidity.max);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MAX_H ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        
        gfx_set_text_pos(w->left + 10, w->top + 220);
        gfx_set_color(COLOR_YELLOW);
        gfx_outtext("min: ", 10);
        if(data->temperature.min != 0x8000)
            tiny_sprintf(stringCache, "%d2 *C", data->temperature.min);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MIN_T ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);
        gfx_set_color(COLOR_YELLOW);
        gfx_outtext(", max: ", 10);
        if(data->temperature.max != 0x8000)
            tiny_sprintf(stringCache, "%d2 *C", data->temperature.max);
        else
            tiny_sprintf(stringCache, "---");
        gfx_set_color(data->alarmMask & ALARM_MAX_T ? COLOR_RED : COLOR_WHITE);
        gfx_outtext_ram(stringCache, 25);

        // TREND

        trend = (data->pressure.trend - data->pressure.trendLast);
        if(trend < 2 && trend > -2)
            draw_minus(w->left + 170, w->top + 38);
        else
        {
            draw_arrow(w->left + 170, w->top + 23, (bool_t) (trend > 0));
            tiny_sprintf(buf, "%c%d1", trend > 0? '+' : ' ', trend);
            gfx_set_text_pos(w->left + 150, w->top + 43);
            gfx_outtext_ram(buf, 16);
        }

        trend = (data->humidity.trend - data->humidity .trendLast);
        if (trend < 5 && trend > -5)
            draw_minus(w->left + 170, w->top + 118);
        else
        {
            draw_arrow(w->left + 170, w->top + 103, (bool_t) (trend > 0));
            tiny_sprintf(buf, "%c%d2", trend > 0? '+' : ' ', trend);
            gfx_set_text_pos(w->left + 150, w->top + 123);
            gfx_outtext_ram(buf, 16);
        }

        trend = (data->temperature.trend - data->temperature.trendLast);
        if (trend < 2 && trend > -2)
            draw_minus(w->left + 170, w->top + 198);
        else
        {
            draw_arrow(w->left + 170, w->top + 183, (bool_t) (trend > 0));
            tiny_sprintf(buf, "%c%d2", trend > 0? '+' : ' ', trend);
            gfx_set_text_pos(w->left + 150, w->top + 203);
            gfx_outtext_ram(buf, 16);
        }

        // Big digits
        
        gfx_set_font(&FONT_ARIALBLACK_36);
        gfx_set_color(COLOR_WHITE);
    
        gfx_set_text_pos(w->left + 10, w->top + 18);
        tiny_sprintf(stringCache, "%d1", data->pressure.val);
        gfx_outtext_ram(stringCache, 10);

        gfx_set_text_pos(w->left + 10, w->top + 98);
        tiny_sprintf(stringCache, "%d2", data->humidity.val);
        gfx_outtext_ram(stringCache, 10);

        gfx_set_text_pos(w->left + 10, w->top + 178);
        tiny_sprintf(stringCache, "%d2", data->temperature.val);
        gfx_outtext_ram(stringCache, 10);
    }
}
Exemple #23
0
/*!
   \brief Draw line dirs
 */
int draw_line_dir(struct robject_list *list, int line)
{
    int narrows;
    int size;			/* arrow length in pixels */
    int limit;			/* segment length limit for drawing symbol (in pixels) */
    double dist, angle, pos;
    double e, n;
    int x0, y0, x1, y1;

    narrows = 0;
    size = 5;
    limit = 5;			/* 5px for line segment */

    dist = Vect_line_length(state.Points);
    G_debug(5, "  draw_line_dir() line=%d", line);
						  
    if (dist_in_px(dist) >= limit) {
	while (1) {
	    pos = (narrows + 1) * 8 * limit * region.map_res;

	    if (Vect_point_on_line(state.Points, pos,
				   &e, &n, NULL, NULL, NULL) < 1) {
		break;
	    }

	    en_to_xy(e, n, &x0, &y0);

	    if (Vect_point_on_line
		(state.Points, pos - 3 * size * region.map_res, &e, &n, NULL,
		 &angle, NULL) < 1) {
		break;
	    }

	    en_to_xy(e, n, &x1, &y1);

	    draw_arrow(x0, y0, x1, y1, angle, size, line, list);

	    if (narrows > 1e2)	/* low resolution, break */
		break;

	    narrows++;
	}

	/* draw at least one arrow in the middle of line */
	if (narrows < 1) {
	    dist /= 2.;
	    if (Vect_point_on_line(state.Points, dist,
				   &e, &n, NULL, NULL, NULL) > 0) {

		en_to_xy(e, n, &x0, &y0);

		if (Vect_point_on_line
		    (state.Points, dist - 3 * size * region.map_res, &e, &n,
		     NULL, &angle, NULL) > 0) {

		    en_to_xy(e, n, &x1, &y1);

		    draw_arrow(x0, y0, x1, y1, angle, size, line, list);
		}
	    }
	}
    }

    return narrows;
}
Exemple #24
0
int main(void)
{
   /* request autodetection */
   int gdriver = DETECT, gmode, errorcode,f=1,t=0;
   void *arrow;
   int x, y, maxx,maxy ;
   unsigned int size;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "");

   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }


   maxx = getmaxx();
   maxy = getmaxy();
   x = 0;
   y = getmaxy()/2;

  // setbkcolor(LIGHTGRAY);
   setcolor(YELLOW);

   /* draw the image to be grabbed */
   draw_arrow(x, y);

   /* calculate the size of the image */
   size = imagesize(x, y-az, x+(4*az), y+az);

   /* allocate memory to hold the image */
   arrow = malloc(size);
     /* grab the image */
   getimage(x, y-az, x+(4*az), y+az, arrow);

   /* repeat until a key is pressed */
  while(!kbhit())
  {	 /* erase old image */
	  putimage(x, y-az, arrow, XOR_PUT);

      x +=az;
      if (x >= maxx)
      {
	  x = 0;
      }

	  delay(100);
	  az++;
	  x++;
	  y++;
      /* plot new image */
      putimage(x, y-az, arrow, XOR_PUT);
       delay(100);


   }

   /* clean up */
   free(arrow);
   closegraph();
   return 0;
}
int title_screen(const char *commands[100], int *f, double noteinfo[2][1000], char output[1000]){

int xsize=1250;
int ysize=1000;
int xpos;
int ypos;
int height=400;
int width=(xsize-50)/16;
int i,j;
char input[20];
char initial[1000];
char c;
gfx_open(xsize, ysize, "Digital Piano");
quit_button();
draw_title(100);
draw_name(50);
draw_name2(50);
draw_button(295,600,70,310);
draw_button(645,600,70,310);
button_label(60);
button_label2(60);

while (1){

	c=gfx_wait();
	xpos=gfx_xpos();
	ypos=gfx_ypos();
	//user clicks the quit button
	if (xpos>=1110 && xpos<=1210 && ypos>=850 && ypos<=890){
		return 0;
	}

	//user clicks free play button
	if (xpos>=295 && xpos<=605 && ypos>=600 && ypos<=670){
		gfx_clear();
		piano_graphic(commands, f);

	}
	//user clicks load file button
	if (xpos>=645 && xpos<=955 && ypos>=600 && ypos<=670){
		terminal_message();
		printf("Please enter the name of the file, including the extension.\nThe file content should follow the same format as the examples in lab 8:\n");
		scanf("%s", input);
		//scans file name into input
		FILE *music=fopen(input, "r");
		if ((music=fopen(input, "r")) == NULL){
			//returns error if file not found
			puts("File could not be opened");
			return 0;
		}

		else{
			//scans the file into output
			for (j=0; j<1000; j++){
			fscanf(music, "%c", &output[j]);
			if (output[j]=='X'){
				break;
			}
			}
			
		}

		piano2(noteinfo, output);
		//fork to play sound while lighting up keys
		if (fork()){
			system("play sound.wav");
		}
		else{
		gfx_clear();
		draw_piano(width, height);
		draw_arrow(50, f);
		gfx_color(255,255,255);
		draw_box();
		octave_label(30);
		quit_button();
		gfx_flush();
		key_animation(noteinfo, f);
		return 0;
		}
	
	}

}

}
Exemple #26
0
int *plot_render_particles(double *x, double *rad, int *type, long N, double L, double *shade, int forces,
                           double cmx, double cmy, int docom, int *pbc, double *v, int doarrows){
    // focus on the part of scene where we draw nice
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, L, L, 0, 0, 1);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    // lets draw our viewport just in case its not square
    glBegin(GL_LINE_LOOP);
      glVertex2f(0, 0);
      glVertex2f(0, L);
      glVertex2f(L, L);
      glVertex2f(L, 0);
    glEnd();
    
    glDisable(GL_POINT_SMOOTH);
    glPointSize(1);

    #ifdef POINTS 
    glBegin(GL_POINTS);
    #else
    double t=0;
    #endif

    int i;
    float tx, ty, cr, cg, cb, ca;
    double c, rx;
    uint secs;

    #ifdef OPENMP
    //#pragma omp parallel for private(tx,ty, c, cr, cg, cb, ca, rx, t, secs)
    #endif
    for (i=0; i<N; i++){
        tx = (float)x[2*i+0];
        ty = (float)x[2*i+1];

        if (forces){
            c = fabs(shade[i]);
            if (c < 0) c = 0.0; 
            if (c > 1.0) c = 1.0;
            cr = cg = cb = c;
            ca = 1.0;
            if (type[i] == 1) {
                cr = 0.9;
                cg = 0.05;
                cb = 0.05;
            }
        } else {
            cr = 1.0; 
            cg = 1.0;
            cb = 1.0;
            ca = 1.0;
            if (type[i] == 1) {
                cr = 0.00; 
                cg = 0.00;
                cb = 0.00;
            }
        }
        
        #ifdef POINTS
        plot_set_draw_color(cr,cg,cb,ca);
        glVertex2f(tx, ty);
        #else
        rx = rad[i];
        secs = 15;
        plot_set_draw_color(cr,cg,cb,ca);
        glBegin(GL_POLYGON);
        for (t=0; t<2*pi; t+=2*pi/secs)
          glVertex2f(tx + rx*cos(t), ty + rx*sin(t));
        glEnd();
        plot_set_draw_color(0.0,0.0,0.0,1.0);
        glBegin(GL_LINE_LOOP);
        for (t=0; t<2*pi; t+=2*pi/secs)
          glVertex2f(tx + rx*cos(t), ty + rx*sin(t));
        glEnd();
        #endif
    }

    if (doarrows)
        for (i=0; i<N; i++)
            if (type[i] == 1) draw_arrow(x[2*i+0], x[2*i+1], v[2*i+0], v[2*i+1], forces);
    #ifdef OPENMP 
    //#pragma omp barrier
    #endif

    if (docom == 1){
        double rx = 2;
        int secs = 15;
        double t;
        glColor4f(1.0,1.0,1.0,1.0);
        glBegin(GL_POLYGON);
        for (t=0; t<2*pi; t+=2*pi/secs)
          glVertex2f(cmx + rx*cos(t), cmy + rx*sin(t));
        glEnd();
        glColor4f(0.0,0.0,0.0,1.0);
        glBegin(GL_LINE_LOOP);
        for (t=0; t<2*pi; t+=2*pi/secs)
          glVertex2f(cmx + rx*cos(t), cmy + rx*sin(t));
        glEnd();

        for (i=0; i<N; i++){
            if (type[i] == 1){
                double tx = x[2*i+0] - cmx;
                double ty = x[2*i+1] - cmy;
                
                if (pbc[0] && tx > L/2)  tx -= L;
                if (pbc[1] && ty > L/2)  ty -= L;
                if (pbc[0] && tx < -L/2) tx += L;
                if (pbc[1] && ty < -L/2) ty += L;
                glBegin(GL_LINE_LOOP);
                glVertex2f(x[2*i+0], x[2*i+1]);
                glVertex2f(x[2*i+0]-tx, x[2*i+1]-ty);
                glEnd();
            }
        }
    }
 
    #ifdef POINTS
    glEnd();
    #endif

    glutSwapBuffers();
    glutMainLoopEvent();

    return keys;
}