Exemplo n.º 1
0
Zumbi::Zumbi(){
    life = 100;
    label(LABEL_ZUMBI);
    load("media/models/Knight/knight.md2");
    changeAnimation(Animation::WALK);
    graphic().setAnimationDelay(Animation::WALK,8);
    graphic().setAnimationDelay(Animation::TAUNT02,3);
    graphic().setAnimationDelay(Animation::HIT01,6);
    graphic().setAnimationDelay(Animation::DIE01,6);
    changeBoundingVolume(Solid::OBOX);
    animatedVolume();
    inactiveBody();
    visible(false);
}
Exemplo n.º 2
0
bool ScreenCapture::Capture(HWND hWnd, Bitmap** bitmapRet)
{
    HDC desktop_dc = GetDC(nullptr);
    RECT rc = {0};
    GetWindowRect(hWnd, &rc);
    Bitmap* bitmap = new Bitmap(rc.right -rc.left, rc.bottom - rc.top);
    RECT window_rect = { };
    GetWindowRect(hWnd, &window_rect);
    bool success = false;
    do
    {
        Graphics graphic(bitmap); 
        HDC graphic_hdc = graphic.GetHDC();
        success = !!BitBlt(
            graphic_hdc, 0, 0, 
            rc.right -rc.left, rc.bottom - rc.top, 
            desktop_dc, 0, 0, SRCCOPY);
        graphic.ReleaseHDC(graphic_hdc);
    } while (false);
    ReleaseDC(nullptr, desktop_dc);
    *bitmapRet = bitmap->Clone(window_rect.left, window_rect.top, 
        window_rect.right - window_rect.left, 
        window_rect.bottom - window_rect.top, PixelFormat32bppARGB);
    delete bitmap;
    return success;
}
Exemplo n.º 3
0
void CairoBox::draw(void) 
  {
  // using fltk functions, set up white background with thin black frame
  fl_push_no_clip();            /* remove any clipping region set by the expose events... */
  fl_push_clip(x(), y(), w(), h());
  fl_color(FL_WHITE);
  fl_rectf(x(), y(), w(), h());
  fl_color(FL_BLACK);
  fl_rect(x(), y(), w(), h());

  // set up cairo structures
  surface = set_surface(w(), h());
  cr      = cairo_create(surface);
  /* All Cairo co-ordinates are shifted by 0.5 pixels to correct anti-aliasing */
  cairo_translate(cr, 0.5, 0.5);
  cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); // set drawing color to black
  cairo_new_path(cr);

  // virtual function defined in driver program
  graphic(cr, x(), y(), w(), h());

  // release the cairo context
  cairo_destroy(cr);
  cairo_surface_destroy(surface);
//  cr = NULL;

  // remove clip regions
  fl_pop_clip();                          // local clip region
  fl_pop_clip();                          // "no_clip" region
  }
