コード例 #1
0
/*! Load a database, an image, and find best matches. */
int main(const int argc, const char **argv)
{
  MYLOGVERB = LOG_INFO;

  // check command-line args:
  if (argc < 3 || argc > 4)
    LFATAL("USAGE: app-match-SIFT-database <dbname.vdb> <image.png> "
           "[<fused.png>]");

  // load the database:
  VisualObjectDB vdb;
  if (vdb.loadFrom(argv[1]) == false)
    LFATAL("Cannot operate without a valid database.");

  // get input image:
  Image< PixRGB<byte> > colim = Raster::ReadRGB(argv[2]);

  // create visual object and extract keypoints:
  rutz::shared_ptr<VisualObject> vo(new VisualObject(argv[2], argv[2], colim));

  // get the matching objects:
  std::vector< rutz::shared_ptr<VisualObjectMatch> > matches;
  const uint nmatches = vdb.getObjectMatches(vo, matches, VOMA_KDTREEBBF);

  // prepare the fused image:
  Image< PixRGB<byte> > mimg;
  std::vector<Point2D<int> > tl, tr, br, bl;

  // if no match, forget it:
  if (nmatches == 0U)
    LINFO("### No matching object found.");
  else
    {
      // let the user know about the matches:
      for (uint i = 0; i < nmatches; i ++)
        {
          rutz::shared_ptr<VisualObjectMatch> vom = matches[i];
          rutz::shared_ptr<VisualObject> obj = vom->getVoTest();

          LINFO("### Object match with '%s' score=%f",
                obj->getName().c_str(), vom->getScore());

          // add to our fused image if desired:
          if (argc > 3)
            {
              mimg = vom->getTransfTestImage(mimg);

              // also keep track of the corners of the test image, for
              // later drawing:
              Point2D<int> ptl, ptr, pbr, pbl;
              vom->getTransfTestOutline(ptl, ptr, pbr, pbl);
              tl.push_back(ptl); tr.push_back(ptr);
              br.push_back(pbr); bl.push_back(pbl);
            }
        }

      // do a final mix between given image and matches:
      if (mimg.initialized())
        {
          mimg = Image<PixRGB<byte> >(mimg * 0.5F + colim * 0.5F);

          // finally draw all the object outlines:
          PixRGB<byte> col(255, 255, 0);
          for (uint i = 0; i < tl.size(); i ++)
            {
              drawLine(mimg, tl[i], tr[i], col, 1);
              drawLine(mimg, tr[i], br[i], col, 1);
              drawLine(mimg, br[i], bl[i], col, 1);
              drawLine(mimg, bl[i], tl[i], col, 1);
            }
        }
    }

  // save result image if desired:
  if (argc > 3)
    {
      if (mimg.initialized() == false)
        mimg = Image< PixRGB<byte> >(colim * 0.5F);
      Raster::WriteRGB(mimg, std::string(argv[3]));
    }

  return 0;
}
コード例 #2
0
ファイル: colorpanel.cpp プロジェクト: KlausMerkert/FreeRail
void ColorPanel::OnPaint(wxPaintEvent& event)
{
  wxPaintDC dc(this);
  m_DC = &dc;

  dc.SetBackground(*wxBLACK_BRUSH);
  dc.Clear();

  m_UseGC = false;

  wxGraphicsContext* gc = NULL;
  if( wGui.isrendergc(wxGetApp().getIni())) {
    m_UseGC = true;
    gc = wxGraphicsContext::Create(this);
    m_GC = gc;
#ifdef wxANTIALIAS_DEFAULT
    gc->SetAntialiasMode(wxANTIALIAS_DEFAULT);
#endif
  }

  int w = 0;
  int h = 0;
  GetSize(&w, &h);

  setPen(*wxLIGHT_GREY, 1, wxDOT);
  float h10 = (float)h / 10.0;
  for( int i = 1; i < 10; i++) {
    //dc.DrawLine( 0, i*h10, w, i*h10 );
    drawLine( 0, i*h10, w, i*h10 );
  }

  int curinterval = -1;
  if( m_Hour != -1 ) {
    curinterval = (m_Hour * 60 + m_Min) / 30;
  }
  float w23 = (float)w / 23.0;
  float w47 = (float)w / 47.0;
  for( int i = 0; i < 48; i++) {
    if( curinterval != -1 && curinterval == i ) {
      setPen(wxColor( 0, 50, 0 ), 1, wxSOLID);
      setBrush( wxColor( 0, 50, 0 ));
      drawRectangle(i * w47 + 1, 0, w47, h);
    }

    if( i == m_Selection ) {
      setPen(*wxLIGHT_GREY, 3, wxDOT);
      dc.SetPen( *wxLIGHT_GREY_PEN );
      drawLine( i * w47, 0, i * w47, h );
    }
    else if( i > 0 && i < 47 ){
      setPen(*wxLIGHT_GREY, 1, wxDOT);
      drawLine( i * w47, 0, i * w47, h );
    }

  }

  TraceOp.trc( "colorpanel", TRCLEVEL_INFO, __LINE__, 9999, "width=%d height=%d", w, h );

  if( m_Weather != NULL ) {

    iONode colorProps[48] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                             NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                             NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                             NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};

    iONode color = wWeather.getweathercolor(m_Weather);
    while(color != NULL) {
      int hour = wWeatherColor.gethour(color);
      int min  = wWeatherColor.getminute(color);
      if( hour < 24 && hour >= 0 && min < 60 && min >= 0) {
        colorProps[(hour*60+min)/30] = color;
      }
      color = wWeather.nextweathercolor(m_Weather, color);
    }

    TraceOp.trc( "colorpanel", TRCLEVEL_INFO, __LINE__, 9999, "check if all 30 mins are there..." );
    iONode prevColorProps = colorProps[0];
    for( int i = 0; i < 48; i++ ) {
      if( colorProps[i] == NULL && prevColorProps == NULL) {
        TraceOp.trc( "colorpanel", TRCLEVEL_INFO, __LINE__, 9999, "exit..." );
        if( gc != NULL)
          delete gc;
        return;
      }
      if( colorProps[i] == NULL && prevColorProps != NULL) {
        colorProps[i] = prevColorProps;
      }
      TraceOp.trc( "colorpanel", TRCLEVEL_DEBUG, __LINE__, 9999, "i=%d", i );
      prevColorProps = colorProps[i];
    }

    TraceOp.trc( "colorpanel", TRCLEVEL_INFO, __LINE__, 9999, "draw the color table..." );

    float ystep = (float)h / 255.0;

    if( m_White ) {
      setPen(wxColor( m_White1R, m_White1G, m_White1B ), 3, wxSOLID);
      int start = wWeatherColor.getwhite(colorProps[0]);
      for( int i = 1; i < 48; i++ ) {
        int val = wWeatherColor.getwhite(colorProps[i]);
        drawLine( (i-1) * w47, (255-start) * ystep, i * w47, (255-val) * ystep );
        start = val;
      }
    }

    if( m_White2 ) {
      setPen(wxColor( m_White2R, m_White2G, m_White2B ), 3, wxSOLID);
      int start = wWeatherColor.getwhite(colorProps[0]);
      for( int i = 1; i < 48; i++ ) {
        int val = wWeatherColor.getwhite2(colorProps[i]);
        drawLine( (i-1) * w47, (255-start) * ystep, i * w47, (255-val) * ystep );
        start = val;
      }
    }

    setPen(wxColor( 255, 0, 0 ), 3, wxSOLID);
    int start = wWeatherColor.getred(colorProps[0]);
    for( int i = 1; i < 48; i++ ) {
      int val = wWeatherColor.getred(colorProps[i]);
      drawLine( (i-1) * w47, (255-start) * ystep, i * w47, (255-val) * ystep );
      start = val;
    }

    setPen(wxColor( 0, 255, 0 ), 3, wxSOLID);
    start = wWeatherColor.getgreen(colorProps[0]);
    for( int i = 1; i < 48; i++ ) {
      int val = wWeatherColor.getgreen(colorProps[i]);
      drawLine( (i-1) * w47, (255-start) * ystep, i * w47, (255-val) * ystep );
      start = val;
    }

    setPen(wxColor( 0, 0, 255 ), 3, wxSOLID);
    start = wWeatherColor.getblue(colorProps[0]);
    for( int i = 1; i < 48; i++ ) {
      int val = wWeatherColor.getblue(colorProps[i]);
      drawLine( (i-1) * w47, (255-start) * ystep, i * w47, (255-val) * ystep );
      start = val;
    }

    if( m_Brightness ) {
      setPen(wxColor( m_BrightnessR, m_BrightnessG, m_BrightnessB ), 1, wxSOLID);
      start = wWeatherColor.getbri(colorProps[0]);
      for( int i = 1; i < 48; i++ ) {
        int val = wWeatherColor.getbri(colorProps[i]);
        drawLine( (i-1) * w47, (255-start) * ystep, i * w47, (255-val) * ystep );
        start = val;
      }
    }

    if( m_Saturation ) {
      setPen(wxColor( m_SaturationR, m_SaturationG, m_SaturationB ), 1, wxSOLID);
      start = wWeatherColor.getsat(colorProps[0]);
      for( int i = 1; i < 48; i++ ) {
        int val = wWeatherColor.getsat(colorProps[i]);
        drawLine( (i-1) * w47, (255-start) * ystep, i * w47, (255-val) * ystep );
        start = val;
      }
    }

  }
  else {
    TraceOp.trc( "colorpanel", TRCLEVEL_INFO, __LINE__, 9999, "No weather selected..." );
    dc.SetTextBackground(*wxBLACK);
    dc.SetTextForeground(*wxWHITE);
    dc.DrawText(wxT("No weather selected..."), 10, h/2);
  }

  if( gc != NULL)
    delete gc;

}
コード例 #3
0
void VoodooGraphics::drawLine(QPoint p1, QPoint p2)
{
    drawLine(p1.x(), p1.y(), p2.x(), p2.y(), color);
}
コード例 #4
0
vector<vector3df> Editor::startEditor(){

	myRecEditor->startEventProcess();
#ifdef EDITOR_VIEW
	myRecEditorView->startEventProcess();
#endif
	bool leftPress = false;
	mouseWheelCurr = 0;
	double value = 0;
	CAMPOSX = 0;
	CAMPOSY = 0;
	CAMPOSZ = CAM_POS_DEFAULT;
	while (deviceEditor->run())
	{
		mouseWheelCurr = (int)(myRecEditor->mouseWheel()*1.29);

		if (currentEksen == EKSEN_X)
			X = mouseWheelCurr;
		else
			X = myRecEditor->mouseX() - EDITOR_HALF_SCREEN_SIZE;

		if (currentEksen == EKSEN_Y)
			Y = mouseWheelCurr;
		else{
			Y = (EDITOR_HALF_SCREEN_SIZE - myRecEditor->mouseY());
		}

		if (currentEksen == EKSEN_X)
			Z = (myRecEditor->mouseX() - EDITOR_HALF_SCREEN_SIZE);
		else if (currentEksen == EKSEN_Y)
			Z = EDITOR_HALF_SCREEN_SIZE - myRecEditor->mouseY();
		else
			Z = mouseWheelCurr;


		driverEditor->beginScene(true, true, SColor(204, 204, 204, 204));
#ifdef EDITOR_VIEW
		driverEditorView->beginScene(true, true, SColor(204, 204, 204, 204));
#endif
		cameraCalibration(myRecEditor, editorCam);
		if (myRecEditor->keyDown(KEY_KEY_W)){ // ....  EVENT HANDLERS  .... 
			currentEksen = EKSEN_Y;
			deviceEditor->setWindowCaption(L"Editor Platform  X - Z Ekseni ");
			editorParentNode->setRotation(vector3df(((int)(editorParentNode->getRotation().X + NODE_ROTATION_SPEED)) % ROTATION_LIMIT, 0, 0));
		}
		else if (myRecEditor->keyDown(KEY_KEY_S)){
			currentEksen = EKSEN_Z;
			deviceEditor->setWindowCaption(L"Editor Platform  X - Y Ekseni ");
			editorCam->setPosition(vector3df(0, 0, CAM_POS_DEFAULT + (mouseWheelCurr * CAM_POS_INC)));
			editorParentNode->setRotation(vector3df(0, 0, 0));
			CAMPOSX = 0;
			CAMPOSY = 0;
			CAMPOSZ = CAM_POS_DEFAULT;
		}
		else if (myRecEditor->keyDown(KEY_KEY_A)){
			currentEksen = EKSEN_X;
			deviceEditor->setWindowCaption(L"Editor Platform  Y - Z Ekseni ");
			editorParentNode->setRotation(vector3df(0, ((int)(editorParentNode->getRotation().Y + NODE_ROTATION_SPEED)) % ROTATION_LIMIT, 0));
		}
		else if (myRecEditor->keyDown(KEY_KEY_D)){
			currentEksen = EKSEN_Z;
			deviceEditor->setWindowCaption(L"Editor Platform  X - Y Ekseni ");
			editorParentNode->setRotation(vector3df(0, 0, ((int)(editorParentNode->getRotation().Z + NODE_ROTATION_SPEED)) % ROTATION_LIMIT));
		}
		else if (myRecEditor->keyDown(KEY_KEY_P))
		{
			stopEditor();
		}

		if (myRecEditor->leftMousePressed()){
			if (!leftPress)
				vFirst = vLast; // Clear Buffer.
			drawLine();
			leftPress = true;
		}
		if (myRecEditor->leftMouseReleased()){
			if (leftPress){
				vFirst = vLast; // Clear buffer.
				leftPress = false;
			}
		}
		if (myRecEditor->rightMouseDown()){

			drawLine();
		}
		if (myRecEditor->keyDown(KEY_KEY_C))
		{
			positionNodes.clear();
			smgrEditor->clear();
			editorParentNode = smgrEditor->addEmptySceneNode();
			editorParentNode->setVisible(true);
			editorChildNode = smgrEditor->addSphereSceneNode();
			nodeEditorCurrMouse = editorChildNode->clone();

			if (nodeEditorCurrMouse && editorChildNode){

				editorParentNode->setVisible(true);
				editorChildNode->setMaterialFlag(EMF_LIGHTING, false);
				editorChildNode->setScale(editorChildNode->getScale()*0.60f);
#if defined(_WIN32) || defined(_WIN64)
				editorChildNode->setMaterialTexture(0, driverEditor->getTexture("media/blueTexture.png"));

#else

				editorChildNode->setMaterialTexture(0, driverEditor->getTexture("../media/blueTexture.png"));
#endif

				editorChildNode->setVisible(false);

				nodeEditorCurrMouse->setMaterialFlag(EMF_LIGHTING, false);
#if defined(_WIN32) || defined(_WIN64)
				nodeEditorCurrMouse->setMaterialTexture(0, driverEditor->getTexture("media/redTexture.png"));

#else

				nodeEditorCurrMouse->setMaterialTexture(0, driverEditor->getTexture("../media/redTexture.png"));
#endif

				nodeEditorCurrMouse->setVisible(true);
				nodeEditorCurrMouse->setScale(nodeEditorCurrMouse->getScale()*1.3f);
			}
			// add camera
			editorCam = smgrEditor->addCameraSceneNode(0, vector3df(0, 0, CAM_POS_DEFAULT), vector3df(0, 0, -CAM_POS_DEFAULT));
			X = 0;
			Y = 0;
			Z = 0;

			// camera View ..
			currentEksen = EKSEN_Z;
			editorParentNode->addChild(nodeEditorCurrMouse);
			deviceEditor->getCursorControl()->setVisible(false); // Unvisible mouse cursor
			mouseWheelBefore = 0; // mouse depth value set 0.
			smgrEditor->setActiveCamera(editorCam);

		}

		drawEditorFrame(driverEditor);
		driverEditor->draw3DLine(vector3df(-EDITOR_SCREEN_WIDTH, 0, 0), vector3df(EDITOR_SCREEN_WIDTH, 0, 0), SColor(255, 0, 255, 0));
		driverEditor->draw3DLine(vector3df(0, -EDITOR_SCREEN_WIDTH, 0), vector3df(0, EDITOR_SCREEN_WIDTH, 0), SColor(255, 255, 0, 0));
		driverEditor->draw3DLine(vector3df(0, 0, -EDITOR_SCREEN_WIDTH), vector3df(0, 0, EDITOR_SCREEN_WIDTH), SColor(0, 0, 0, 0));

		/*  Current node will be painted on editor */
		nodeEditorCurrMouse->setPosition(vector3df(X, Y, Z));
#ifdef EDITOR_VIEW
		nodeEditorViewCurrMouse->setPosition(vector3df(X, Y, Z));
		handleCameraDevice2(myRecEditorView, editorViewCam, eBoxEditorView, editorViewParentNode);
#endif


		snprintf(stringEditorHelper, 100, "X: %d   Y: %d   Z: %d ", X, Y, Z);
		mbstowcs(stringEditor, stringEditorHelper, (size_t)100);
		eBoxEditor->setText(stringEditor);

		guienvEditor->drawAll();
		smgrEditor->drawAll();
		driverEditor->endScene();
#ifdef EDITOR_VIEW		
		smgrEditorView->drawAll();
		guienvEditorView->drawAll();
		driverEditorView->endScene();
#endif

	}
	return positionNodes;
}
コード例 #5
0
static void drawDebugPaths() {
	
	GRenderer->SetRenderState(Renderer::DepthTest, false);
	
	for(long i = 0; i < nbARXpaths; i++) {
		
		ARX_PATH * path = ARXpaths[i];
		if(!path) {
			continue;
		}
		
		Vec3f center = Vec3f_ZERO;
		int n = 0;
		
		std::vector<Vec3f> points;
		for(long i = 0; i < path->nb_pathways; i++) {
			const ARX_PATHWAY & node = path->pathways[i];
			Vec3f pos = path->pos + node.rpos;
			points.push_back(pos);
			center += pos, n++;
			if(node.flag == PATHWAY_BEZIER) {
				// Interpolate bezier curve by creating linear segments
				if(i + 2 >= path->nb_pathways) {
					break;
				}
				const size_t nsegments = 20;
				for(size_t j = 0; j < nsegments; j++) {
					points.push_back(path->interpolateCurve(i, float(j) / nsegments));
				}
				i++; // Skip the control point
			}
		}
		
		// Zones only check the bounding box for the y coordinate - adjust display for that
		if(path->height > 0) {
			for(size_t i = 0; i < points.size(); i++) {
				points[i].y = path->bbmin.y;
			}
		}
		
		if(path->height != 0 || ((path->flags & PATH_LOOP) && points.size() > 0)) {
			points.push_back(points[0]);
		}
		
		Color color = (path->height != 0) ? Color::green : Color::red;
		
		for(size_t i = 0; i + 1 < points.size(); i++) {
			drawLine(points[i], points[i + 1], color);
		}
		
		if(path->height > 0) {
			Vec3f offset(0.f, (path->bbmax.y - path->bbmin.y), 0.f);
			for(size_t i = 0; i + 1 < points.size(); i++) {
				drawLine(points[i] + offset, points[i + 1] + offset, color);
			}
			for(size_t i = 0; i < points.size(); i++) {
				drawLine(points[i], points[i] + offset, color);
			}
		}
		
		// Display the name and controlling entity for close zones
		if(!path->name.empty() || !path->controled.empty()) {
			if(path->height > 0) {
				center = (path->bbmin + path->bbmax) / 2.f;
			} else if(n != 0) {
				center /= float(n);
			} else {
				center = path->pos;
			}
			if(closerThan(center, player.pos, DebugTextMaxDistance)) {
				std::string controlledby;
				if(!path->controled.empty()) {
					controlledby = "Controlled by: " + path->controled;
				}
				Color textcolor = color * 0.5f + Color::gray(0.5f);
				drawTextAt(hFontDebug, center, path->name, textcolor, controlledby);
			}
		}
		
	}
	
	GRenderer->SetRenderState(Renderer::DepthTest, true);
	
}
コード例 #6
0
ファイル: GLDebugDrawer.cpp プロジェクト: AJ92/Engine
void	GLDebugDrawer::drawLine(const btVector3& from,const btVector3& to,const btVector3& color)
{
	drawLine(from,to,color,color);
}
コード例 #7
0
ファイル: weatherchart.cpp プロジェクト: primijos/f1lt
void TempChart::drawChart(QPainter *p)
{
    EventData &ed = EventData::getInstance();
//    if (ed.getWeather().getSize(weatherId)>1)
    {
        p->setBrush(QBrush(color));
        QPen pen(color);
        pen.setWidth(2);
        p->setPen(pen);
        p->setRenderHint(QPainter::Antialiasing);

        int sz = last - first + 1;

        if (sz <= 0)
            return;

        double xFactor1 = ((double)paintRect.width()) / (double)sz;//(ed.getWeather().getSize(weatherId));
        double yFactor = ((double)paintRect.height()-40.0) / (double)(tMax-tMin);

        double x = paintRect.left(), j1 = x + xFactor1;

        double y1 = (double)paintRect.bottom();// - (double)(ed.getWeather().getWeatherData(weatherId)[first].getValue()-tMin) * yFactor;
        double y2 = (double)paintRect.bottom();// - (double)(ed.getWeather().getWeatherData(trackTempId)[first].getValue()-tMin) * yFactor;

        if (first < ed.getWeather().getWeatherData(weatherId).size())
            y1 -= (double)(ed.getWeather().getWeatherData(weatherId)[first].getValue()-tMin) * yFactor;

        if (first < ed.getWeather().getWeatherData(trackTempId).size())
            y2 -= (double)(ed.getWeather().getWeatherData(trackTempId)[first].getValue()-tMin) * yFactor;

        int i = first;
        pen.setColor(color);
        p->setPen(pen);

        int end = ed.getWeather().getWeatherData(weatherId).size() > ed.getWeather().getWeatherData(trackTempId).size() ?
                  ed.getWeather().getWeatherData(weatherId).size() : ed.getWeather().getWeatherData(trackTempId).size();

        for (; i < last + 1 && i < end; ++i, j1 += xFactor1)
        {
            double y3 = (double)paintRect.bottom();// - (double)(ed.getWeather().getWeatherData(weatherId)[i].getValue()-tMin) * yFactor;
            double y4 = (double)paintRect.bottom();// - (double)(ed.getWeather().getWeatherData(trackTempId)[i].getValue()-tMin) * yFactor;

            if (i < ed.getWeather().getWeatherData(weatherId).size())
                y3 -= (double)(ed.getWeather().getWeatherData(weatherId)[i].getValue()-tMin) * yFactor;

            if (i < ed.getWeather().getWeatherData(trackTempId).size())
                y4 -= (double)(ed.getWeather().getWeatherData(trackTempId)[i].getValue()-tMin) * yFactor;

            double ty1 = y1, ty3 = y3, ty2 = y2, ty4 = y4;

            pen.setColor(color);
            p->setPen(pen);
            drawLine(p, x, ty1, j1, ty3);

            pen.setColor(trackTempCol);
            p->setPen(pen);
            drawLine(p, x, ty2, j1, ty4);

            x = j1;
            y1 = y3;
            y2 = y4;
        }
//        i = 1;
//        x = paintRect.left();

//        pen.setColor(trackTempCol);
//        p->setPen(pen);
//        for (; i < ed.weatherData[trackTempId].size(); ++i, j2 += xFactor2)
//        {
//            double y4 = (double)paintRect.width() - (double)(ed.weatherData[trackTempId][i].getValue()-tMin) * yFactor;
//            double midx = (j2 + x)/2;

//            p->drawLine(x, y2, midx, y2);
//            p->drawLine(midx, y2, midx, y4);
//            p->drawLine(midx, y4, j2, y4);

//            x = j2;
//            y2 = y4;
//        }
    }
}
コード例 #8
0
ファイル: TFTLCD.c プロジェクト: blaezec/stm32f4
// draw a triangle!
void drawTriangle(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color)
{
    drawLine(x0, y0, x1, y1, color);
    drawLine(x1, y1, x2, y2, color);
    drawLine(x2, y2, x0, y0, color); 
}
コード例 #9
0
ファイル: physicsdebugdraw.cpp プロジェクト: IreNox/tiki3
	void PhysicsDebugDraw::drawLine( const btVector3& from, const btVector3& to, const btVector3& fromColor, const btVector3& toColor )
	{
		drawLine( from, to, fromColor );
	}
