Ejemplo n.º 1
0
static void translate(int bnum, void (*drawscreen) (void)) {
 float xstep, ystep;

 xstep = (xright - xleft)/2.;
 ystep = (ybot - ytop)/2.;
 switch (bnum) {
 case 0:  ytop -= ystep;  /* up arrow */
          ybot -= ystep;
          break;
 case 1:  xleft -= xstep; /* left arrow */
          xright -= xstep; 
          break;
 case 2:  xleft += xstep;  /* right arrow */
          xright += xstep;
          break;
 case 3:  ytop += ystep;   /* down arrow */
          ybot += ystep;   
          break;
 default: printf("Graphics Error:  Unknown translation button.\n");
          printf("Got a button number of %d in routine translate.\n",
              bnum);
 }
 update_transform();         
 drawscreen();
}
Ejemplo n.º 2
0
/**
 * \brief Set font transformation matrix and shift vector
 **/
void ass_font_set_transform(ass_font_t* font, double scale_x, double scale_y, FT_Vector* v)
{
	font->scale_x = scale_x;
	font->scale_y = scale_y;
	font->v.x = v->x;
	font->v.y = v->y;
	update_transform(font);
}
Ejemplo n.º 3
0
void Polygon::setScale(glm::vec3 scale)
{
	if (scale != m_scale)
	{
		m_scale = scale;
		update_transform();
	}
}
Ejemplo n.º 4
0
void Polygon::setRot(glm::mat4 rot)
{
	if (rot != m_rot)
	{
		m_rot = rot;
		update_transform();
	}
}
Ejemplo n.º 5
0
void Polygon::setPos(glm::vec3 pos)
{
	if (pos != m_pos)
	{
		m_pos = pos;
		update_transform();
	}
}
Ejemplo n.º 6
0
void init_world (float x1, float y1, float x2, float y2) {

 xleft = x1;
 xright = x2;
 ytop = y1;
 ybot = y2;
 if (disp_type == SCREEN) {
    update_transform();
 }
 else {
    update_ps_transform();
 }
}
Ejemplo n.º 7
0
void close_postscript (void) {

/* Properly ends postscript output and redirects output to screen. */

 fprintf(ps,"showpage\n");
 fprintf(ps,"\n%%%%Trailer\n");
 fclose (ps);
 disp_type = SCREEN;
 update_transform();   /* Ensure screen world reflects any changes      *
                        * made while printing.                          */

/* Need to make sure that we really set up the graphics context --  *
 * don't want the change requested to match the current setting and *
 * do nothing -> force the changes.                                 */

 force_setcolor (currentcolor);
 force_setlinestyle (currentlinestyle);
 force_setlinewidth (currentlinewidth);
 force_setfontsize (currentfontsize); 
}
Ejemplo n.º 8
0
static void zoom(int bnum, void (*drawscreen) (void)) {
/* Zooms in or out by a factor of 1.666. */

 float xdiff, ydiff;

 xdiff = xright - xleft; 
 ydiff = ybot - ytop;
 if (strcmp(button[bnum].text,"Zoom In") == 0) {
    xleft += xdiff/5.;
    xright -= xdiff/5.;
    ytop += ydiff/5.;
    ybot -= ydiff/5.;
 }
 else {
    xleft -= xdiff/3.;
    xright += xdiff/3.;
    ytop -= ydiff/3.;
    ybot += ydiff/3.;
 }
 update_transform ();
 drawscreen();
}
Ejemplo n.º 9
0
static void update_win (int x[2], int y[2], void (*drawscreen)(void)) {
 float x1, x2, y1, y2;
 
 x[0] = min(x[0],top_width-MWIDTH);  /* Can't go under menu */
 x[1] = min(x[1],top_width-MWIDTH);
 y[0] = min(y[0],top_height-T_AREA_HEIGHT); /* Can't go under text area */
 y[1] = min(y[1],top_height-T_AREA_HEIGHT);

 if ((x[0] == x[1]) || (y[0] == y[1])) {
    printf("Illegal (zero area) window.  Window unchanged.\n");
    return;
 }
 x1 = XTOWORLD(min(x[0],x[1]));
 x2 = XTOWORLD(max(x[0],x[1]));
 y1 = YTOWORLD(min(y[0],y[1]));
 y2 = YTOWORLD(max(y[0],y[1]));
 xleft = x1;
 xright = x2;
 ytop = y1;
 ybot = y2;
 update_transform();
 drawscreen();
}
Ejemplo n.º 10
0
/**
 * \brief Select a face with the given charcode and add it to ass_font_t
 * \return index of the new face in font->faces, -1 if failed
 */
