static void gr_draw_sunken_border( short x1, short y1, short x2, short y2 ) { const uint8_t cgrey = CGREY; const uint8_t cbright = CBRIGHT; Hline(x1-1, x2+1, y1-1, cgrey); Vline( y1-1, y2+1, x1-1, cgrey); Hline(x1-1, x2+1, y2+1, cbright); Vline( y1, y2+1, x2+1, cbright); }
void ui_draw_shad( short x1, short y1, short x2, short y2, short c1, short c2 ) { gr_setcolor( c1 ); Hline( x1+0, x2-1, y1+0 ); Vline( y1+1, y2+0, x1+0 ); gr_setcolor( c2 ); Hline( x1+1, x2, y2-0 ); Vline( y1+0, y2-1, x2-0 ); }
static int ligne(lua_State *L) { unsigned short n = lua_gettop(L); short int x,y,y1,x1,page,i,xx,dx,dy,err,sx,sy,e2; short int coul; x = (lua_toint(L, 1)-1); y = (lua_toint(L, 2)-1); x1 = (lua_toint(L, 3)-1); y1 = (lua_toint(L, 4)-1); if(n>=5) {page= lua_toint(L, 5);if(page<0 || page >5) page = 0;} //peut representer la couleur ou un numero de buffer else page = 0; dx = abs(x1-x), sx = x<x1 ? 1 : -1; dy = abs(y1-y), sy = y<y1 ? 1 : -1; if ( !NetB ) { if (n==6 || dx == 0 || dy == 0) { if (x>x1) {xx=x ; x=max(x1 ,0) ;x1= min(xx,127);} if (y>y1) {xx=y ; y=max (y1,0) ;y1= min (xx,63);} // donc y<=y1 et x<=x1 if (n == 6) { // rectangle coul = lua_toint(L,6); for( i=y ; i<=y1 ; i++){ Hline(x, x1 , i , coul); } if (page!=coul) { Hline(x,x1,y,page); Vline(x1,y,y1,page); Hline(x,x1,y1,page); Vline(x,y,y1,page); } } else if (dy==0) Hline(x,x1,y1,page); else Vline(x,y,y1,page); //dx == 0 return 0; } } err = (dx>dy ? dx : -dy)/2; for(;;){ if ((x == x&0x007F) && (y == y&0x003F)) // si on est dans les plages de l'écran (tester si pas de pb pour les valeurs négatives) { if(NetB) ML_pixel(x,y,1,VRAM[page]); else draw_write_pix(x,y,page); } if (x==x1 && y==y1) break; e2 = err; if (e2 >-dx) { err -= dy; x += sx; } if (e2 < dy) { err += dx; y += sy; } } if (NetB && page==0)ML_display_vram(VRAM[0]); return 0; }
void gr_draw_sunken_border( short x1, short y1, short x2, short y2 ) { gr_setcolor( CGREY ); Hline( x1-1, x2+1, y1-1); Vline( y1-1, y2+1, x1-1); gr_setcolor( CBRIGHT ); Hline( x1-1, x2+1, y2+1); Vline( y1, y2+1, x2+1); }
void ui_draw_line_in( short x1, short y1, short x2, short y2 ) { gr_setcolor( CGREY ); Hline( x1, x2, y1 ); Hline( x1, x2-1, y2-1 ); Vline( y1+1, y2-2, x1 ); Vline( y1+1, y2-2, x2-1 ); gr_setcolor( CBRIGHT ); Hline( x1+1, x2-1, y1+1 ); Hline( x1, x2, y2 ); Vline( y1+2, y2-2, x1+1 ); Vline( y1+1, y2-1, x2 ); }
void ui_draw_inputbox( UI_DIALOG *dlg, UI_GADGET_INPUTBOX * inputbox ) { int w, h, aw; #if 0 //ndef OGL if ((inputbox->status==1) || (inputbox->position != inputbox->oldposition)) #endif { gr_set_current_canvas( inputbox->canvas ); gr_setcolor( CBLACK ); gr_rect( 0, 0, inputbox->width-1, inputbox->height-1 ); gr_get_string_size(inputbox->text, &w, &h, &aw ); if (dlg->keyboard_focus_gadget == (UI_GADGET *)inputbox) { if (inputbox->first_time) { gr_set_fontcolor( CBLACK, -1 ); gr_setcolor( CRED ); gr_rect(2, 2, 2 + w, 2 + h); } else gr_set_fontcolor( CRED, -1 ); } else gr_set_fontcolor( CWHITE, -1 ); inputbox->status = 0; gr_string( 2, 2, inputbox->text ); //gr_setcolor( CBLACK ); //gr_rect( 2+w, 0, inputbox->width-1, inputbox->height-1 ); if (dlg->keyboard_focus_gadget == (UI_GADGET *)inputbox && !inputbox->first_time ) { gr_setcolor(CRED); Vline( 2,inputbox->height-3, 2+w+1 ); Vline( 2,inputbox->height-3, 2+w+2 ); } } }
void ui_draw_inputbox( UI_GADGET_INPUTBOX * inputbox ) { int w, h, aw; if ((inputbox->status==1) || (inputbox->position != inputbox->oldposition)) { ui_mouse_hide(); gr_set_current_canvas( inputbox->canvas ); if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)inputbox) { if (inputbox->first_time) gr_set_fontcolor( CBLACK, CRED ); else gr_set_fontcolor( CRED, CBLACK ); } else gr_set_fontcolor( CWHITE, CBLACK ); inputbox->status = 0; gr_string( 2, 2, inputbox->text ); gr_get_string_size(inputbox->text, &w, &h, &aw ); gr_setcolor( CBLACK ); gr_rect( 2+w, 0, inputbox->width-1, inputbox->height-1 ); if (CurWindow->keyboard_focus_gadget == (UI_GADGET *)inputbox && !inputbox->first_time ) { gr_setcolor(CRED); Vline( 2,inputbox->height-3, 2+w+1 ); Vline( 2,inputbox->height-3, 2+w+2 ); } ui_mouse_show(); } }
bool ON_Mesh::CollapseEdge( int topei ) { ON_Mesh& mesh = *this; ON__MESHEDGE me; memset(&me,0,sizeof(me)); const ON_MeshTopology& top = mesh.Topology(); const int F_count = mesh.m_F.Count(); const int V_count = mesh.m_V.Count(); const int topv_count = top.m_topv.Count(); //const int tope_count = top.m_tope.Count(); if ( topei < 0 || topei >= top.m_tope.Count() ) { return false; } const ON_MeshTopologyEdge& tope = top.m_tope[topei]; if ( tope.m_topf_count < 1 || tope.m_topvi[0] == tope.m_topvi[1] || tope.m_topvi[0] < 0 || tope.m_topvi[1] < 0 || tope.m_topvi[0] >= topv_count || tope.m_topvi[1] >= topv_count ) { return false; } const ON_MeshTopologyVertex& topv0 = top.m_topv[tope.m_topvi[0]]; const ON_MeshTopologyVertex& topv1 = top.m_topv[tope.m_topvi[1]]; if ( topv0.m_v_count < 1 || topv1.m_v_count < 1 ) { return false; } if ( topv0.m_vi[0] < 0 || topv0.m_vi[0] >= V_count ) { return false; } if ( topv1.m_vi[0] < 0 || topv1.m_vi[0] >= V_count ) { return false; } // create a ON__MESHEDGE for each face (usually one or two) that uses the edge ON__MESHEDGE* me_list = (ON__MESHEDGE*)alloca(tope.m_topf_count*sizeof(me_list[0])); int me_list_count = 0; int efi; for ( efi = 0; efi < tope.m_topf_count; efi++ ) { int fi = tope.m_topfi[efi]; if ( fi < 0 || fi >= F_count ) continue; const ON_MeshFace& f = mesh.m_F[fi]; if ( !f.IsValid(V_count) ) continue; me.vi1 = f.vi[3]; me.topvi1 = top.m_topv_map[me.vi1]; int fvi; for ( fvi = 0; fvi < 4; fvi++ ) { me.vi0 = me.vi1; me.topvi0 = me.topvi1; me.vi1 = f.vi[fvi]; me.topvi1 = top.m_topv_map[me.vi1]; if ( me.vi0 != me.vi1 ) { if ( (me.topvi0 == tope.m_topvi[0] && me.topvi1 == tope.m_topvi[1]) || (me.topvi0 == tope.m_topvi[1] && me.topvi1 == tope.m_topvi[0]) ) { if ( me.vi0 > me.vi1 ) { int i = me.vi0; me.vi0 = me.vi1; me.vi1 = i; i = me.topvi0; me.topvi0 = me.topvi1; me.topvi1 = i; } me_list[me_list_count++] = me; break; } } } } if (me_list_count<1) { return false; } // Sort me_list[] so edges using same vertices are adjacent // to each other in the list. This is needed so that non-manifold // crease edges will be properly collapsed. ON_qsort(me_list,me_list_count,sizeof(me_list[0]),(QSORTCMPFUNC)CompareMESHEDGE); // create new vertex or vertices that edge will be // collapsed to. mesh.m_C.Destroy(); mesh.m_K.Destroy(); int mei; bool bHasVertexNormals = mesh.HasVertexNormals(); bool bHasTextureCoordinates = mesh.HasTextureCoordinates(); bool bHasFaceNormals = mesh.HasFaceNormals(); if ( topv0.m_v_count == 1 || topv1.m_v_count == 1 ) { // a single new vertex ON_Line Vline(ON_origin,ON_origin); ON_Line Tline(ON_origin,ON_origin); ON_3dVector N0(0,0,0); ON_3dVector N1(0,0,0); ON_3dPoint P; int vi, tvi, cnt; int newvi = topv0.m_vi[0]; cnt = 0; for ( tvi = 0; tvi < topv0.m_v_count; tvi++ ) { vi = topv0.m_vi[tvi]; if ( vi < 0 || vi > V_count ) continue; if ( vi < newvi ) newvi = vi; cnt++; P = mesh.m_V[vi]; Vline.from += P; if ( bHasVertexNormals ) { N0 += ON_3dVector(mesh.m_N[vi]); } if ( bHasTextureCoordinates ) { P = mesh.m_T[vi]; Tline.from += P; } } if (cnt > 1) { double s = 1.0/((double)cnt); Vline.from.x *= s; Vline.from.y *= s; Vline.from.z *= s; Tline.from.x *= s; Tline.from.y *= s; Tline.from.z *= s; N0 = s*N0; } cnt = 0; for ( tvi = 0; tvi < topv1.m_v_count; tvi++ ) { vi = topv1.m_vi[tvi]; if ( vi < 0 || vi > V_count ) continue; if ( vi < newvi ) newvi = vi; cnt++; P = mesh.m_V[vi]; Vline.to += P; if ( bHasVertexNormals ) { N1 += ON_3dVector(mesh.m_N[vi]); } if ( bHasTextureCoordinates ) { P = mesh.m_T[vi]; Tline.to += P; } } if (cnt > 1) { double s = 1.0/((double)cnt); Vline.to.x *= s; Vline.to.y *= s; Vline.to.z *= s; Tline.to.x *= s; Tline.to.y *= s; Tline.to.z *= s; N1 = s*N1; } ON_3fPoint newV(Vline.PointAt(0.5)); ON_3fVector newN; ON_2fPoint newT; if ( bHasVertexNormals ) { N0.Unitize(); N1.Unitize(); ON_3dVector N = N0+N1; if ( !N.Unitize() ) { N = (topv0.m_v_count == 1) ? mesh.m_N[topv0.m_vi[0]] :mesh.m_N[topv1.m_vi[0]]; } newN = N; } if ( bHasTextureCoordinates ) { newT = Tline.PointAt(0.5); } for ( mei = 0; mei < me_list_count; mei++ ) { me_list[mei].newvi = newvi; me_list[mei].newV = newV; me_list[mei].newN = newN; me_list[mei].newT = newT; } } else { // collapsing a "crease" edge - attempt to preserve // the crease. memset(&me,0,sizeof(me)); me.vi0 = -1; me.vi1 = -1; for ( mei = 0; mei < me_list_count; mei++ ) { if ( 0 == mei && CompareMESHEDGE(&me,me_list+mei) ) { // cook up new vertex me_list[mei].newvi = mesh.m_V.Count(); me = me_list[mei]; ON_Line line; line.from = mesh.m_V[me.vi0]; line.to = mesh.m_V[me.vi1]; me.newV = line.PointAt(0.5); if ( bHasVertexNormals ) { ON_3dVector N0(mesh.m_N[me.vi0]); ON_3dVector N1(mesh.m_N[me.vi1]); ON_3dVector N = N0 + N1; if ( !N.Unitize() ) N = N0; me.newN = N; } if ( bHasTextureCoordinates ) { line.from = mesh.m_T[me.vi0]; line.to = mesh.m_T[me.vi1]; me.newT = line.PointAt(0.5); } me.newvi = (me.vi0 < me.vi1) ? me.vi0 : me.vi1; } else { me_list[mei].newvi = me.newvi; me_list[mei].newV = me.newV; me_list[mei].newN = me.newN; me_list[mei].newT = me.newT; } } } // We are done averaging old mesh values. // Change values in mesh m_V[], m_N[] and m_T[] arrays. for ( mei = 0; mei < me_list_count; mei++ ) { mesh.m_V[me_list[mei].vi0] = me_list[mei].newV; mesh.m_V[me_list[mei].vi1] = me_list[mei].newV; if ( bHasVertexNormals ) { mesh.m_N[me_list[mei].vi0] = me_list[mei].newN; mesh.m_N[me_list[mei].vi1] = me_list[mei].newN; } if ( bHasTextureCoordinates ) { mesh.m_T[me_list[mei].vi0] = me_list[mei].newT; mesh.m_T[me_list[mei].vi1] = me_list[mei].newT; } } // make a map of old to new int old2new_map_count = 0; ON__NEWVI* old2new_map = (ON__NEWVI*)alloca(2*me_list_count*sizeof(old2new_map[0])); for ( mei = 0; mei < me_list_count; mei++ ) { old2new_map[old2new_map_count].oldvi = me_list[mei].vi0; old2new_map[old2new_map_count].newvi = me_list[mei].newvi; old2new_map_count++; old2new_map[old2new_map_count].oldvi = me_list[mei].vi1; old2new_map[old2new_map_count].newvi = me_list[mei].newvi; old2new_map_count++; } // sort old2new_map[] so we can use a fast bsearch() call // to update faces. ON_qsort(old2new_map,old2new_map_count,sizeof(old2new_map[0]),(QSORTCMPFUNC)CompareNEWVI); // count faces that use the vertices that are being changed int bad_fi_count = 0; int topv_end, vei, fi, fvi23, fvi; ON__NEWVI nvi; for ( topv_end = 0; topv_end < 2; topv_end++ ) { const ON_MeshTopologyVertex& topv = (topv_end) ? topv1 : topv0; for ( vei = 0; vei < topv.m_tope_count; vei++ ) { topei = topv.m_topei[vei]; if ( topei < 0 && topei >= top.m_tope.Count() ) continue; bad_fi_count += top.m_tope[topei].m_topf_count; } } int* bad_fi = (int*)alloca(bad_fi_count*sizeof(*bad_fi)); bad_fi_count = 0; // Go through all the faces that use the vertices at the // ends of the edge and update the vi[] values to use the // new vertices. for ( topv_end = 0; topv_end < 2; topv_end++ ) { const ON_MeshTopologyVertex& topv = (topv_end) ? topv1 : topv0; for ( vei = 0; vei < topv.m_tope_count; vei++ ) { topei = topv.m_topei[vei]; if ( topei < 0 && topei >= top.m_tope.Count() ) continue; const ON_MeshTopologyEdge& e = top.m_tope[topei]; for ( efi = 0; efi < e.m_topf_count; efi++ ) { fi = e.m_topfi[efi]; if ( fi < 0 || fi >= F_count ) continue; bool bChangedFace = false; ON_MeshFace& f = mesh.m_F[fi]; for ( fvi = 0; fvi < 4; fvi++ ) { nvi.oldvi = f.vi[fvi]; ON__NEWVI* p = (ON__NEWVI*)bsearch(&nvi,old2new_map,old2new_map_count,sizeof(old2new_map[0]),(QSORTCMPFUNC)CompareNEWVI); if ( 0 != p && p->oldvi != p->newvi) { f.vi[fvi] = p->newvi; bChangedFace = true; } } if ( bChangedFace ) { if ( !f.IsValid(V_count) ) { if ( f.vi[3] == f.vi[0] ) { f.vi[0] = f.vi[1]; f.vi[1] = f.vi[2]; f.vi[2] = f.vi[3]; } else if ( f.vi[0] == f.vi[1] ) { fvi23 = f.vi[0]; f.vi[0] = f.vi[2]; f.vi[1] = f.vi[3]; f.vi[2] = fvi23; f.vi[3] = fvi23; } else if ( f.vi[1] == f.vi[2] ) { fvi23 = f.vi[1]; f.vi[1] = f.vi[0]; f.vi[0] = f.vi[3]; f.vi[2] = fvi23; f.vi[3] = fvi23; } if ( f.vi[0] == f.vi[1] || f.vi[1] == f.vi[2] || f.vi[2] == f.vi[0] || f.vi[2] != f.vi[3] ) { bad_fi[bad_fi_count++] = fi; } } if ( bHasFaceNormals ) { // invalid faces are removed below ON_3fVector a, b, n; a = mesh.m_V[f.vi[2]] - mesh.m_V[f.vi[0]]; b = mesh.m_V[f.vi[3]] - mesh.m_V[f.vi[1]]; n = ON_CrossProduct( a, b ); n.Unitize(); mesh.m_FN[fi] = n; } } } } } if ( bad_fi_count > 0 ) { // remove collapsed faces ON_qsort(bad_fi,bad_fi_count,sizeof(bad_fi[0]),CompareInt); int bfi = 1; int dest_fi = bad_fi[0]; for ( fi = dest_fi+1; fi < F_count && bfi < bad_fi_count; fi++ ) { if ( fi == bad_fi[bfi] ) { bfi++; } else { mesh.m_F[dest_fi++] = mesh.m_F[fi]; } } while (fi<F_count) { mesh.m_F[dest_fi++] = mesh.m_F[fi++]; } mesh.m_F.SetCount(dest_fi); if ( bHasFaceNormals ) { bfi = 1; dest_fi = bad_fi[0]; for ( fi = dest_fi+1; fi < F_count && bfi < bad_fi_count; fi++ ) { if ( fi == bad_fi[bfi] ) { bfi++; } else { mesh.m_FN[dest_fi++] = mesh.m_FN[fi]; } } while (fi<F_count) { mesh.m_FN[dest_fi++] = mesh.m_FN[fi++]; } mesh.m_FN.SetCount(dest_fi); } } mesh.Compact(); mesh.DestroyTopology(); mesh.DestroyPartition(); return true; }
void Xbar(int x,int y,int lx,int ly,char c){ Hline(x,y,x+lx-1,c); Hline(x,y+ly-1,x+lx-1,c); Vline(x,y,y+ly-1,c); Vline(x+lx-1,y,y+ly-1,c); };