Example #1
0
Task::Task(Project* project, const std::string taskDef) {
    qDebug("Task::Task(Project* project, std::string* taskDef)");
    _project = project;
    _totalTime = 0;
    _logs = new vector<TaskLog*>();

    hashmap* values = parseTextFormat(taskDef);

    _id = new std::string(READ_ELEMENT(values, "task-id"));
    qDebug("Loading task id: %s", _id->c_str());
    _shortDescription =  new std::string(READ_ELEMENT(values, "short-description"));
    _longDescription = new std::string(READ_ELEMENT(values, "long-description"));
    _duration = Duration(READ_ELEMENT(values, "duration").c_str());
    _startDate = new DateTime(READ_ELEMENT(values, "startdate"));
    _endDate = new DateTime(READ_ELEMENT(values, "enddate"));
    _templateName = new string(READ_ELEMENT(values, "template-name"));
    _status = new string(READ_ELEMENT(values, "status"));

    Template* tpl = readTemplate(*_templateName);
    // Check the current template existance
    if (tpl == NULL) {
        qDebug("Warning: The task with id: %s contains an invalid template: %s", _id->c_str(), _templateName->c_str());
        _templateName = defaultTemplate()->name();
        _status = new string(*defaultTemplate()->statusList().begin());
    }

    int red = randColor();
    int green = randColor();
    int blue = randColor();
    _taskColor = QColor(red, green, blue);
    _parentTask = NULL;
    delete(values);
    qDebug("out Task::Task(Project* project, std::string* taskDef)");
}
Example #2
0
void GuardianSystemDemo::UpdateBoundaryLookAndFeel()
{
    if ((uint32_t)mGlobalTimeSec % 2 == 1) {
        ovrBoundaryLookAndFeel lookAndFeel = {};
        lookAndFeel.Color = { randColor(), randColor(), randColor(), 1.0f };
        ovr_SetBoundaryLookAndFeel(mSession, &lookAndFeel);
        ovr_RequestBoundaryVisible(mSession, ovrTrue);
    }
    else {
        ovr_ResetBoundaryLookAndFeel(mSession);
        ovr_RequestBoundaryVisible(mSession, ovrFalse);
    }
}
Example #3
0
void MorphColor::reset(ColorRGB color)
{
  currentColor = startColor = color;
  endColor = randColor();
  ratio = 0.0f;
  steps = colorSpeed + rand() % colorSpeed;
}
Example #4
0
void ParseTreeLablerForm::showNbrButtonClicked()
{
    //get the text of the selected item
    const QModelIndex index = widget.treeView->selectionModel()->currentIndex();
    QString selectedText = index.data(Qt::DisplayRole).toString();
    string name = getCppString(selectedText);
        segNumToColor.clear();
        Node nd(name);
        colorMapTableModel->clearAll();
            if (nd.type == "Terminal")
            {
                set<int> & nbrs =nbrMap[nd.id];
                for(set<int>::iterator it= nbrs.begin(); it!=nbrs.end(); it++)
                {
                    float colorS=randColor();
                        segNumToColor[*it] =colorS;
                        
                        ColorRGB colorRGB(colorS);
                        colorMapTableModel->addItem(string("Terminal__")+lexical_cast<string>(*it),QColor(colorRGB.r*255,colorRGB.g*255,colorRGB.b*255));
                }
                colorSegs(segNumToColor,true);
                updatePCDVis();
                
            }
            else
            {
              QMessageBox::warning(this, tr("Parse Tree Labaler"),
                                tr("Neighbors can be shown only for a Terminal"
                                   "Please select a Terminal in the tree explorer"),
                                QMessageBox::Ok,QMessageBox::Ok);            
              return;
                
            }

 }