Exemplo n.º 4
0
void Picture::uncacheChildren () {
    register UList* i;
    Graphic* subgr;

    for (i = _kids->First(); i != _kids->End(); i = i->Next()) {
	subgr = graphic(i);
	uncacheExtentGraphic(subgr);
	uncacheChildrenGraphic(subgr);
    }
}
Exemplo n.º 5
0
info_base* olias_server::get_infobase(const char *locator_string, enum TestSelector sel)
{

   if ( locator_string == 0 )
      return 0;


   info_base* ib = 0;

   int ind = infolibptr -> first();

   while ( ind ) {

      ib =  (*infolibptr)(ind);

      if (ib==0)
         throw(stringException("null info_base ptr"));

      try { // since an infobase may not have any graphics, we catch
            // any exceptions there and try next infobase.

         switch (sel) {
          case LOC:
   	   {
            locator_smart_ptr loc(ib, locator_string);
   
//fprintf(stderr, "inside-loc-string=%s\n", loc.inside_node_locator_str());
//fprintf(stderr, "loc-string=%s\n", locator_string);
            if ( strcmp( loc.inside_node_locator_str(), locator_string) == 0 ) {
               return ib;
            }
   
           }
          case GRA:
   	   {
            graphic_smart_ptr graphic(ib, locator_string);
   
            if ( strcmp( graphic.locator(), locator_string) == 0 ) {
               return ib;
            }
           }
         }
      }

      catch (mmdbException &,e)
      {
      } end_try;


      infolibptr -> next(ind);
   }

   return 0;
}
Exemplo n.º 6
0
void Picture::Remove (Iterator& i) {
    UList* doomed = Elem(i);
    Graphic* g = graphic(doomed);

    Next(i);
    unsetParent(g);
    _kids->Remove(doomed);
    delete doomed;
    uncacheExtent();
    uncacheParents();
}
Exemplo n.º 7
0
Picture::~Picture () {
    while (!_kids->IsEmpty()) {
	UList* cur = _kids->First();
	_kids->Remove(cur);
        Graphic* g = graphic(cur);
	delete g;
	delete cur;
    }
    delete _kids;
    uncacheExtent();
}
Exemplo n.º 8
0
QPixmap HockeyGame::getFaceoffCompPreview(int awayWins, int homeWins)
{
    QList<QString> stats;
    stats.append(QString::number(awayWins));
    stats.append(QString::number(homeWins));
    prepareSameStatComp(stats, "FACEOFF WINS", false);
    QPixmap graphic(comparisonPreview.getWidth(), comparisonPreview.getHeight());
    graphic.fill(QColor(0,0,0,0));
    QPainter painter(&graphic);
    comparisonPreview.paintPreview(&painter);
    return graphic.scaled(comparisonPreview.getWidth()/2, comparisonPreview.getHeight()/2);
}
/*------------------------------------------------------------------------------
| DrawingArea::DrawingArea                                                     |
|                                                                              |
|                                                                              |
------------------------------------------------------------------------------*/
DrawingArea::~DrawingArea( )
{
  // Delete all the graphic objects in the drawing canvas.
  IGList::Cursor graphicsCursor( *graphicList() );
  for ( graphicsCursor.setToFirst();
        graphicsCursor.isValid();
        graphicsCursor.setToNext() )
  {
    IGraphic* graphic(&(graphicList()->graphicAt(graphicsCursor)));
    delete graphic;
  } /* endfor */
  delete graphicList();
}
FTL::FileFindResultHandle CLotteryMgr::OnFindFile(LPCTSTR pszFilePath, const WIN32_FIND_DATA& findData, LPVOID pParam)
{
    HRESULT hr = E_FAIL;
    BOOL    bRet = FALSE;
    Gdiplus::Status sts = Gdiplus::Ok;

    if (ftwtContinue != m_threadInit.GetThreadWaitType(INFINITE))
    {
         return rhStop;
    }

    if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
    {
        //find result file
        FTLTRACE(TEXT("OnFindFile: %s\n"), pszFilePath);

        CImage img;
        COM_VERIFY(img.Load(pszFilePath));
        if (SUCCEEDED(hr))
        {
            LotteryInfoPtr pLotteryInfo(new LotteryInfo(pszFilePath, FALSE));
            CRect rcThumbnail(0, 0, m_szThumbnail.cx, m_szThumbnail.cy);
            CSize szImage(img.GetWidth(), img.GetHeight());

            CRect rcDrawTarget = m_pCalcRect->GetFitRect(rcThumbnail, szImage);
            if (rcDrawTarget.bottom <= rcDrawTarget.top)
            {
                rcDrawTarget.bottom = rcDrawTarget.top + 1;
            }
            if (rcDrawTarget.right <= rcDrawTarget.left)
            {
                rcDrawTarget.right = rcDrawTarget.left + 1;
            }

            API_VERIFY(pLotteryInfo->imgThumbnail.Create(rcDrawTarget.Width(), rcDrawTarget.Height(), 32, CImage::createAlphaChannel));
            if (bRet)
            {
                CImageDC dc(pLotteryInfo->imgThumbnail);
                Gdiplus::Bitmap bmp((HBITMAP)img, NULL);
                Gdiplus::Graphics graphic(dc);
                GDIPLUS_VERIFY(graphic.DrawImage(&bmp, 0, 0, rcDrawTarget.Width(), rcDrawTarget.Height()));

                SendMessage(m_hWndControl, UM_ADD_LOTTERY_INFO, (WPARAM)pLotteryInfo.get(), NULL);

                m_allLotteryInfos.push_back(pLotteryInfo);
            }
        }
    }
    
    return rhContinue;
}
Exemplo n.º 11
0
void main()
{
    int gd = DETECT,gm,i, ch, cch;
    conj* A=iconj();
    conj* B=iconj();
    A=cconj(A);
    B=A;
    clrscr();
    do
    {
    printf("1. Presentacion\n");
    printf("2. Los elementos del conjunto A o B\n");
    printf("3. El producto cartesiano\n");
    printf("4. El conjunto relación (R)\n");
    printf("5. La matriz de adyacencia de la relación\n");
    printf("6. El dígrafo de la relación\n");
    printf("7. Salir\n");
    printf("Eliga una de las opciones presentadas.\n");
    scanf("%d", &ch);
    switch(ch)
    {
	case 1: presentacion();
		break;
	case 2: 
		printf("Que conjunto desea imprimir?\n1. A\n2. B\n");
		scanf("%d", &cch);
		if(cch==1){
			printf("A=");printj(A);
		} else if(cch==2){
			printf("B=");printj(B);
		}
		break;
	case 3: printf("Producto Cartesiano\n");
		pcar(A,B);
		break;
	case 4: printf("Conjunto de Relación\n");
		nrel(A,B,1);
		break;
	case 5: printf("Matriz relacion\n");
		matrel(A, B);
		break;
	case 6: graphic(&gd,&gm,A,B);
		break;
	case 7: printf("Gracias!");
		break;
	default: printf("Eliga de las opciones predeterminadas.\n");
    }
    }while (ch!=7);
    //printf("N: %d\n",A->X[0]);
    getch();
}
Exemplo n.º 12
0
QPixmap HockeyGame::getSogComparisonPreview()
{
    QList<QString> stats;
    stats.append(QString::number(awaySOG));
    stats.append(QString::number(homeSOG));
    comparisonPreview.prepareStandardComp(MiamiAllAccessHockey::awaySchool.getShortName(),
                                          MiamiAllAccessHockey::homeSchool.getShortName(),
                                          stats, "Shots on Goal");
    QPixmap graphic(comparisonPreview.getWidth(), comparisonPreview.getHeight());
    graphic.fill(QColor(0,0,0,0));
    QPainter painter(&graphic);
    comparisonPreview.paintPreview(&painter);
    return graphic.scaled(comparisonPreview.getWidth()/2, comparisonPreview.getHeight()/2);
}
Exemplo n.º 13
0
void CairoBox::out_svg(const char* filename, int wpts, int hpts)
  {
  cairo_surface_t* surface;
  cairo_t*         cr;

  surface = cairo_svg_surface_create (filename, wpts, hpts);
  cr      = cairo_create (surface);
  cairo_set_source_rgb (cr, 0, 0, 0);

  // user coordinates -- see cairo_svg_surface_create 
  graphic(cr, 0, 0, wpts, hpts);

  cairo_destroy (cr);
  cairo_surface_destroy (surface);
  }
