示例#1
0
void TCuePosition::Outline(BRect outline)
{
	// Use the rect for the four corners
	Corner1(outline.LeftTop());
	Corner2(outline.RightTop());
	Corner3(outline.RightBottom());
	Corner4(outline.LeftBottom());

	// Set the registration in the center
	BPoint center(outline.left + outline.Width() / 2, outline.top +
			outline.Height() / 2);
	Registration(center);
}
//Cambio***************
static int filtro_gestos_buscar_limites(lua_State *L)
{
 dato_t *in = (filtro_gestos_in_imagen_t *)lua_touserdata(L, 1);
 int op = luaL_checkint(L, 2);
 special_colour_t *sc = (special_colour_t *)lua_touserdata(L, 3);
 bounds_t* out = (bounds_t*)malloc(sizeof(bounds_t));
 coord_t c1= Corner1(in,sc);
 coord_t c2= Corner2(in,sc);
 coord_t c3= Corner3(in,sc);
 coord_t c4= Corner4(in,sc);
 int b, a, d, c;
double divis,divis2;
 double angulo, angulo2;
 int grados1, grados2;
 if(op){
   Identify(in,out,c1);
   Identify(in,out,c2);
   Identify(in,out,c3);
   Identify(in,out,c4);
 }
 else Identify2(out,c1,c2,c3,c4);
 //Cambio********************************+
 b= out->ii.y-out->id.y;
  a= out->id.x-out->ii.x;
  d= out->ii.y-out->si.y;
  c= out->ii.x-out->si.x;
 
 
 // Tenías esto, el compilador da un warning
 // se suele usar sólo para asignaciones como te lo he puesto
 // Carlos
 // (a==0)?divis=0:divis=(double)b/a;
 //(c==0)?divis2=0:divis2=(double)d/c;
 // hasta aquí
 divis = (a == 0) ? 0 : (double)b / a;
 divis2 = (c == 0) ? 0 : (double)d / c;
 // esto de antes es lo nuevo, así no se queja
  angulo= atan(divis);
  angulo2= atan(divis2);
 out->grados= (angulo*180)/M_PI;
  grados1= abs(out->grados);
  grados2= abs((angulo2*180)/M_PI);
 /*lua_pushlightuserdata(L, grados1+grados2>80 && grados1+grados2<100 ? 
   out : 0);*/
 lua_pushlightuserdata(L, out);
 ///*if((*/grados1+grados2>80 && grados1+grados2<100;/*) || !op)*/
 return 1;
// else return 0;
}
//Cambio********************
static int filtro_gestos_on_border(lua_State *L)
{
 dato_t *in = (filtro_gestos_in_imagen_t *)lua_touserdata(L, 1);
 special_colour_t *sc = (special_colour_t *)lua_touserdata(L, 2);
 //bounds_t* out = (bounds_t*)malloc(sizeof(bounds_t));
 bounds_t out;
 coord_t c1= Corner1(in,sc);
 coord_t c2= Corner2(in,sc);
 coord_t c3= Corner3(in,sc);
 coord_t c4= Corner4(in,sc);
 Identify2(&out,c1,c2,c3,c4);
 if(out.ii.y>in->m_alto-BORDER || out.si.y<BORDER ||
    out.ii.x<BORDER || out.id.x>in->m_ancho-BORDER){
   //free(out);   
   //   return 1;
   lua_pushboolean(L, 1);
 }
 else{
   //free(out);
   //return 0;
   lua_pushboolean(L, 0);
 }
 return 1;
}