コード例 #10
0
ファイル: drawing.cpp プロジェクト: Artens/openanpr
/*!
 * \brief draw a grid within the given image
 * \param img image to be returned
 * \param img_width width of the image
 * \param img_height height of the image
 * \param centre_x x centre point of the grid
 * \param centre_y y centre point of the grid
 * \param rotation rotation angle of the grid  radians
 * \param columns number of grid columns
 * \param rows number of grid rows
 * \param r red
 * \param g green
 * \param b blue
 * \param linewidth line width
 */
void drawing::drawGrid(
    unsigned char* img,
    int img_width,
    int img_height,
    int centre_x,
    int centre_y,
    float rotation,
    float size_width,
    float size_height,
    int columns,
    int rows,
    int r,
    int g,
    int b,
    int linewidth)
{
    // draw the columns
    for (int col = 0; col <= columns; col++)
    {
        float grid_x = ((col * size_width) / (float)columns) - (size_width/2);
        int prev_x = 0;
        int prev_y = 0;
        for (int row = 0; row <= rows; row += rows)
        {
            float grid_y = ((row * size_height) / (float)rows) - (size_height/2);
            float hyp = (float)sqrt((grid_x*grid_x) + (grid_y*grid_y));
            float angle = 0;
            if (hyp > 0)
            {
                angle = (float)asin(grid_x / hyp);
                if (grid_y < 0) angle = (float)(PI*2)-angle;
            }
            angle += rotation;

            int x = (int)(centre_x + (hyp * sin(angle)));
            int y = (int)(centre_y + (hyp * cos(angle)));

            if (row > 0)
            {
                drawLine(img, img_width, img_height, prev_x, prev_y, x, y,
                         r, g, b, linewidth, false);
            }

            prev_x = x;
            prev_y = y;
        }
    }

    // draw the rows
    for (int row = 0; row <= rows; row ++)
    {
        float grid_y = ((row * size_height) / (float)rows) - (size_height/2);
        int prev_x = 0;
        int prev_y = 0;
        for (int col = 0; col <= columns; col += columns)
        {
            float grid_x = ((col * size_width) / (float)columns) - (size_width/2);
            float hyp = (float)sqrt((grid_x*grid_x) + (grid_y*grid_y));
            float angle = 0;
            if (hyp > 0)
            {
                angle = (float)asin(grid_x / hyp);
                if (grid_y < 0) angle = (float)(PI*2)-angle;
            }
            angle += rotation;

            int x = (int)(centre_x + (hyp * sin(angle)));
            int y = (int)(centre_y + (hyp * cos(angle)));

            if (col > 0)
            {
                drawLine(img, img_width, img_height, prev_x, prev_y, x, y,
                         r, g, b, linewidth, false);
            }

            prev_x = x;
            prev_y = y;
        }
    }

}
コード例 #11
0
ファイル: bndsmodifier.cpp プロジェクト: JustDevZero/bulmages
int BndsModifier::exec()
{
	/// Inicializa las 2 pantallas a negro.
	g_video->resetAllMain();
	g_video->resetAllSub();
	
	show();

	touchPosition touch;
	int pulsado;
	int pulsadoClick;
	int grosorX = 1;
	int grosorY = 2;
	bool tactil = false;
	int origenX = 0;
	int origenY = 0;
	
	/// Limites donde dibujar.
	int limXmin = 40 + 2;
	int limXmax = 256;
	int limYmin = 0;
	int limYmax = 171 - 2;
	
	u16* buffer = (u16*) bgGetGfxPtr ( g_video->backgroundMain() );
	
	/// Espera hasta que no se este pulsando en la pantalla. Nos aseguramos de
	/// no estar pintando antes de tiempo.
	while (1) {
	    scanKeys();
	    touchRead(&touch);
	    pulsado = keysHeld();
	    if (pulsado & KEY_TOUCH) {
	    } else {
		break;
	    } // end if
	} // end while


	while (1) {
	    scanKeys();
	    touchRead(&touch);
	    pulsado = keysHeld();
	    pulsadoClick = keysDown();
	    
	
	    if ((pulsado & KEY_TOUCH) && ((touch.px >= limXmin) && (touch.px <= limXmax) && (touch.py >= limYmin) && (touch.py <= limYmax)) ) {
		/// Se esta pulsando en la pantalla tactil.
		if (tactil == false) {
		    /// Se acaba de pulsar en la pantalla tactil. Se registra la posicion inicial.
		    origenX = touch.px;
		    origenY = touch.py;
		    tactil = true;
		} // end if
		
		//drawRectangle8bpp ( touch.px - (grosorX / 2), touch.py - (grosorY / 2), touch.px + (grosorX / 2), touch.py + (grosorY / 2), 1, buffer);
		drawLine(origenX, origenY, touch.px, touch.py, grosorX, grosorY, 0, buffer);
		
		/// Registra para el proximo dibujado.
		origenX = touch.px;
		origenY = touch.py;
		
	    } else {
		/// No se esta pulsando la pantalla tactil.
		tactil = false;
	    } // end if


	    if ( (pulsado & KEY_L) && (pulsado & KEY_R)) {
		/// Resetea la pantalla
		clearCanvas();
	    } // end if

	    if (pulsado & KEY_A) {
		/// Se pulsa la tecla A (aceptar).
		return 1;
	    } // end if

	    /// Si se pulsa en el boton 'aceptar'.
	    if ( (pulsadoClick & KEY_TOUCH) &&
		  (touch.px >= 180) && (touch.px <= 255 ) &&
		  (touch.py >= 175) && (touch.py <= 192 ) ) {

		  /// Se guarda la imagen en disco
		  time_t seconds;
		  seconds = time (NULL);
	    
		  string sec;
		  stringstream out;
		  out << seconds;
		  sec = out.str();
	    
		  string nombreArchivo = "tmp_ndsbulmatpv_" + sec + ".bmp.base64";
		  screenshotToBmp1BitBase64(nombreArchivo.c_str());
		  m_nombreArchivo = nombreArchivo;
	      
		  return 1;
	    } // end if

	    /// Si se pulsa en el boton 'cancelar'.
	    if ( (pulsadoClick & KEY_TOUCH) &&
		  (touch.px >= 0) && (touch.px <= 70 ) &&
		  (touch.py >= 175) && (touch.py <= 192 ) ) {
		    return -1;
	    } // end if

	    swiWaitForVBlank();
	
	} // end while

	return 0;
}
コード例 #12
0
ファイル: 2dcube.cpp プロジェクト: llovett/2dcube
void display(){
    int i;
    int sides = SIDES[WhichSides];

    glutSetWindow(main_window);
    glClear(GL_COLOR_BUFFER_BIT);

    glColor3f(0.3f, 0.0f, 0.4f);

    /* drawing the viewport */
    glBegin(GL_POLYGON);
    /* this is not the real viewport. We will clip to this
     * area later on. */
    glVertex2f(VIEWPORT_MARGIN, VIEWPORT_MARGIN);
    glVertex2f(VIEWPORT_MARGIN, Wb - VIEWPORT_MARGIN);
    glVertex2f(Wr - VIEWPORT_MARGIN, Wb - VIEWPORT_MARGIN);
    glVertex2f(Wr - VIEWPORT_MARGIN, VIEWPORT_MARGIN);
    glEnd();

    /* draw the cube */
    glColor3f(1.0,0.0,0.0);
    drawLine(0, 0, 0,
    	     CubeSize, 0, 0);
    drawLine(CubeSize, 0, 0,
    	     CubeSize, CubeSize, 0);
    drawLine(CubeSize, CubeSize, 0,
    	     0, CubeSize, 0);
    drawLine(0, CubeSize, 0,
    	     0, 0, 0);
    glColor3f(1.0,0.3,0.0);
    drawLine(CubeSize,0,CubeSize,
    	     CubeSize,CubeSize,0);

    glColor3f(0.0,1.0,0.0);
    drawLine(0, 0, CubeSize,
    	     CubeSize, 0, CubeSize);
    drawLine(CubeSize, 0, CubeSize,
    	     CubeSize, CubeSize, CubeSize);
    drawLine(CubeSize, CubeSize, CubeSize,
    	     0, CubeSize, CubeSize);
    drawLine(0, CubeSize, CubeSize,
    	     0, 0, CubeSize);

    glColor3f(0.0,1.0,1.0);
    drawLine(0, 0, 0,
    	     0, 0, CubeSize);
    drawLine(CubeSize, 0, 0,
    	     CubeSize, 0, CubeSize);
    drawLine(CubeSize, CubeSize, 0,
    	     CubeSize, CubeSize, CubeSize);
    drawLine(0, CubeSize, 0,
    	     0, CubeSize, CubeSize);

    glutSwapBuffers();

}
コード例 #13
0
ファイル: kicongrid.cpp プロジェクト: kthxbyte/KDE1-Linaro
void KIconEditGrid::mouseReleaseEvent( QMouseEvent *e )
{
  if(!e || (e->button() != LeftButton))
    return;

  int row = findRow( e->pos().y() );
  int col = findCol( e->pos().x() );
  btndown = false;
  end.setX(col);
  end.setY(row);
  int cell = row * numCols() + col;

  switch( tool )
  {
    case Eraser:
      currentcolor = TRANSPARENT;
    case Freehand:
    {
      if(!img->valid(col, row))
        return;
      setColor( cell, currentcolor );
      //if ( selected != cell )
      //{
        //modified = true;
        int prevSel = selected;
        selected = cell;
        repaint((prevSel%numCols())*cellsize,(prevSel/numCols())*cellsize, cellsize, cellsize, false);
        repaint(col*cellsize,row*cellsize, cellsize, cellsize, false);
        //updateCell( prevSel/numCols(), prevSel%numCols(), FALSE );
        //updateCell( row, col, FALSE );
        *((uint*)img->scanLine(row) + col) = colorAt(cell);
        p = *img;
      //}
      break;
    }
    case Ellipse:
    case Circle:
    case FilledEllipse:
    case FilledCircle:
    {
      drawEllipse(true);
      break;
    }
    case FilledRect:
    case Rect:
    {
      drawRect(true);
      break;
    }
    case Line:
    {
      drawLine(true);
      break;
    }
    case Spray:
    {
      drawSpray(QPoint(col, row));
      break;
    }
    case FloodFill:
    {
      QApplication::setOverrideCursor(waitCursor);
      drawFlood(col, row, colorAt(cell));
      QApplication::restoreOverrideCursor();
      updateColors();
      emit needPainting();
      p = *img;
      break;
    }
    case Find:
    {
      currentcolor = colorAt(cell);
      if ( selected != cell )
      {
        int prevSel = selected;
        selected = cell;
        repaint((prevSel%numCols())*cellsize,(prevSel/numCols())*cellsize, cellsize, cellsize, false);
        repaint(col*cellsize,row*cellsize, cellsize, cellsize, false);
        //updateCell( prevSel/numCols(), prevSel%numCols(), FALSE );
        //updateCell( row, col, FALSE );
      }

      break;
    }
    default:
      break;
  }
  emit changed(QPixmap(p));
  //emit colorschanged(numColors(), data());
}
コード例 #14
0
ファイル: kicongrid.cpp プロジェクト: kthxbyte/KDE1-Linaro
void KIconEditGrid::mouseMoveEvent( QMouseEvent *e )
{
  if(!e)
    return;

  int row = findRow( e->pos().y() );
  int col = findCol( e->pos().x() );
  int cell = row * numCols() + col;

  QPoint tmpp(col, row);
  if(tmpp == end)
    return;

  if(img->valid(col, row))
  {
    //debug("%d X %d", col, row);
    emit poschanged(col, row);
    emit xposchanged((col*scaling())+scaling()/2); // for the rulers
    emit yposchanged((row*scaling())+scaling()/2);
  }

  if(ispasting && !btndown && img->valid(col, row))
  {
    if( (col + cbsize.width()) > (numCols()-1) )
      insrect.setX(numCols()-insrect.width());
    else
      insrect.setX(col);
    if( (row + cbsize.height()) > (numRows()-1) )
      insrect.setY(numRows()-insrect.height());
    else
      insrect.setY(row);
    insrect.setSize(cbsize);
    //debug("Moving: %d x %d", insrect.width(), insrect.height());
    start = insrect.topLeft();
    end = insrect.bottomRight();
    drawRect(false);
    return;
  }

  if(!img->valid(col, row) || !btndown)
    return;

  end.setX(col);
  end.setY(row);

  if(isselecting)
  {
    if(tool == SelectRect)
      drawRect(false);
    else
      drawEllipse(false);
    return;
  }

  switch( tool )
  {
    case Eraser:
      currentcolor = TRANSPARENT;
    case Freehand:
    {
      setColor( cell, currentcolor );
  //img.setPixel(col, row, currentcolor.pixel());

      if ( selected != cell )
      {
        modified = true;
        int prevSel = selected;
        selected = cell;
        repaint((prevSel%numCols())*cellsize,(prevSel/numCols())*cellsize, cellsize, cellsize, false);
        repaint(col*cellsize,row*cellsize, cellsize, cellsize, false);
        //updateCell( prevSel/numCols(), prevSel%numCols(), FALSE );
        //updateCell( row, col, FALSE );
        *((uint*)img->scanLine(row) + col) = (colorAt(cell));
      }
      break;
    }
    case Find:
    {
      iconcolors.closestMatch(colorAt(cell));
      if ( selected != cell )
      {
        int prevSel = selected;
        selected = cell;
        repaint((prevSel%numCols())*cellsize,(prevSel/numCols())*cellsize, cellsize, cellsize, false);
        repaint(col*cellsize,row*cellsize, cellsize, cellsize, false);
        //updateCell( prevSel/numCols(), prevSel%numCols(), FALSE );
        //updateCell( row, col, FALSE );
      }
      break;
    }
    case Ellipse:
    case Circle:
    case FilledEllipse:
    case FilledCircle:
    {
      drawEllipse(false);
      break;
    }
    //case Select:
    case FilledRect:
    case Rect:
    {
      drawRect(false);
      break;
    }
    case Line:
    {
      drawLine(false);
      break;
    }
    case Spray:
    {
      drawSpray(QPoint(col, row));
      modified = true;
      break;
    }
    default:
      break;
  }

  p = *img;

  emit changed(QPixmap(p));
  //emit colorschanged(numColors(), data());
}
コード例 #15
0
ファイル: inputGUI.cpp プロジェクト: gbl08ma/utilities
int doTextInput(textInput* input) {
  if(input->type==INPUTTYPE_NORMAL) {
    drawFkeyLabels(-1, -1, -1, (input->symbols? 0x02A1 : -1), 0x0307); // CHAR, A<>a
  }
  int wasInClip=0;
  if (input->key)
    input->cursor = EditMBStringChar((unsigned char*)input->buffer, input->charlimit, input->cursor,
                                     input->key);
  int widthForSyscalls = input->width;
  if(input->width == 21) {
    widthForSyscalls = 20;
    clearLine(1, input->y); // remove aestethically unpleasing bit of background at the end of the field
  }
  while(1) {
    if(input->forcetext && strlen(input->buffer)==0) {
      input->buffer[0]='\xd8';
      input->buffer[1]='\x0';
    }
    DisplayMBString2(0, (unsigned char*)input->buffer, input->start, input->cursor, 0, input->x,
                     input->y*24-24, widthForSyscalls+input->x, input->width==21? 0 : 1);
    
    drawLine(input->x*18-18, input->y*24-1,
             input->width == 21 ? LCD_WIDTH_PX-1 : input->width*18+input->x*18-18-1,
             input->y*24-1, COLOR_GRAY);
    drawLine(input->x*18-18, input->y*24+23,
             input->width == 21 ? LCD_WIDTH_PX-1 : input->width*18+input->x*18-18-1,
             input->y*24+23, COLOR_GRAY);
    if(input->width != 21) {
      //vertical lines, start and end
      drawLine(input->x*18-18, input->y*24-1, input->x*18-18, input->y*24+23, COLOR_GRAY);
      drawLine((input->x*18-18)+18*input->width,
               input->y*24-1, (input->x*18-18)+18*input->width, input->y*24+23, COLOR_GRAY);
    }
    if(input->type==INPUTTYPE_DATE) {
      //vertical lines: dd, mm and yyyy separators
      switch(getSetting(SETTING_DATEFORMAT)) {
        case 0:
        case 1:
          drawLine((input->x*18-18)+18*2, input->y*24-1,
                   (input->x*18-18)+18*2, input->y*24+22, COLOR_GRAY);
          drawLine((input->x*18-18)+18*4+1, input->y*24-1,
                   (input->x*18-18)+18*4+1, input->y*24+23, COLOR_GRAY);
          break;
        case 2:
          drawLine((input->x*18-18)+18*4, input->y*24-1,
                   (input->x*18-18)+18*4, input->y*24+22, COLOR_GRAY);
          drawLine((input->x*18-18)+18*6+1, input->y*24-1,
                   (input->x*18-18)+18*6+1, input->y*24+23, COLOR_GRAY);
          break;
      }
    } else if(input->type==INPUTTYPE_TIME) {
      //vertical lines: hh, mm and ss separators
      drawLine((input->x*18-18)+18*2, input->y*24-1,
               (input->x*18-18)+18*2, input->y*24+23, COLOR_GRAY);
      drawLine((input->x*18-18)+18*4, input->y*24-1,
               (input->x*18-18)+18*4, input->y*24+23, COLOR_GRAY);
    }
    int keyflag = GetSetupSetting( (unsigned int)0x14);
    if(input->type==INPUTTYPE_NORMAL) {
      if(keyflag == 0x02) {
        // in clip mode
        wasInClip=1;
        drawFkeyLabels(0x0034, 0x0069); // COPY (white), CUT (white)
      } else if(wasInClip) {
        // clear, because we were in clip mode before
        wasInClip=0;
        drawFkeyLabels(0,0); // empty first two
      }
    }
    mGetKey(&input->key);
    if (GetSetupSetting((unsigned int)0x14) == 0x01 ||
        GetSetupSetting((unsigned int)0x14) == 0x04 ||
        GetSetupSetting( (unsigned int)0x14) == 0x84) {
      keyflag = GetSetupSetting( (unsigned int)0x14); // make sure the flag we're using is the
      // updated one. we can't update always because that way alpha-not-lock will cancel when F5 is
      // pressed.
    }
    if(input->key == KEY_CTRL_EXE || (input->key == KEY_CTRL_F6 && input->acceptF6)) {
      // Next step
      if(!input->forcetext || (strlen((char*)input->buffer) > 0 && input->buffer[0]!='\xd8')) {
        // input can be empty, or it already has some text
        Cursor_SetFlashOff(); return INPUT_RETURN_CONFIRM;
      } else {
        mMsgBoxPush(4);
        multiPrintXY(3, 2, "Field can't be\nleft blank.",
                     TEXT_MODE_TRANSPARENT_BACKGROUND, TEXT_COLOR_BLACK);
        closeMsgBox();
      }
    } else if(input->key == KEY_CTRL_EXIT) {
      // Aborted
      Cursor_SetFlashOff(); return INPUT_RETURN_EXIT;
    } else if(input->key == KEY_CTRL_F1 || input->key == KEY_CTRL_F2) {  
      Cursor_SetFlashOff(); return INPUT_RETURN_KEYCODE;
    } else if(input->key == KEY_CTRL_F4 && input->type == INPUTTYPE_NORMAL && input->symbols) {
      short character = selectCharacterAux();
      if (character)
        input->cursor = EditMBStringChar((unsigned char*)input->buffer, input->charlimit,
                                         input->cursor, character);
    } else if(input->key == KEY_CTRL_F5 && input->type == INPUTTYPE_NORMAL) {
      // switch between lower and upper-case alpha
      switch(keyflag) {
        case 0x08:
        case 0x88:
          SetSetupSetting((unsigned int)0x14, keyflag-0x04);
          continue; //do not process the key, because otherwise we will leave alpha status
        case 0x04:
        case 0x84:
          SetSetupSetting((unsigned int)0x14, keyflag+0x04);
          continue; //do not process the key, because otherwise we will leave alpha status
      }
    } 
    if(input->key && input->key < 30000) {
      if(input->type == INPUTTYPE_NORMAL ||
         (input->key >= KEY_CHAR_0 && input->key <= KEY_CHAR_9) ||
         (input->key == KEY_CHAR_DP && !input->symbols && input->type == INPUTTYPE_NUMERIC)) {
        // either a normal input, or only allow digits and eventually the decimal separator
        if ((GetSetupSetting((unsigned int)0x14) == 0x08 ||
             GetSetupSetting((unsigned int)0x14) == 0x88) &&
            input->key >= KEY_CHAR_A && input->key <= KEY_CHAR_Z) //if lowercase and key is char...
          input->key = input->key + 32; // to switch to lower-case characters

        input->cursor = EditMBStringChar((unsigned char*)input->buffer, input->charlimit,
                                         input->cursor, input->key);
      }
    } else EditMBStringCtrl2((unsigned char*)input->buffer, input->charlimit+1, &input->start,
                             &input->cursor, &input->key, input->x, input->y*24-24, 1,
                             widthForSyscalls+input->x-1 );
    if(input->key == KEY_CTRL_PASTE) {
      // at this point it will have already pasted
      int pos = strlen(input->buffer)-1;
      if(input->forcetext && pos > 0 && input->buffer[pos]=='\xd8') {
        input->buffer[pos]='\x0';
      }
    }
  }
  Cursor_SetFlashOff();
  return INPUT_RETURN_CONFIRM;
}
コード例 #16
0
ファイル: TestWidget.cpp プロジェクト: IlyaSkriblovsky/lx
void TestWidget::paint(const Rect& rect)
{
    drawLine(Point(0, 0), Point(size().w, size().h));
}
コード例 #17
0
void DebugDrawRouter::drawContactPoint( const btVector3& pointOnB, const btVector3& normalOnB,
                                        btScalar distance, int lifeTime,const btVector3& color )
{
    drawLine( pointOnB, ( pointOnB+( normalOnB/10 ) ), color );
}
コード例 #18
0
ファイル: guiTSControl.cpp プロジェクト: 1414648814/Torque3D
void GuiTSCtrl::drawLineList( const Vector<Point3F> &points, const ColorI color, F32 width )
{
   for ( S32 i = 0; i < points.size() - 1; i++ )
      drawLine( points[i], points[i+1], color, width );
}
コード例 #19
0
ファイル: sin.c プロジェクト: xnbya/comp101p
void drawPixel(int x, int y) 
{
	drawLine(x,y,x,y);
}
コード例 #20
0
ファイル: Draw Line 3.c プロジェクト: FSXAC/APSC-160-Projects
// main function
int main(void) {
	// coord of endpoints of line
	int x1 = -2, y1 = -2, x2, y2;
	char **grid;
	int isDone = 0;

	// set up dynamic memory 2D array
	grid = malloc(MAX_ROW * sizeof(char*));
	for (int row = 0; row < MAX_ROW; row++) {
		grid[row] = malloc(MAX_COL * sizeof(char));

		// add blank chars to each element
		for (int col = 0; col < MAX_COL; col++) {
			grid[row][col] = BLANK;
		}
	}

	while (not isDone) {
		// ask the user for width and height
		x2 = getint("Enter X: ");
		y2 = getint("Enter Y: ");

		// check if point is on grid
		if (inRange(x2, 0, MAX_COL) and inRange(y2, 0, MAX_ROW)) {

			// add the end points to the array
			grid[y2][x2] = DOT;

			if (x1 != -2 and y1 != -2) {
				// draw line between the two points
				drawLine(x1, y1, x2, y2, grid);
			}
			
			// add current point to previous point
			x1 = x2;
			y1 = y2;

			// display the grid
			displayGrid(grid);
		}
		else if (x2 == -1 or y2 == -1) {
			// quit
			isDone = 1;
		}
		else {
			// invalid input
			printf("XY coord not in range.\n");
		}
	}

	// end of program
	// free memory
	for (int i = 0; i < MAX_ROW; i++) {
		free(grid[i]);
	}
	free(grid);

	// end
	pause;
	return 0;
}
コード例 #21
0
ファイル: Draw.c プロジェクト: SNavleen/Paint
void Draw::drawRect(int x0, int y0, int x1, int y1){
    drawLine(x0, y0, x1, y0);
    drawLine(x0, y0, x0, y1);
    drawLine(x1, y1, x0, y1);
    drawLine(x1, y1, x1, y0);
}
コード例 #22
0
ファイル: DebugHud.cpp プロジェクト: nemyax/ArxLibertatis
void ShowFpsGraph() {
	
	ARX_PROFILE_FUNC();

	GRenderer->ResetTexture(0);

	static std::deque<float> lastFPSArray;
	lastFPSArray.push_front(1000 / arxtime.get_frame_delay());

	Vec2i windowSize = mainApp->getWindow()->getSize();
	if(lastFPSArray.size() == size_t(windowSize.x))
	{
		lastFPSArray.pop_back();
	}

	float avg = 0;
	float worst = lastFPSArray[0];

	std::vector<TexturedVertex> vertices;
	vertices.resize(lastFPSArray.size());

	const float SCALE_Y = 2.0f;

	for(size_t i = 0; i < lastFPSArray.size(); ++i)
	{
		float time = lastFPSArray[i];

		avg += lastFPSArray[i];
		worst = std::min(worst, lastFPSArray[i]);

		vertices[i].color = Color(255, 255, 255, 255).toRGBA();
		vertices[i].p.x = i;
		vertices[i].p.y = windowSize.y - (time * SCALE_Y);
		vertices[i].p.z = 1.0f;
		vertices[i].rhw = 1.0f;
	}
	avg /= lastFPSArray.size();

	EERIEDRAWPRIM(Renderer::LineStrip, &vertices[0], vertices.size());

	Color avgColor = Color::blue * 0.5f + Color::white * 0.5f;
	float avgPos = windowSize.y - (avg * SCALE_Y);
	drawLine(Vec2f(0, avgPos), Vec2f(windowSize.x, avgPos), 1.0f, Color::blue);

	Color worstColor = Color::red * 0.5f + Color::white * 0.5f;
	float worstPos = windowSize.y - (worst * SCALE_Y);
	drawLine(Vec2f(0, worstPos), Vec2f(windowSize.x, worstPos), 1.0f, Color::red);

	Font * font = hFontDebug;
	float lineOffset = font->getLineHeight() + 2;

	std::string labels[3] = { "Average: ", "Worst: ", "Current: " };
	Color colors[3] = { avgColor, worstColor, Color::white };
	float values[3] = { avg, worst, lastFPSArray[0] };

	std::string texts[3];
	float widths[3];
	static float labelWidth = 0.f;
	static float valueWidth = 0.f;
	for(size_t i = 0; i < 3; i++) {
		// Format value
		std::ostringstream oss;
		oss << std::fixed << std::setprecision(2) << values[i] << " FPS";
		texts[i] = oss.str();
		// Calculate widths (could be done more efficiently for monospace fonts...)
		labelWidth = std::max(labelWidth, float(font->getTextSize(labels[i]).x));
		widths[i] = font->getTextSize(texts[i]).x;
		valueWidth = std::max(valueWidth, widths[i]);
	}

	float x = 10;
	float y = 10;
	float xend = x + labelWidth + 10 + valueWidth;
	for(size_t i = 0; i < 3; i++) {
		font->draw(Vec2i(x, y), labels[i], Color::gray(0.8f));
		font->draw(Vec2i(xend - widths[i], y), texts[i], colors[i]);
		y += lineOffset;
	}

}
コード例 #23
0
ファイル: MultiMolDraw2D.cpp プロジェクト: iwatobipen/rdkit
void MolDraw2D::doContinuousHighlighting(
    const ROMol &mol, const vector<int> *highlight_atoms,
    const vector<int> *highlight_bonds,
    const map<int, DrawColour> *highlight_atom_map,
    const map<int, DrawColour> *highlight_bond_map,
    const std::map<int, double> *highlight_radii) {
  int orig_lw = lineWidth();
  int tgt_lw = lineWidth() * 8;
  // try to scale lw to reflect the overall scaling:
  tgt_lw = max(
      orig_lw * 2,
      min(tgt_lw,
          (int)(scale_ / 25. * tgt_lw)));  // the 25 here is extremely empirical
  bool orig_fp = fillPolys();
  ROMol::VERTEX_ITER this_at, end_at;
  if (highlight_bonds) {
    boost::tie(this_at, end_at) = mol.getVertices();
    while (this_at != end_at) {
      int this_idx = mol[*this_at]->getIdx();
      ROMol::OEDGE_ITER nbr, end_nbr;
      boost::tie(nbr, end_nbr) = mol.getAtomBonds(mol[*this_at].get());
      while (nbr != end_nbr) {
        const Bond* bond = mol[*nbr];
        ++nbr;
        int nbr_idx = bond->getOtherAtomIdx(this_idx);
        if (nbr_idx < static_cast<int>(at_cds_.size()) && nbr_idx > this_idx) {
          if (std::find(highlight_bonds->begin(), highlight_bonds->end(),
                        bond->getIdx()) != highlight_bonds->end()) {
            DrawColour col = drawOptions().highlightColour;
            if (highlight_bond_map &&
                highlight_bond_map->find(bond->getIdx()) !=
                    highlight_bond_map->end()) {
              col = highlight_bond_map->find(bond->getIdx())->second;
            }
            setLineWidth(tgt_lw);
            Point2D at1_cds = at_cds_[this_idx];
            Point2D at2_cds = at_cds_[nbr_idx];
            drawLine(at1_cds, at2_cds, col, col);
          }
        }
      }
      ++this_at;
    }
  }
  if (highlight_atoms) {
    boost::tie(this_at, end_at) = mol.getVertices();
    while (this_at != end_at) {
      int this_idx = mol[*this_at]->getIdx();
      if (std::find(highlight_atoms->begin(), highlight_atoms->end(),
                    this_idx) != highlight_atoms->end()) {
        DrawColour col = drawOptions().highlightColour;
        if (highlight_atom_map &&
            highlight_atom_map->find(this_idx) != highlight_atom_map->end()) {
          col = highlight_atom_map->find(this_idx)->second;
        }
        Point2D p1 = at_cds_[this_idx];
        Point2D p2 = at_cds_[this_idx];
        double radius = 0.4;
        if (highlight_radii &&
            highlight_radii->find(this_idx) != highlight_radii->end()) {
          radius = highlight_radii->find(this_idx)->second;
        }
        Point2D offset(radius, radius);
        p1 -= offset;
        p2 += offset;
        setColour(col);
        setFillPolys(true);
        setLineWidth(1);
        drawEllipse(p1, p2);
      }
      ++this_at;
    }
  }
  setLineWidth(orig_lw);
  setFillPolys(orig_fp);
}
コード例 #24
0
ファイル: ThickLine.cpp プロジェクト: KeWei423/Graphics
void ThickLine::draw(RenderWindow &window)
{
	//window.draw(VA) ;
	drawLine(window) ;
}
コード例 #25
0
static void drawDebugPathFinding() {
	
	if(!ACTIVEBKG || !ACTIVEBKG->anchors) {
		return;
	}
	
	const float zbias = 0.00001f;
	
	for(long i = 0; i < ACTIVEBKG->nbanchors; i++) {
		
		const ANCHOR_DATA & node = ACTIVEBKG->anchors[i];
		
		Color color1 = (node.flags & ANCHOR_FLAG_BLOCKED) ? Color::blue : Color::green;
		for(long j = 0; j < node.nblinked; j++) {
			long k = node.linked[j];
			if(k >= 0 && k < ACTIVEBKG->nbanchors && i < k) {
				const ANCHOR_DATA & other = ACTIVEBKG->anchors[k];
				Color color2 = (other.flags & ANCHOR_FLAG_BLOCKED) ? Color::blue : Color::green;
				drawLine(node.pos, other.pos, color1, color2, zbias);
			}
		}
		
		if(node.height != 0.f) {
			Vec3f toppos = node.pos + Vec3f(0.f, node.height, 0.f);
			drawLine(node.pos, toppos, Color::blue, zbias);
		}
		
	}
	
	// Highlight active paths
	for(size_t i = 1; i < entities.size(); i++) {
		const EntityHandle handle = EntityHandle(i);
		const Entity * entity = entities[handle];
		
		if(!entity || !(entity->ioflags & IO_NPC)) {
			continue;
		}
		const IO_PATHFIND & pathfind = entity->_npcdata->pathfind;
		if(pathfind.listnb <= 0 || !pathfind.list) {
			continue;
		}
		
		// Draw visited nodes yellow and target nodes as red
		for(long j = 1; j < pathfind.listnb; j++) {
			short k0 = pathfind.list[j - 1], k1 = pathfind.list[j];
			if(k0 >= 0 && k0 < ACTIVEBKG->nbanchors && k1 >= 0 && k1 < ACTIVEBKG->nbanchors) {
				const ANCHOR_DATA & n0 = ACTIVEBKG->anchors[k0], & n1 = ACTIVEBKG->anchors[k1];
				Color color0 = (j     <= pathfind.listpos) ? Color::yellow : Color::red;
				Color color1 = (j + 1 <= pathfind.listpos) ? Color::yellow : Color::red;
				drawLine(n0.pos, n1.pos, color0, color1, 2.f * zbias);
			}
		}
		
		// Highlight end nodes
		short k0 = pathfind.list[pathfind.listnb - 1];
		if(k0 >= 0 && k0 < ACTIVEBKG->nbanchors) {
			Anglef angle(0.f, 0.f, 0.f);
			Vec3f scale(0.5f);
			RenderMaterial mat;
			mat.setBlendType(RenderMaterial::Opaque);
			mat.setDepthTest(true);
			
			Draw3DObject(g_nodeObject, angle, ACTIVEBKG->anchors[k0].pos, scale, Color3f::white, mat);
		}
		
		// Show entity ID at the active node
		if(pathfind.listpos < pathfind.listnb) {
			short k1 = pathfind.list[pathfind.listpos];
			if(k1 >= 0 && k1 < ACTIVEBKG->nbanchors) {
				if(closerThan(ACTIVEBKG->anchors[k1].pos, player.pos, DebugTextMaxDistance)) {
					drawTextAt(hFontDebug, ACTIVEBKG->anchors[k1].pos, entity->idString());
					GRenderer->SetRenderState(Renderer::DepthTest, true);
				}
			}
		}
		
	}
	
}
コード例 #26
0
/**
 * Draws an arc on apple. 
 *
 * @param cx center in x
 * @param cy center in y
 * @param radius Radius
 * @param a1 Angle 1 in rad
 * @param a2 Angle 2 in rad
 * @param reversed true: clockwise, false: counterclockwise
 */