Exemplo n.º 14
0
void Zumbi::movimento(Player &player) {
    if ((player.position() - position()).length() < 5.0)
    {
        if (graphic().getCurrentAnimation() != Animation::TAUNT02)
        {
            //Força colisão repetida de ataque
            Array tmp = (player.position() - position()).normalize()*200.0;
            tmp += Array(0,1000.0,0);
            body().force += tmp;
            tempAnimation(Animation::TAUNT02, Animation::WALK);
        }
    }
    else
    {
        body().force += (player.position() - position()).normalize()* VELOCIDADE_ZUMBI;
        direction(body().force);
    }
}
Exemplo n.º 15
0
void CairoBox::out_png(const char* filename, int wpix, int hpix)
  {
  cairo_surface_t* surface;
  cairo_t*         cr;

  // setup, see cairo_format_t for discussion of first argument 
  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, wpix, hpix);
  cr      = cairo_create (surface);

  cairo_translate(cr, 0.5, 0.5);       // for anti-aliasing
  cairo_set_source_rgb (cr, 0, 0, 0);  // drawing color set to black

  // virtual function
  graphic(cr, 0, 0, wpix, hpix); 

  cairo_surface_write_to_png (surface, filename);
  cairo_destroy (cr);
  cairo_surface_destroy (surface);
  }