Example #5
0
void resetFireWork(){

    Point fireWorkColor=randColor();
    if(particals[0]){
        delete particals[0];
    }
    particals[0] = new ParticalRound();
    for(int i=0; i<NUM_OF_PARTICALS; i++){
        
        Point oo((((double) rand() / (RAND_MAX)) -0.5)/10.0, ((((double) rand() / (RAND_MAX)) -0.5)/10.0), ((((double) rand() / (RAND_MAX)) -0.5)/10.0));
        
        if((oo[0]*oo[0] + oo[1]*oo[1] + oo[2]*oo[2]) < particals[0]->getRadius()*particals[0]->getRadius()){
            if(particals[i]){
                delete particals[i];
            }
            particals[i] = new ParticalRound(oo[0], oo[1], oo[2]);
            particals[i]->setColor(fireWorkColor);
        }else{
            i--;
        }
        additionalParticals.erase(additionalParticals.begin(), additionalParticals.end());
    }
    fireWorkLocation=Point()+((double(rand()%100)/200.0)+2)*Physics::getRandomVector(Vector(0,1,0),30);
    fireWorkLocation[2]-=1.5;

}
Example #6
0
void initVector(int i){
    if(i==0){ sparkColors=rand()%ColorTransitions.size();}
    particalsVec[i]->setColor(randColor());
        particalsVec[i]->setLaunchVector(Physics::getRandomVector(Vector(1,1,0),30));
    particalsVec[i]->setLaunchVelocity(((rand()%1000)/200.0)+3);
    particalsVec[i]->colorTransitionCalc=ColorTransitions[sparkColors][rand()%ColorTransitions[sparkColors].size()];
}
Example #7
0
void AnimationEffect::reset()
{
	startFrame = m_pSettings->frame;
	for (int i = 0; i < MAX_COLORS; i++)
		palette[i] = randColor();

	start();
}
Example #8
0
Task::Task(Project* project) {
    _project = project;
    _id = NULL;
    _shortDescription = NULL;
    _longDescription = NULL;
    _startDate = NULL;
    _endDate = NULL;
    _templateName = NULL;
    _status = NULL;
    _totalTime = 0;
    _parentTask = NULL;

    _logs = new std::vector<TaskLog*>();
    int red = randColor();
    int green = randColor();
    int blue = randColor();
    _taskColor = QColor(red, green, blue);
}
Example #9
0
void buildScene4() {
	for(int x=0; x<cx; ++x)
		for(int y=0; y<cy; ++y) 
			for(int z=0; z<cz; ++z) 
				data[x][y][z] = 0;

	for(int i=0; i<cx*cy*cz>>4; ++i)
		data[rand()%cx][rand()%cy][rand()%cz] = randColor();
}
Example #10
0
void buildScene2() {
	for(int x=0; x<cx; ++x)
		for(int y=0; y<cy; ++y)
			for(int z=0; z<cz; ++z) {
				if( (x&1) & (y&1) & (z&1))
					data[x][y][z] = randColor();
				else
					data[x][y][z] = 0;
			}
}
Example #11
0
void buildScene5() {
	for(int x=0; x<cx; ++x)
		for(int y=0; y<cy; ++y)
			for(int z=0; z<cz; ++z) {
				if( (x&3)==0 && (y&3)==0 && (z&3)==0)
					data[x][y][z] = randColor();
				else
					data[x][y][z] = 0;
			}
}
Example #12
0
void buildScene1() {
	for(int x=0; x<cx; ++x)
		for(int y=0; y<cy; ++y)
			for(int z=0; z<cz; ++z) {
				if( ( ((x&7)==0) && ((y&7)==0) ) || ( ((x&7)==0) && ((z&7)==0) ) || ( ((z&7)==0) && ((y&7)==0) )  )
					data[x][y][z] = randColor();
				else
					data[x][y][z] = 0;
			}
}
Example #13
0
int Paint(HDC &hdc, int width, int height) {

	int x[BN], y[BN];
	bool stop = false;
	int n = 0;
	while (stop == false) {

		if (GetAsyncKeyState(VK_ESCAPE)) {
			_getch();
			stop = true;
		}

		// Cоздаем контекст
		HDC hmemDC = CreateCompatibleDC(hdc);
		// Cоздаем битмап
		HBITMAP hbmpTarget = CreateCompatibleBitmap(hdc, width, height);
		// Выбираем битмап в контекст
		::SelectObject(hmemDC, hbmpTarget);
		//Записывает наш bmb в память
		BitBlt(hmemDC, 0, 0, width, height, hdc, 0, 0, SRCCOPY);

		for (int i = 0; i<BN; i++) {
			x[i] = rand() % width;
			y[i] = rand() % height;

			if (GetPixel(hmemDC, x[i], y[i]) == RGB(0, 0, 0)) {
				SetPixel(hdc, x[i], y[i], RGB(randColor(), randColor(), randColor()));
				n++;
			}
			else {
				SetPixel(hdc, x[i], y[i], RGB(0, 0, 0));
				n--;
			}
		}

		PText(hdc, Rate(n, width, height));
		DeleteDC(hmemDC); // контекст отжирает уйму ресурсов, поэтому не забудем его грохнуть
		DeleteObject(hbmpTarget);
		hmemDC = NULL;
		Sleep(12);
	}
	return n;
};
Example #14
0
CBox::CBox() {
	m_shape = sf::RectangleShape(sf::Vector2f(10.f,10.f));//(0,0,10,10,sf::Color(255,255,255));
    m_shape.SetOrigin(5,5);
	m_shape.SetFillColor(randColor());
	//cout << 300/PPM << " : " << -300/PPM-n*5/PPM << endl;
    m_bodyDef.position.Set(300.0f/PPM,-300.0f/PPM-n*5/PPM);
    n++;
    m_bodyDef.type = b2_dynamicBody;
    m_bodyShape.SetAsBox(5.0f/PPM,5.0f/PPM);
    m_bodyFix.shape = &m_bodyShape;
    m_bodyFix.density = 0.1f;
    m_bodyFix.friction = 0.1f;
}
Example #15
0
void buildScene3() {
	for(int x=0; x<cx; ++x)
		for(int y=0; y<cy; ++y) 
			for(int z=0; z<cz; ++z) 
				data[x][y][z] = 0;

	for(int x=0; x<cx; ++x)
		for(int y=0; y<cy; ++y) {
			data[x][y][cz-1] = randColor();
			data[x][y][0] = randColor();
		}

	for(int x=0; x<cx; ++x)
		for(int z=0; z<cz; ++z) {
			data[x][0][z] = randColor();
			data[x][cy-1][z] = randColor();
		}

	for(int y=0; y<cy; ++y)
		for(int z=0; z<cz; ++z) {
			data[cx-1][y][z] = randColor();
		}
}
Example #16
0
void printToPCLViewer(){
    pclViewer->removeAllPointClouds();
    //pcl::visualization::PointCloudColorHandlerRGBField<PointT> rgb(cloud);
    //pclViewer->addPointCloud<PointT>(cloud,rgb,"source cloud");
    //pclViewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "source cloud");
    for(int i=0; i < object_vector.size(); i++){
        pcl::PointCloud<PointT>::Ptr pc = object_vector[i];
        pcl::visualization::PointCloudColorHandlerRandom<PointT> randColor(pc);
        std::stringstream ss;
        ss << i;
        std::string ind = ss.str();
        std::string pc_name = "object_" + ind;
        pclViewer->addPointCloud<PointT>(pc,randColor,pc_name);
        pclViewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, pc_name);
    }

    pcl::visualization::PointCloudColorHandlerCustom<PointT> yellow_color(retrieved_object, 255, 255, 102);
    pclViewer->addPointCloud<PointT>(retrieved_object,yellow_color,"tracked cloud");
    pclViewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1, "tracked cloud");


    //    if(particles){
    //        pcl::PointCloud<pcl::PointXYZ>::Ptr particle_cloud (new pcl::PointCloud<pcl::PointXYZ> ());
    //        for (size_t i = 0; i < particles->points.size (); i++){
    //            pcl::PointXYZ point;
    //            point.x = particles->points[i].x;
    //            point.y = particles->points[i].y;
    //            point.z = particles->points[i].z;
    //            particle_cloud->points.push_back(point);
    //        }
    //        pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZ> red_color (particle_cloud, 255, 0, 0);
    //        pclViewer->addPointCloud<pcl::PointXYZ> (particle_cloud, red_color, "particle cloud");
    //        pclViewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 2, "particle cloud");
    //    }

    pcl::visualization::PointCloudColorHandlerCustom<PointT> centroid_color (tracked_object_centroid, 255, 0, 255);
    pclViewer->addPointCloud<PointT> (tracked_object_centroid, centroid_color, "centroid");
    pclViewer->setPointCloudRenderingProperties (pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 12, "centroid");
}
Example #17
0
std::string buildGrid(std::vector<int> &grid, int x, int y, Color &c)
{
    Random r;
    
    std::stringstream ppmData;
    // create the header
    ppmData << "P3\n" << x << " " << y << "\n255\n";
    for(int i = 0; i < 5; ++i)
    {
        c = randColor(r);
        line(grid, r.DrawNumber(0, 256), r.DrawNumber(0, 256), r.DrawNumber(0, 256), r.DrawNumber(0, 256), c);
        
        int rx = r.DrawNumber(0, 255);
        int ry = r.DrawNumber(0, 255);
        box(grid, rx, ry, r.DrawNumber(1, 256 - rx), r.DrawNumber(1, 256 - ry), c);
        
        rx = r.DrawNumber(0, 255);
        ry = r.DrawNumber(0, 255);
        solid_box(grid, rx, ry, r.DrawNumber(1, 256 - rx), r.DrawNumber(1, 256 - ry), c);
        
        rx = r.DrawNumber(55, 255);
        ry = r.DrawNumber(55, 255);
        int radius = r.DrawNumber(3, 255);
        circle(grid, rx, ry, radius, c, r.DrawBool());
    }
    
    // convert list to text file.
    for(int dy : range(0, y))
    {
        for(int dx : range(0, x))
        {
            int a, b, c;
            std::tie(a, b, c) = getPoint(grid, dx, dy);
            ppmData << " " << a << " " << b << " " << c << '\n';
        }
    }
    std::string s(ppmData.str());
    return s;
}
Example #18
0
void MainMenu::paintEvent(QPaintEvent* )
{
    setFixedSize(parentWidget()->width(),parentWidget()->height());
    QPainter painter(this);
    double w = width();
    double h = height();
    QFont font("Times");
    font.setStyleHint(QFont::Monospace);
    font.setPointSize(w/12);
    font.setBold(true);
    painter.setFont(font);
    painter.setPen(Qt::blue);
    QString str = "Flood Em!";
    for (int i = 0; i < 9; i++) {
        painter.setPen(Qt::black);
        // Drawing each letter 5 times to get our wacky outlined font
        painter.drawText((w/6 + i*2*w/27 + w/120), h/8, w/9, 3*h/4, 1, QString(str[i]));
        painter.drawText((w/6 + i*2*w/27), h/8 + w/120, w/9, 3*h/4, 1, QString(str[i]));
        painter.drawText((w/6 + i*2*w/27 - w/120), h/8, w/9, 3*h/4, 1, QString(str[i]));
        painter.drawText((w/6 + i*2*w/27), h/8 - w/120, w/9, 3*h/4, 1, QString(str[i]));
        painter.setPen(randColor().lighter(100));
        painter.drawText((w/6 + i*2*w/27), h/8, w/9, 3*h/4, 1, QString(str[i]));
    }
}
Example #19
0
void EffectText::drawLine(float xa, float ya, float xb, float yb, float width)
{
	m_pSettings->waterField->DrawLine(xa,ya,xb,yb,width,0.4f,0.5f,randColor());
}
Example #20
0
void ParseTreeLablerForm::splitButtonClicked()
{
    //get the text of the selected item
    const QModelIndex index = widget.treeView->selectionModel()->currentIndex();
    QString selectedText = index.data(Qt::DisplayRole).toString();
    string name = getCppString(selectedText);
    std::vector<pcl::PointIndices> clusters;
    Node nd(name);
    cout<<"in split seg"<<endl;
    if (nd.type == "Terminal")
    {
                        undoNames.clear();
        double radT=getValueOfType<double>(widget.radEdit->text());
        double angleT=getValueOfType<double>(widget.angleEdit->text());
        double colorT=getValueOfType<double>(widget.colorT->text());
        int numNbr=getValueOfType<int>(widget.nbrEdit->text());
        int segId = nd.id;
        pcl::PointCloud<PointT> segCloud;
        segCloud.header = cloud_orig.header;
        vector<int> originalIndices;
        undoAvl = true;
        cloud_undo=cloud_orig;
        for (int i = 0; i < (int)cloud_orig.points.size(); i++)
        {
            if ((int)cloud_orig.points[i].segment == segId)
            {
                segCloud.points.push_back(cloud_orig.points[i]);
                cloud_orig.points[i].segment=0;
                originalIndices.push_back(i);
            }
        }
        cout<<"oversegmenting this seg whihch had "<<segCloud.size()<<"with params"<<radT<<","<<angleT<<","<<numNbr<<endl;
    //    segment(segCloud, clusters,radT,angleT,numNbr,true,colorT);
        SegmentPCDGraph<PointT> segmenter(angleT,radT,numNbr,colorT,100);
        segmenter.segment(segCloud,clusters);
        sort(clusters.begin(), clusters.end(), compareSegsDecreasing);

        
        // the old segment now contains the largest segment after splitting
        segNumToColor.clear();
        segNumToColor[segId]=randColor();
        cout<<clusters.size()<<" oversegments found"<<endl;
        for (size_t i = 0; i < clusters.size(); i++)
        {
            cout<<"cluster "<<i<<"has "<<clusters[i].indices.size()<<" points\n";
            int newSegId;
            if(i==0)
            {
                newSegId=segId;
            }
            else
            {
                newSegId=(++typeMaxId["Terminal"]);
            }
            segNumToColor[newSegId]=randColor();
            for (size_t j = 0; j < clusters[i].indices.size(); j++)
            {
                cloud_orig.points[originalIndices.at(clusters[i].indices[j])].segment = newSegId;
            }
            if(i==0)
                continue;
            
            string name="Terminal__"+lexical_cast<string>(newSegId)+"__split"+lexical_cast<string>(segId);
                QStandardItem *item = new QStandardItem(name.data());
                nameToTreeNode[name] = item;
                undoNames.push_back(name);
                rootNode->appendRow(item);
            
        }
    colorSegs(segNumToColor, true);
    updatePCDVis();

              QMessageBox::warning(this, tr("Parse Tree Labaler"),
                                tr("IMPORTANT: undo operation should not be done after merging any newly created segments"
                                   "It will cause inconsistency"),
                                QMessageBox::Ok,QMessageBox::Ok);            

    }
}
void GameplayScreen::init()
{
	b2Vec2 gravity(0.0f, -50.0f);
	//create up world
	mWorld = std::make_unique<b2World>(gravity);

	//Add Ground body
	b2BodyDef groundBodyDef;
	groundBodyDef.position.Set(0.0f, -20.0f); // units of meters
	b2Body* groundBody = mWorld->CreateBody(&groundBodyDef);
	//Shape is a polygon, fixture keeps them together
	b2PolygonShape groundBox;
	groundBox.SetAsBox(50.0f, 10.0f);
	groundBody->CreateFixture(&groundBox, 0.0f);

	//Load texture
	mTexture = WebEngine::ResourceManager::getTexture("Assets/bricks_top.png");

	WebEngine::ColorRGBA8 color(255, 0, 0, 255);

	//Add a bunch of boxes
	std::mt19937 randGenerator(time(nullptr));
	std::uniform_real_distribution<float> xPos(-10.0f, 10.0f);
	std::uniform_real_distribution<float> yPos(-15.0f, 15.0f);
	std::uniform_real_distribution<float> size(0.5f, 2.5f);
	std::uniform_int_distribution<unsigned int> randColor(0, 255);
	const int numBoxes = 20;

	for (int i = 0; i < numBoxes; i++)
	{
		WebEngine::ColorRGBA8 color(randColor(randGenerator), randColor(randGenerator), randColor(randGenerator), 255);
		Box newBox;
		newBox.init(mWorld.get(), glm::vec2(xPos(randGenerator), yPos(randGenerator)), glm::vec2(size(randGenerator), size(randGenerator)), mTexture, color);
		//Box memory can be discraded because the important bits are stored in the world
		mBoxes.push_back(newBox);
	}

	//Initialize shaders
	//Compile texture shader
	mTextureProgram.compileShaders("Shaders/textureShading.vert", "Shaders/textureShading.frag");
	mTextureProgram.addAttribute("vertexPosition");
	mTextureProgram.addAttribute("vertexColor");
	mTextureProgram.addAttribute("vertexUV");
	mTextureProgram.linkShaders();
	//Compile light shader
	mLightProgram.compileShaders("Shaders/lightShading.vert", "Shaders/lightShading.frag");
	mLightProgram.addAttribute("vertexPosition");
	mLightProgram.addAttribute("vertexColor");
	mLightProgram.addAttribute("vertexUV");
	mLightProgram.linkShaders();

	mDebugRenderer.init();
	m_CameraController.init(&mCamera, mTime);
	//Initialize spritebatch
	mSpriteBatch.init();

	//Init camera
	mCamera.init(mWindow->getScreenWidth(), mWindow->getScreenHeight());
	mCamera.setScale(32.0f); //32 pixels per meter, good scale

	mPlayer.init(mWorld.get(), glm::vec2(0.0f, 30.0f), glm::vec2(1.0f), glm::vec2(0.5f, 1.0f), WebEngine::ColorRGBA8(255, 255, 255, 255));
}
Example #22
0
sf::Color getRandomColor()
{
    sf::Color randColor(rand256(), rand256(), rand256());
    return randColor;
}
Example #23
0
void ParseTreeLablerForm::selectionChangedSlot(const QItemSelection & /*newSelection*/, const QItemSelection & /*oldSelection*/)
{
    //get the text of the selected item
    const QModelIndex index = widget.treeView->selectionModel()->currentIndex();
    QString selectedText = index.data(Qt::DisplayRole).toString();
    string name = getCppString(selectedText);
    QStandardItem *parNode = nameToTreeNode[name];
    int numChildren = parNode->rowCount();
        segNumToColor.clear();
        Node nd(name);
            if (nd.type == "Terminal")
            {
                segNumToColor[nd.id] = randColor();
            }
        colorMapTableModel->clearAll();
    for (int i = 0; i < numChildren; i++)
    {
        QStandardItem *child = parNode->child(i, 0);
                        


        queue<QStandardItem *> bfsQueue;
        float color = randColor();
                        ColorRGB colorRGB(color);
                        colorMapTableModel->addItem(getCppString(child->text()),QColor(colorRGB.r*255,colorRGB.g*255,colorRGB.b*255));
        bfsQueue.push(child);
        //boost::random::uniform_int_distribution<> randSix(0,5);
        // distribution that maps to 1..6
        // see random number distributions
        while (!bfsQueue.empty())
        {
            QStandardItem *curNode = bfsQueue.front();
            bfsQueue.pop();
            int numChildren = curNode->rowCount();
            string parName = getCppString(curNode->text());
            //cout << "selseg:" << parName.substr(0, 10) << endl;
            //cout << "selseg:" << "Terminal__" << endl;
            
            Node ndp(parName);

            if (ndp.type == "Terminal")
            {

                segNumToColor[ndp.id] = color;
                continue;
            }
            
            //cout << parName << endl;

            for (int i = 0; i < numChildren; i++)
            {
                QStandardItem *child = curNode->child(i, 0);
              //  cout << "child:" << getCppString(child->text()) << endl;
                bfsQueue.push(child);
            }

        }
    }
    colorSegs(segNumToColor, true);
    updatePCDVis();
    
     
 }