static int add_face(void* fc_priv, ass_font_t* font, uint32_t ch)
{
	char* path;
	int index;
	FT_Face face;
	int error;
	int mem_idx;
	
	if (font->n_faces == ASS_FONT_MAX_FACES)
		return -1;
	
	path = fontconfig_select(fc_priv, font->desc.family, font->desc.bold,
					      font->desc.italic, &index, ch);

	mem_idx = find_font(font->library, path);
	if (mem_idx >= 0) {
		error = FT_New_Memory_Face(font->ftlibrary, (unsigned char*)font->library->fontdata[mem_idx].data,
					   font->library->fontdata[mem_idx].size, 0, &face);
		if (error) {
			mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorOpeningMemoryFont, path);
			return -1;
		}
	} else {
		error = FT_New_Face(font->ftlibrary, path, index, &face);
		if (error) {
			mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorOpeningFont, path, index);
			return -1;
		}
	}
	charmap_magic(face);
	buggy_font_workaround(face);
	
	font->faces[font->n_faces++] = face;
	update_transform(font);
	face_set_size(face, font->size);
	return font->n_faces - 1;
}
Ejemplo n.º 11
0
Archivo: bind.c Proyecto: ccxvii/mio
static int ffi_update_transform(lua_State *L)
{
	struct transform *tra = luaL_checkudata(L, 1, "mio.transform");
	update_transform(tra);
	return 0;
}
Ejemplo n.º 12
0
void event_loop (void (*act_on_button) (float x, float y), 
    void (*drawscreen) (void)) {

/* The program's main event loop.  Must be passed a user routine        *
 * drawscreen which redraws the screen.  It handles all window resizing *
 * zooming etc. itself.  If the user clicks a button in the graphics    *
 * (toplevel) area, the act_on_button routine passed in is called.      */

 XEvent report;
 int bnum;
 float x, y;

#define OFF 1
#define ON 0

 turn_on_off (ON);
 while (1) {
    XNextEvent (display, &report);
    switch (report.type) {  
    case Expose:
#ifdef VERBOSE 
       printf("Got an expose event.\n");
       printf("Count is: %d.\n",report.xexpose.count);
       printf("Window ID is: %d.\n",report.xexpose.window);
#endif
       if (report.xexpose.count != 0)
           break;
       if (report.xexpose.window == menu)
          drawmenu(); 
       else if (report.xexpose.window == toplevel)
          drawscreen();
       else if (report.xexpose.window == textarea)
          draw_message();
       break;
    case ConfigureNotify:
       top_width = report.xconfigure.width;
       top_height = report.xconfigure.height;
       update_transform();
#ifdef VERBOSE 
       printf("Got a ConfigureNotify.\n");
       printf("New width: %d  New height: %d.\n",top_width,top_height);
#endif
       break; 
    case ButtonPress:
#ifdef VERBOSE 
       printf("Got a buttonpress.\n");
       printf("Window ID is: %d.\n",report.xbutton.window);
#endif
       if (report.xbutton.window == toplevel) {
          x = XTOWORLD(report.xbutton.x);
          y = YTOWORLD(report.xbutton.y); 
          act_on_button (x, y);
       } 
       else {  /* A menu button was pressed. */
          bnum = which_button(report.xbutton.window);
#ifdef VERBOSE 
       printf("Button number is %d\n",bnum);
#endif
          button[bnum].ispressed = 1;
          drawbut(bnum);
          XFlush(display);  /* Flash the button */
          button[bnum].fcn(bnum, drawscreen);
          button[bnum].ispressed = 0;
          drawbut(bnum);
          if (button[bnum].fcn == proceed) {
             turn_on_off(OFF);
             flushinput ();
             return;  /* Rather clumsy way of returning *
                       * control to the simulator       */
          }
       }
       break;
    }
 }
}
Ejemplo n.º 13
0
static void adjustwin (int bnum, void (*drawscreen) (void)) {  
/* The window button was pressed.  Let the user click on the two *
 * diagonally opposed corners, and zoom in on this area.         */

 XEvent report;
 int corner, xold, yold, x[2], y[2];

 corner = 0;
 xold = -1;
 yold = -1;    /* Don't need to init yold, but stops compiler warning. */
 
 while (corner<2) {
    XNextEvent (display, &report);
    switch (report.type) {
    case Expose:
#ifdef VERBOSE 
       printf("Got an expose event.\n");
       printf("Count is: %d.\n",report.xexpose.count);
       printf("Window ID is: %d.\n",report.xexpose.window);
#endif
       if (report.xexpose.count != 0)
           break;
       if (report.xexpose.window == menu)
          drawmenu(); 
       else if (report.xexpose.window == toplevel) {
          drawscreen();
          xold = -1;   /* No rubber band on screen */
       }
       else if (report.xexpose.window == textarea)
          draw_message();
       break;
    case ConfigureNotify:
       top_width = report.xconfigure.width;
       top_height = report.xconfigure.height;
       update_transform();
#ifdef VERBOSE 
       printf("Got a ConfigureNotify.\n");
       printf("New width: %d  New height: %d.\n",top_width,top_height);
#endif
       break;
    case ButtonPress:
#ifdef VERBOSE 
       printf("Got a buttonpress.\n");
       printf("Window ID is: %d.\n",report.xbutton.window);
       printf("Location (%d, %d).\n", report.xbutton.x,
          report.xbutton.y);
#endif
       if (report.xbutton.window != toplevel) break;
       x[corner] = report.xbutton.x;
       y[corner] = report.xbutton.y; 
       if (corner == 0) {
       XSelectInput (display, toplevel, ExposureMask | 
         StructureNotifyMask | ButtonPressMask | PointerMotionMask);
       }
       else {
          update_win(x,y,drawscreen);
       }
       corner++;
       break;
    case MotionNotify:
#ifdef VERBOSE 
       printf("Got a MotionNotify Event.\n");
       printf("x: %d    y: %d\n",report.xmotion.x,report.xmotion.y);
#endif
       if (xold >= 0) {  /* xold set -ve before we draw first box */
          XDrawRectangle(display,toplevel,gcxor,min(x[0],xold),
             min(y[0],yold),abs(x[0]-xold),abs(y[0]-yold));
       }
       /* Don't allow user to window under menu region */
       xold = min(report.xmotion.x,top_width-1-MWIDTH); 
       yold = report.xmotion.y;
       XDrawRectangle(display,toplevel,gcxor,min(x[0],xold),
          min(y[0],yold),abs(x[0]-xold),abs(y[0]-yold));
       break;
    }
 }
 XSelectInput (display, toplevel, ExposureMask | StructureNotifyMask
                | ButtonPressMask); 
}