Exemplo n.º 16
0
int		main(int ac, char **av)
{
	if (ac != 3){
		usage();
	}
	checkArgs(std::string(av[1]), std::string(av[2]));

	srand (time(NULL));

	Board board(std::atoi(av[1]), std::atoi(av[2]));

	GraphSwitch graphic(std::atoi(av[1]), std::atoi(av[2]));

	graphic.setGraphic("sfml");

	while (board.isAlive){
		eKeys key = graphic.graph->getKeyPressed();
		try{
			if (key == eKeys::ONE)
				graphic.setGraphic("sfml");
			else if (key == eKeys::TWO)
				graphic.setGraphic("ncurses");
			else if (key == eKeys::THREE)
				graphic.setGraphic("sdl");
			else
				board.handleKey(key);
		}
		catch(std::string const & e){
			std::cout << e << std::endl;
			graphic.graph->close();
			exit(EXIT_SUCCESS);
		}

		graphic.graph->clearWindow();
		board.drawMap(graphic.graph);
		graphic.graph->show();
	}
	std::cout << "You are dead !" << std::endl << "Score : " << board.getScore() << std::endl;
	graphic.graph->close();
	return (0);
}
Exemplo n.º 17
0
void CGraphicOption::OnPaint() 
{
	CPaletteDC dc(this); // device context for painting

	ASSERT(m_pgBackground);
	CGraphicOnscreen graphic(m_pgBackground->Width(),m_pgBackground->Height());

	// Copy background to temporary graphic
	m_pgBackground->Copy(&graphic);

	int iYOffset=(m_pgBackground->Height() - m_pgaUpUp->Height())/2;

	// Paint buttons...
	m_pgaUpUp->Copy(&graphic,0,iYOffset);
	m_pgaDownUp->Copy(&graphic,m_pgBackground->Width()-m_iButtonX,iYOffset);

	// Paint background
	int iStop=m_pgBackground->Width()-m_iButtonX*2-m_iPartX;
	for(int iX=0;iX<iStop;iX+=m_iPartX)
		m_pgaNormalMid->Copy(&graphic,iX+m_iButtonX,0);
	m_pgaNormalMid->Copy(&graphic,iX+m_iButtonX,0,0,0,iStop+m_iPartX-iX,m_iButtonHeight);

	// Reset position
	if(m_iPos < GetMin()) m_iPos=GetMin();
	if(m_iPos > GetMax()) m_iPos=GetMax();

	if(m_iPos >= GetMin()) 
	{
		m_pfont->Draw(&graphic,
			(m_pgBackground->Width()-m_pfont->Width(GetText(m_iPos)))/2,
			(m_pgBackground->Height()-m_pfont->Height())+m_iBaselineAdjust,
			GetText(m_iPos),m_clrText);
	}

	graphic.Draw(&dc,0,0);
}
Exemplo n.º 18
0
void Minitel::graphic(String s, int x, int y){
  moveCursorTo(x, y);
  graphic(s); 
}
Exemplo n.º 19
0
Graphic* Picture::GetGraphic (Iterator i) { return graphic(Elem(i)); }
/*------------------------------------------------------------------------------
| DrawingArea::button1Down                                                     |
|                                                                              |
| Handle button 1 down messages.  This event indicates a new graphic object is |
| to be created of additional data points to add to an existing graphic object.|
------------------------------------------------------------------------------*/
DrawingArea& DrawingArea::button1Down( const IPoint& point )
{
  switch (currentObj)
  {
    case move: // Button 1 drag
      if (drawState() == notDrawing)
      {
        moveGraphic = graphicList()->topGraphicUnderPoint( point, gc );
        if ( moveGraphic )
        {
          moveRect.setEnclosingRect(moveGraphic->boundingRect( gc ));
          previousPt = point;
          startingPt = point;
          capturePointer();
        }
      }
    break;
    case eraser:
      {
        // Delete the object under the pointer
        moveGraphic = graphicList()->topGraphicUnderPoint( point, gc );
        if ( moveGraphic )
        {
          moveRect.setEnclosingRect(moveGraphic->boundingRect( gc ));
          IGList::Cursor cursor( *graphicList(), gc, point );
          for (cursor.setToFirst(); cursor.isValid(); cursor.setToNext())
          {
             IGraphic* graphic(&(graphicList()->graphicAt(cursor)));
             if (graphic == moveGraphic)
             {
               graphicList()->removeAt(cursor);
               delete graphic;
               this->refresh( moveRect.boundingRect(gc).expandBy(2) );
               moveRect.resetTransformMatrix();
               moveGraphic = 0;
               break;
             }
          }
        }
      }
    break;
    case stylecan:
    {
      // Change all objects to the current pen and fill color.
      IRectangle tempRect;
      moveGraphic = graphicList()->topGraphicUnderPoint( point, gc );
      if( moveGraphic )
      {
        tempRect = moveGraphic->boundingRect( gc );
        moveGraphic->setGraphicBundle( currentBundle );
        moveGraphic->drawOn( gc );
        tempRect |= moveGraphic->boundingRect( gc );
        this->refresh( tempRect.expandBy(2) );
        moveGraphic = 0;
      }
    }
    break;
    case line:
      startingPt = point;
      previousPt = point;
      iGraphic = new IGLine( startingPt, previousPt );
      setDrawState();
    break;
    case freehand:
      iGraphic = new IGPolygon(IPointArray());
      ((IGPolygon*)iGraphic)->addPoint( point );
      setDrawState();
    break;
    case rectangle:
      startingPt = point;
      previousPt = point;
      iGraphic = new IGRectangle(IRectangle(startingPt, previousPt));
      setDrawState();
    break;
    case ellipse:
      startingPt = point;
      previousPt = point;
      iGraphic = new IGEllipse( startingPt, 0L );
      setDrawState();
    break;
    case polyline:
    case polygon:
      if (drawState() == notDrawing)
      {
        startingPt = point;
        previousPt = point;
        if (currentObj == polyline)
          iGraphic = new IGPolyline(IPointArray());
        else
          iGraphic = new IGPolygon(IPointArray());

        ((IGPolyline*)iGraphic)->addPoint( startingPt );
        ((IGPolyline*)iGraphic)->addPoint( previousPt );
        setDrawState();
      }
      else
      {
        ((IGPolyline*)iGraphic)->IGPolyline::drawOn( gc );
        ((IGPolyline*)iGraphic)->addPoint( point );
        ((IGPolyline*)iGraphic)->IGPolyline::drawOn( gc );
      }
    break;
    case arc:
      pointCount++;
      if (drawState() == notDrawing)
      {
        iGraphic = new IG3PointArc( point, IPoint(0,0), IPoint(0,0) );
        startingPt = point;
        previousPt = point;
      }
      else if ( pointCount == 2 )
      {
        previousPt = point;
        IGLine tempLine( ((IG3PointArc*)iGraphic)->startingPoint(), point );
        tempLine.drawOn( gc );
      }
      else if ( pointCount == 3 )
      {
        IGLine tempLine( ((IG3PointArc*)iGraphic)->startingPoint(), previousPt );
        tempLine.drawOn( gc );
        previousPt = point;
        ((IG3PointArc*)iGraphic)->setEndingPoint( point );
        iGraphic->drawOn( gc );
      }
      setDrawState();
    break;
    case pie:
    case chord:
      pointCount++;
      if (drawState() == notDrawing)
      {
        if (currentObj == pie)
          iGraphic = new IGPie( IRectangle(), 0, 0);
        else
          iGraphic = new IGChord( IRectangle(), 0, 0);

        ((IGPie*)iGraphic)->setEnclosingRect(
                             ((IGPie*)iGraphic)->enclosingRect().centerAt( point ));
        startingPt = point;
        previousPt = point;
      }
      else if ( pointCount == 2 )
      {
        previousPt = point;
        IGLine tempLine( ((IGPie*)iGraphic)->enclosingRect().center(), point );
        tempLine.drawOn( gc );
      }
      else if ( pointCount == 3 )
      {
        IGLine tempLine( ((IGPie*)iGraphic)->enclosingRect().center(), previousPt );
        tempLine.drawOn( gc );
        previousPt = point;
        double sweep(angleFromPoints( ((IGPie*)iGraphic)->enclosingRect().center(), point ));
        if ( sweep < ((IGPie*)iGraphic)->startAngle() )
          ((IGPie*)iGraphic)->setSweepAngle( 360.0 -
                                ( ((IGPie*)iGraphic)->startAngle() - sweep ));
        else
          ((IGPie*)iGraphic)->setSweepAngle( sweep -
                                            ((IGPie*)iGraphic)->startAngle());
        iGraphic->drawOn( gc );
      }
      setDrawState();
    break;
    case text:
      setDrawState();
    break;
    case bitmap:
      setDrawState();
    break;
  } /* endswitch */
  return *this;
}