Example #24
0
MorphColor::MorphColor(int speed)
{
  colorSpeed = speed;
  reset(randColor());
}
Example #25
0
void pizza(Drawer * drawer, Chart * chart, Rectangle base) {
	Color rcolor;
   float initAngle = 0.0;
	int i;
	char str[20] = "";

  for(i = 0; chart->content[i] != 0; ++i) {

		float perc = chart->content[i]->percentage;
	 
		randColor(&rcolor);//Função que randomiza os números responsáveis pelas cores
		percToText(perc*100,str);//Função que transforma a porcentagem em string

	   Arc arc = {
		
	 		 base.width/3, //x
	 		 base.height/2, //y
	 		 initAngle, //initAngle
	 		 perc*2*M_PI+initAngle, //endAngle
	 		 200,   //radius
	 		 0.5, // borderWidth
	 		 {rcolor.r, rcolor.g, rcolor.b, 1.0}, // Color Bg
	 		 {1.0,1.0,1.0, 1.0} // Color border
};
		
		Rectangle rectPerc = {
			
			 2*base.width/3, //x
	 		 4*base.height/10 + 35*i, //y
	 		 60,//width
	 		 30, //height
	 		 1.0, // borderWidth
	 		 {rcolor.r, rcolor.g, rcolor.b, 1.0}, // Color Bg
	 		 {1.0,1.0,1.0, 1.0}// Color border
};		
		

	 	Text text = {
		  	 
	 		 2*rectPerc.height/3,//Font Size
			 3*base.width/4 ,//X
			 4*base.height/10 + rectPerc.height/2,//Y
		  	 chart->content[i]->label ,//Label
			 str,//Percentage(String Form)
		  	 1.4,//BorderWidth
		    rectPerc.y - 4*base.height/10,//Space Legend
			 -5,//Space Percentage
			 2*base.width/3 + rectPerc.width/4,//Coordenada X da porcentagem
			 4*base.height/10 + rectPerc.height/2,//Coordenada Y da porcentagem
	   	 0,//Se 1 = Retangulo
	       1,//Se 1 = Arco
		  	 {0.0,0.0,0.0,1.0},//Color Bg
		  	 {rcolor.r, rcolor.g, rcolor.b, 1.0},//Color Border
		    {1.0,1.0,1.0,1.0}//Color of Percentage
};
	
	DrawerDrawRectangle(drawer, rectPerc);

		  if(perc == 1.0) {//Se o gráfico de pizza tiver somente um parâmetro (100%), excluir a borda
	      arc.border.a = 0.0;
}
        DrawerDrawArc(drawer, arc);
		  DrawerDrawText(drawer, text, base);
        initAngle += chart->content[i]->percentage*2*M_PI;
		
	}
}
Example #26
0
void barra(Drawer * drawer, Chart * chart, Rectangle base, float * aux) {//Função que desenha o Gráfico de Barras
	    
		 Color rcolor;//Declarando um parâmetro rcolor do tipo Color
	
	 
		 int i;
		 char str[20] = "";//Declarando uma string vazia

  for(i = 0; chart->content[i] != 0; ++i) {

		 float perc = chart->content[i]->percentage;

		percToText(perc*100.00,str);//Função que transforma as porcentagens em Strings
		randColor(&rcolor);//Função que randomiza os números responsáveis pelas cores

	   Rectangle rect = {

	 		 base.width/9 + (SpaceValue(chart->DatumSize)*base.width/80)*(i), //x
	 		 14*base.height/15, //y
	 		 (11*base.width/15)/chart->DatumSize,//width
	 		-perc*((11*base.height/15)/sort(aux, chart)), //height
	 		 0.0, // borderWidth
	 		{rcolor.r, rcolor.g, rcolor.b, 1.0}, // Color Bg
	 		{1.0,1.0,1.0, 1.0} // Color border
};		
		
		
		
	 	Text text = {
		  	 
	 		 15,//Font Size
			 rect.x+rect.width/2,//X
			 20*base.height/21,//Y
		  	 chart->content[i]->label ,//Label
			 str,//Percentage(String Form)
		  	 1,//BorderWidth
		    i,//Space Legend
			 0,//Space Percentage
			 1*base.width/60,//Coordenada X da porcentagem
			 19*base.height/20 + rect.height,//Coordenada Y da porcentagem
			 1,//Se 1 = Retangulo
			 0,//Se 1 = Arco
			 {0.0,0.0,0.0,1.0},//Color Bg
			 rect.bg,//Color Border
			 rect.bg//Color of Percentage
};
	
		
		  DrawerDrawRectangle(drawer, rect);
		  DrawerDrawText(drawer, text, base);
		  
}
		Axis axisy = {
	 		 
			 1*base.width/15,// Posição x0
	 		 3*base.height/18,// Posição y0
	 		 1*base.width/15,// Posição x
	 		 39*base.height/40,// Posição y
	 		 2,// Largura do Eixo
	 		 {0.0,0.0,0.0,1.0}// Cor do Eixo
};
		Axis axisx = {
	 		 
			 1*base.width/40,// Posição x0
	 		 14*base.height/15,// Posição y0
	 		 14*base.width/15,// Posição x
	 		 14*base.height/15,// Posição y
	 		 2,// Largura do Eixo
	 		 {0.0,0.0,0.0,1.0}// Cor do Eixo
};
		Arrow arrowY = {

	 		 1*base.width/15 - 5,// Posição X da ponta Direita da Seta
	 		 3*base.width/21,// Posição Y da ponta Direita da Seta
	 		 1*base.width/15 + 5,// Posição X da ponta Esquerda da Seta
	 		 3*base.width/21,// Posição Y da ponta Esquerda da Seta
	 		 axisy.x0,// Posição X de intersecção da ponta Direita com a ponta Esquerda
	 		 axisy.y0,// Posição Y de intersecção da ponta Direita com a ponta Esquerda
	 		 2,// Largura da Seta
	 		 axisy.bg//Cor da Seta
};
		Arrow arrowX = {
	 		 
			 21*base.width/23,// Posição X da ponta Direita da Seta
	 		 14*base.height/15 - 5,// Posição Y da ponta Direita da Seta
	 		 21*base.width/23 ,// Posição X da ponta Esquerda da Seta
	 		 14*base.height/15 + 5,// Posição Y da ponta Esquerda da Seta
	 		 axisx.x,// Posição X de intersecção da ponta Direita com a ponta Esquerda
	 		 axisx.y,// Posição Y de intersecção da ponta Direita com a ponta Esquerda
	 		 2,// Largura da Seta
	 		 axisx.bg//Cor da Seta
};
	
	 		 DrawerDrawArrow(drawer, axisy, arrowX);
	 		 DrawerDrawArrow(drawer, axisx, arrowY);
	 		 DrawerDrawAxis(drawer, axisx, base);
	 		 DrawerDrawAxis(drawer, axisy, base);
}		
Example #27
0
void EffectRain::apply()
{
	if (frand() < rainDensity/60.f)
		m_pSettings->waterField->SetHeight(minx+frand()*scalex,miny+frand()*scaley,0.5f+0.5f*frand(),-2.0f-frand()*2, randColor());
}
//public
void RGBElement::stateMaschine()
{

    switch(m_state)
    {
    case 0:		//OFF
    {
        m_Rnext 		= 0;
        m_Gnext 		= 0;
        m_Bnext 		= 0;
        m_brightness 	= 1;
        m_fade 			= false;

        m_sync 			= false;

        break;
    }
    case 1:		//OFF_FADE_DOWN ==> STATE 0
    {
        m_Rnext 		= 0;
        m_Gnext 		= 0;
        m_Bnext 		= 0;
        m_brightness 	= 1;
        m_fade 			= true;

        m_sync			= true;

        if(isReady())
        {
            m_state = 0;
            m_out->pDln();
            m_out->pDS("_%E");
            m_out->pD(m_id);
            m_out->pDS("_%M");
            m_out->pD(m_state);			//PROFILE/MODE
            m_out->pDln();

        }
        break;
    }
    case 2:		//ON_WHITE
    {
        m_Rnext 		= 255;
        m_Gnext 		= 255;
        m_Bnext 		= 255;
        m_brightness 	= 1;
        m_fade 			= false;

        m_sync 			= false;

        break;
    }
    case 3:		//ON_WHITE_FADE_UP  ==> STATE 2
    {
        m_Rnext 		= 255;
        m_Gnext 		= 255;
        m_Bnext 		= 255;
        m_brightness 	= 1;
        m_fade 			= true;
        m_uTime			= 5;

        m_sync 			= true;

        if(isReady())
        {
            m_state = 2;
            m_out->pDln();
            m_out->pDS("_%E");
            m_out->pD(m_id);
            m_out->pDS("_%M");
            m_out->pD(m_state);			//PROFILE/MODE
            m_out->pDln();

        }
        break;
    }
    case 4:		//SELECTED_COLOR
    {
        break;
    }
    case 5:		//NEXT_COLOR
    {
        if(m_autoNext && (m_sync || isReady()))
        {
            nextColor();
            m_out->pDS("_%E");
            m_out->pD(m_id);
            m_out->pDS("_%R");
            m_out->pD(m_Rnext);		//RED
            m_out->pDS("_%G");
            m_out->pD(m_Gnext);		//GREEN
            m_out->pDS("_%B");
            m_out->pD(m_Bnext);		//BLUE
            m_out->pDln();
        }
        break;
    }
    case 6:		//SHUFFLE_COLOR
    {
        if(m_autoNext && (m_sync || isReady()))
        {
            shuffleColor();
            m_out->pDS("_%E");
            m_out->pD(m_id);
            m_out->pDS("_%R");
            m_out->pD(m_Rnext);		//RED
            m_out->pDS("_%G");
            m_out->pD(m_Gnext);		//GREEN
            m_out->pDS("_%B");
            m_out->pD(m_Bnext);		//BLUE
            m_out->pDln();
        }
        break;
    }
    case 7:		//PART_COLORS
    {
        if(m_autoNext && (m_sync || isReady()))
        {
            partColor();
            m_out->pDS("_%E");
            m_out->pD(m_id);
            m_out->pDS("_%R");
            m_out->pD(m_Rnext);		//RED
            m_out->pDS("_%G");
            m_out->pD(m_Gnext);		//GREEN
            m_out->pDS("_%B");
            m_out->pD(m_Bnext);		//BLUE
            m_out->pDln();
        }
        break;
    }
    case 8:		//RAND_COLOR
    {
        if(m_autoNext && (m_sync || isReady()))
        {
            randColor();
            m_out->pDS("_%E");
            m_out->pD(m_id);
            m_out->pDS("_%R");
            m_out->pD(m_Rnext);		//RED
            m_out->pDS("_%G");
            m_out->pD(m_Gnext);		//GREEN
            m_out->pDS("_%B");
            m_out->pD(m_Bnext);		//BLUE
            m_out->pDln();
        }
        break;
    }
    default:	//SWTICH_OFF
    {
        m_state = 0;
    }
    }
}
Example #29
0
void PLYReader::readFromPly(
        std::vector<Object *> & scene_objects,
        const std::string & filename) {
    std::ifstream fileIn(filename);
    std::string currLine;
    getline(fileIn, currLine);
    std::cout << "cl: " << currLine << std::endl;
    assert(stringMatches(currLine, "ply"));
    getline(fileIn, currLine);
    assert(stringMatches(currLine, "format ascii 1.0"));
    std::string currWord;
    fileIn >> currWord;
    assert(stringMatches(currWord, "element"));
    fileIn >> currWord;
    assert(stringMatches(currWord, "vertex"));
    fileIn >> currWord;
    std::string::size_type sz;
    int numVertices = std::stoi(currWord, &sz);
    std::cout << "num vertices = " << numVertices << std::endl;
    getline(fileIn, currLine);
    getline(fileIn, currLine);
    assert(stringMatches(currLine, "property float x"));
    getline(fileIn, currLine);
    assert(stringMatches(currLine, "property float y"));
    getline(fileIn, currLine);
    assert(stringMatches(currLine, "property float z"));
    fileIn >> currWord;
    assert(stringMatches(currWord, "element"));
    fileIn >> currWord;
    assert(stringMatches(currWord, "face"));
    fileIn >> currWord;
    int numFaces = std::stoi(currWord, &sz);
    std::cout << "num faces = " << numFaces << std::endl;
    getline(fileIn, currLine);
    getline(fileIn, currLine);
    getline(fileIn, currLine);
    assert(stringMatches(currLine, "end_header"));
    std::vector<Vector3D> vertices;
    for (int i = 0; i < numVertices; ++i) {
        getline(fileIn, currLine);
        std::istringstream iss(currLine);
        iss >> currWord;
        auto x = std::stod(currWord, &sz);
        iss >> currWord;
        auto y = std::stod(currWord, &sz);
        iss >> currWord;
        auto z = std::stod(currWord, &sz);
        vertices.push_back(Vector3D(x, y, z));
    }
    for (int i = 0; i < numFaces; ++i) {
        getline(fileIn, currLine);
        std::istringstream iss(currLine);
        iss >> currWord;
        assert(currWord.compare("3") == 0);
        iss >> currWord;
        int iv1 = std::stoi(currWord, &sz);
        iss >> currWord;
        int iv2 = std::stoi(currWord, &sz);
        iss >> currWord;
        int iv3 = std::stoi(currWord, &sz);
        Triangle * t = new Triangle(vertices[iv1], vertices[iv2], vertices[iv3], randColor());
        scene_objects.push_back(dynamic_cast<Object *>(t));
    }
}