void RS_PainterQt::drawArcMac(const RS_Vector& cp, double radius,
                           double a1, double a2,
                           bool reversed) {
	RS_DEBUG->print("RS_PainterQt::drawArcMac");
    if(radius<=0.5) {
        drawGridPoint(cp);
    } else {
        //QPointArray pa;
        //createArc(pa, cp, radius, a1, a2, reversed);

              double cix;            // Next point on circle
              double ciy;            //
              double aStep;         // Angle Step (rad)
              double a;             // Current Angle (rad)
			  double ox;
			  double oy;

              if(2.0/radius<=1.0) {
                  aStep=asin(2.0/radius);
              } else {
                  aStep=1.0;
              }

              if (aStep<0.05) {
                  aStep = 0.05;
              }

              //QPointArray pa;
              //int i=0;
              //pa.resize(i+1);
              //pa.setPoint(i++, toScreenX(cp.x+cos(a1)*radius),
              //            toScreenY(cp.y-sin(a1)*radius));
              //moveTo(toScreenX(cp.x+cos(a1)*radius),
              //       toScreenY(cp.y-sin(a1)*radius));
              ox = cp.x+cos(a1)*radius;
              oy = cp.y-sin(a1)*radius;
              if(!reversed) {
                  // Arc Counterclockwise:
                  if(a1>a2-1.0e-10) {
                      a2+=2*M_PI;
                  }
                  for(a=a1+aStep; a<=a2; a+=aStep) {
                      cix = cp.x+cos(a)*radius;
                      ciy = cp.y-sin(a)*radius;
                      //lineTo(cix, ciy);
					  drawLine(RS_Vector(ox, oy), RS_Vector(cix, ciy));
					  ox = cix;
					  oy = ciy;
                      //pa.resize(i+1);
                      //pa.setPoint(i++, cix, ciy);
                  }
              } else {
                  // Arc Clockwise:
                  if(a1<a2+1.0e-10) {
                      a2-=2*M_PI;
                  }
                  for(a=a1-aStep; a>=a2; a-=aStep) {
                      cix = cp.x+cos(a)*radius;
                      ciy = cp.y-sin(a)*radius;
                      drawLine(RS_Vector(ox, oy), RS_Vector(cix, ciy));
					  ox = cix;
					  oy = ciy;
					  //lineTo(cix, ciy);
                      //pa.resize(i+1);
                      //pa.setPoint(i++, cix, ciy);
                  }
              }
              drawLine(RS_Vector(ox, oy), 
			  		RS_Vector(cp.x+cos(a2)*radius,
                     cp.y-sin(a2)*radius));
              //lineTo(toScreenX(cp.x+cos(a2)*radius),
              //       toScreenY(cp.y-sin(a2)*radius));
              //pa.resize(i+1);
              //pa.setPoint(i++,
              //            toScreenX(cp.x+cos(a2)*radius),
              //            toScreenY(cp.y-sin(a2)*radius));
        //drawPolyline(pa);
    }
}
コード例 #27
0
void VoodooGraphics::drawLine(int x1, int y1, int x2, int y2)
{
    drawLine(x1, y1, x2, y2, color);
}
コード例 #28
0
ファイル: lua_test_bindings.cpp プロジェクト: AomXD/workspace
void DrawNode3D::drawCube(Vec3* vertices, const Color4F &color)
{
    // front face
    drawLine(vertices[0], vertices[1], color);
    drawLine(vertices[1], vertices[2], color);
    drawLine(vertices[2], vertices[3], color);
    drawLine(vertices[3], vertices[0], color);
    
    // back face
    drawLine(vertices[4], vertices[5], color);
    drawLine(vertices[5], vertices[6], color);
    drawLine(vertices[6], vertices[7], color);
    drawLine(vertices[7], vertices[4], color);
    
    // edge
    drawLine(vertices[0], vertices[7], color);
    drawLine(vertices[1], vertices[6], color);
    drawLine(vertices[2], vertices[5], color);
    drawLine(vertices[3], vertices[4], color);
}
コード例 #29
0
ファイル: display_func.cpp プロジェクト: ricann/gwmonitor
void ShowObject::dealShowVideo(){
//    ////debug
//    if(camera_no==2)
//        cout<<"show_thread_"<<camera_no<<" is running! ID : "<<QThread::currentThreadId()<<endl;

    int frameFinished = 0;
    int decode = 0;

    int dataLength = 0;
    char *showData = NULL;

        switch(camera_no){
        case 1:
            if(fullShow0.tryAcquire(1,0)){
                pFrameNoNow = showBuf0[nextGetShow0].frameNo;
                dataLength = showBuf0[nextGetShow0].size;
                showData = (char*)malloc((dataLength+1)*sizeof(char));
                memcpy(showData, showBuf0[nextGetShow0].h264node, dataLength);
                showData[dataLength] = '\0';

                emptyShow0.release();

                nextGetShow0++;
                nextGetShow0 %= MAX_BUF_SIZE;
            }

            break;

        case 2:
            if(fullShow1.tryAcquire(1,0)){
                pFrameNoNow = showBuf1[nextGetShow1].frameNo;
                dataLength = showBuf1[nextGetShow1].size;
                showData = (char*)malloc((dataLength+1)*sizeof(char));
                memcpy(showData, showBuf1[nextGetShow1].h264node, dataLength);
                showData[dataLength] = '\0';

                emptyShow1.release();

                nextGetShow1++;
                nextGetShow1 %= MAX_BUF_SIZE;
            }

            break;

        case 3:
            if(fullShow2.tryAcquire(1,0)){
                pFrameNoNow = showBuf2[nextGetShow2].frameNo;
                dataLength = showBuf2[nextGetShow2].size;
                showData = (char*)malloc((dataLength+1)*sizeof(char));
                memcpy(showData, showBuf2[nextGetShow2].h264node, dataLength);
                showData[dataLength] = '\0';

                emptyShow2.release();

                nextGetShow2++;
                nextGetShow2 %= MAX_BUF_SIZE;
            }

            break;

        case 4:
            if(fullShow3.tryAcquire(1,0)){
                pFrameNoNow = showBuf3[nextGetShow3].frameNo;
                dataLength = showBuf3[nextGetShow3].size;
                showData = (char*)malloc((dataLength+1)*sizeof(char));
                memcpy(showData, showBuf3[nextGetShow3].h264node, dataLength);
                showData[dataLength] = '\0';

                emptyShow3.release();

                nextGetShow3++;
                nextGetShow3 %= MAX_BUF_SIZE;
            }

            break;

        case 5:
            if(fullShow4.tryAcquire(1,0)){
                pFrameNoNow = showBuf4[nextGetShow4].frameNo;
                dataLength = showBuf4[nextGetShow4].size;
                showData = (char*)malloc((dataLength+1)*sizeof(char));
                memcpy(showData, showBuf4[nextGetShow4].h264node, dataLength);
                showData[dataLength] = '\0';

                emptyShow4.release();

                nextGetShow4++;
                nextGetShow4 %= MAX_BUF_SIZE;
            }

            break;

        case 6:
            if(fullShow5.tryAcquire(1,0)){
                pFrameNoNow = showBuf5[nextGetShow5].frameNo;
                dataLength = showBuf5[nextGetShow5].size;
                showData = (char*)malloc((dataLength+1)*sizeof(char));
                memcpy(showData, showBuf5[nextGetShow5].h264node, dataLength);
                showData[dataLength] = '\0';

                emptyShow5.release();

                nextGetShow5++;
                nextGetShow5 %= MAX_BUF_SIZE;
            }

            break;

        case 7:
            if(fullShow6.tryAcquire(1,0)){
                pFrameNoNow = showBuf6[nextGetShow6].frameNo;
                dataLength = showBuf6[nextGetShow6].size;
                showData = (char*)malloc((dataLength+1)*sizeof(char));
                memcpy(showData, showBuf6[nextGetShow6].h264node, dataLength);
                showData[dataLength] = '\0';

                emptyShow6.release();

                nextGetShow6++;
                nextGetShow6 %= MAX_BUF_SIZE;
            }

            break;

        case 8:
            if(fullShow7.tryAcquire(1,0)){
                pFrameNoNow = showBuf7[nextGetShow7].frameNo;
                dataLength = showBuf7[nextGetShow7].size;
                showData = (char*)malloc((dataLength+1)*sizeof(char));
                memcpy(showData, showBuf7[nextGetShow7].h264node, dataLength);
                showData[dataLength] = '\0';

                emptyShow7.release();

                nextGetShow7++;
                nextGetShow7 %= MAX_BUF_SIZE;
            }

            break;

        case 9:
            if(fullShow8.tryAcquire(1,0)){
                pFrameNoNow = showBuf8[nextGetShow8].frameNo;
                dataLength = showBuf8[nextGetShow8].size;
                showData = (char*)malloc((dataLength+1)*sizeof(char));
                memcpy(showData, showBuf8[nextGetShow8].h264node, dataLength);
                showData[dataLength] = '\0';

                emptyShow8.release();

                nextGetShow8++;
                nextGetShow8 %= MAX_BUF_SIZE;
            }

            break;

        case 10:
            if(fullShow9.tryAcquire(1,0)){
                pFrameNoNow = showBuf9[nextGetShow9].frameNo;
                dataLength = showBuf9[nextGetShow9].size;
                showData = (char*)malloc((dataLength+1)*sizeof(char));
                memcpy(showData, showBuf9[nextGetShow9].h264node, dataLength);
                showData[dataLength] = '\0';

                emptyShow9.release();

                nextGetShow9++;
                nextGetShow9 %= MAX_BUF_SIZE;
            }

            break;

        default:
            break;
        }

        if(!timer.isActive()){
            timer.start(10 * 1000);
        }
        else{
            timer.stop();
            timer.start(10 * 1000);
        }

        if(yuv_debug){
            if(pFrameNoNext == 1){//当发送端不停顿但接收端重启时,防止因填充帧使程序阻塞在此处
                pFrameNoNext = pFrameNoNow;
            }
            else if(pFrameNoNext < pFrameNoNow){
                if(!yuv_file){
                    char fileName[10];
                    memset(fileName, 0, 10);
                    sprintf(fileName, "%d", fileNum);

                    char yuv_file_name[30];
                    memset(yuv_file_name, 0, 30);
                    sprintf(yuv_file_name, "%d", camera_no);
                    strcat(yuv_file_name, "_");
                    strcat(yuv_file_name, fileName);
                    strcat(yuv_file_name, ".yuv");

                    yuv_file = fopen(yuv_file_name, "wb");
                }

                //initialize buffer
                char k_yuv[(480*272)+(480*272)/2];
                memset(k_yuv, 255, (480*272)+(480*272)/2);

                //make up lost_frames
                for(int i = pFrameNoNext; i < pFrameNoNow; i++){
                    fwrite(k_yuv, 1, (480*272)+(480*272)/2, yuv_file);
                    fflush(yuv_file);
                }
            }
        }

        if(showData){
            decode = avcodec_decode_video(pCodecCtxT, pFrame, &frameFinished,(const unsigned char*)showData, dataLength);
            free(showData);
            showData = NULL;
        }


        if(frameFinished > 0){

            //////retore video data after 264-decoder///////
            if(yuv_debug){
                if(!yuv_file){
                    char fileName[10];
                    memset(fileName, 0, 10);
                    sprintf(fileName, "%d", fileNum);

                    char yuv_file_name[30];
                    memset(yuv_file_name, 0, 30);
                    sprintf(yuv_file_name, "%d", camera_no);
                    strcat(yuv_file_name, "_");
                    strcat(yuv_file_name, fileName);
                    strcat(yuv_file_name, ".yuv");

                    yuv_file = fopen(yuv_file_name, "wb");
                }

                int xx, yy, zz;
                char g_yuv[(480*272)+(480*272)/2];

                for(xx=0;xx<pCodecCtxT->height;xx++)
                    memcpy(g_yuv+pCodecCtxT->width*xx, pFrame->data[0]+pFrame->linesize[0]*xx,pCodecCtxT->width);
                for(yy=0;yy<pCodecCtxT->height/2;yy++)
                    memcpy(g_yuv+pCodecCtxT->width*xx+pCodecCtxT->width/2*yy,pFrame->data[1]+pFrame->linesize[1]*yy,pCodecCtxT->width/2);
                for(zz=0;zz<pCodecCtxT->height/2;zz++)
                    memcpy(g_yuv+pCodecCtxT->width*xx+pCodecCtxT->width/2*yy+pCodecCtxT->width/2*zz, pFrame->data[2]+pFrame->linesize[2]*zz, pCodecCtxT->width/2);

                fwrite(g_yuv, 1, (480*272)+(480*272)/2, yuv_file);
                fflush(yuv_file);

            }

            SDL_LockYUVOverlay(bmp);
            pict.data[0] = bmp->pixels[0];
            pict.data[1] = bmp->pixels[2];
            pict.data[2] = bmp->pixels[1];

            pict.linesize[0] = bmp->pitches[0];
            pict.linesize[1] = bmp->pitches[2];
            pict.linesize[2] = bmp->pitches[1];

            sws_scale(img_convert_ctx, pFrame->data, pFrame->linesize, 0, pCodecCtxT->height, pict.data, pict.linesize);
            SDL_UnlockYUVOverlay(bmp);

            screen = SDL_SetVideoMode(ww, hh, 0, SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_DOUBLEBUF);


                switch(win_no){
                case 1:
                    dst.x = 0;
                    dst.y = 0;
                    dst.w =(ww-5)/2;
                    dst.h =(hh-5)/2;
                    break;
                case 2:
                    dst.x = (ww+5)/2;
                    dst.y = 0;
                    dst.w = (ww-5)/2;
                    dst.h = (hh-5)/2;
                    break;
                case 3:
                    dst.x = 0;
                    dst.y = (hh+5)/2;
                    dst.w = (ww-5)/2;
                    dst.h = (hh-5)/2;
                    break;
                case 4:
                    dst.x = (ww+5)/2;
                    dst.y = (hh+5)/2;
                    dst.w = (ww-5)/2;
                    dst.h = (hh-5)/2;
                    break;
                default:
                    break;
                }
        }

        else if(decode <= 0){
           cout<<"frameFinished <= 0 ; decode > 0"<<endl;
           if(yuv_debug){
                if(!yuv_file){
                    char fileName[10];
                    memset(fileName, 0, 10);
                    itoa(fileNum, fileName, 10);

                    char yuv_file_name[30];
                    memset(yuv_file_name, 0, 30);
                    itoa(camera_no, yuv_file_name, 10);
                    strcat(yuv_file_name, "_");
                    strcat(yuv_file_name, fileName);
                    strcat(yuv_file_name, ".yuv");

                    yuv_file = fopen(yuv_file_name, "wb");
                }

                char k_yuv[(480*272)+(480*272)/2];
                memset(k_yuv, 0,(480*272)+(480*272)/2);
                fwrite(k_yuv, 1, (480*272)+(480*272)/2, yuv_file);
                fflush(yuv_file);
            }
        }else
            cout<<"frameFinished <= 0 ; decode <= 0"<<endl;

        //update pFrameNo
        pFrameNoNext = pFrameNoNow + 1;

        frameFinished = 0;

        //添加函数在SDL窗口画线
        if(points.size() >= 2){
            int sWinNo,eWinNo;
            for(int i = 0;i < points.size()-1;i++) {
                int sx = points[i].x();
                int sy = points[i].y();
                sWinNo = changePointsByWinNo(sx,sy);
                int ex = points[i+1].x();
                int ey = points[i+1].y();
                eWinNo = changePointsByWinNo(ex,ey);
                if(sWinNo == eWinNo && win_no == sWinNo) {
                    drawLine(bmp,sx,sy,ex,ey);
                }
                //bresenham_line(bmp,sx,sy,ex,ey);
            }
        }

        SDL_DisplayYUVOverlay(bmp, &dst);
        SDL_PollEvent(&event_sdl);
        switch(event_sdl.type){
        case SDL_KEYDOWN:
            switch(event_sdl.key.keysym.sym){
            case SDLK_UP: break;
            case SDLK_DOWN: break;
            default: break;
            }
            cout<<"SDL_KEYDOWN"<<endl;
            break;
        case SDL_VIDEORESIZE:
            screen = SDL_SetVideoMode(event_sdl.resize.w, event_sdl.resize.h, 0,
                                      SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL);
            break;
        case SDL_QUIT:
            SDL_FreeSurface(screen);
            SDL_Quit();
            if(yuv_debug){
                if(yuv_file){
                    fclose(yuv_file);
                    yuv_file = NULL;

                    fileNum++;
                }
            }
            av_free(pFrame);
//            avcodec_close(pCodecCtx);
//            av_close_input_file(pFormatCtx);
            cout<<"event SDL_QUIT occurred"<<endl;
            exit(0);
            break;
        default:
            break;
        }
//    }
    //else
    //printf("....queue empty....\n");
}
コード例 #30
0
ファイル: OpenGLFTGLFont.cpp プロジェクト: junjie020/OpenGL
	void FTGLFontDrawingObj::drawLineWithNumAtTheEnd(const Unit3f &beg, const Unit3f &end, UINT numSize, FTFont &font)
	{
		drawLine(beg, end);
		//font.Render()
	}