当前位置: 首页>>代码示例>>C++>>正文


C++ Framebuffer::ClearScreen方法代码示例

本文整理汇总了C++中Framebuffer::ClearScreen方法的典型用法代码示例。如果您正苦于以下问题:C++ Framebuffer::ClearScreen方法的具体用法?C++ Framebuffer::ClearScreen怎么用?C++ Framebuffer::ClearScreen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Framebuffer的用法示例。


在下文中一共展示了Framebuffer::ClearScreen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(){
	system("setterm -cursor off");
	framebuffer.ClearScreen();
	framebuffer.SwapBuffers();
	set_conio_terminal_mode();
	
	vector<string> filenames;
    filenames.push_back("indomap.txt");

    //Filenames for coloring the map based on total population of each province
    vector<string> populationFile;
    populationFile.push_back("weight.txt");

    //Filenames for coloring the map
    vector<string> colorFiles;
    colorFiles.push_back("colormap.txt");    

	initMatrix();
	
	//window border
	vector<Point> windowBorder; // define 4 corner points of a window
	windowBorder.push_back((Point){0,0});
	windowBorder.push_back((Point){framebuffer.width, 0});
	windowBorder.push_back((Point){framebuffer.width, framebuffer.height});
	windowBorder.push_back((Point){0, framebuffer.height});
	
	map<string, vector<Point> > points = getPointsFromFile(filenames);
	//Mapping the population of each region with the same order
	map<string, int> populations = getIntegersFromFile(populationFile);
	//Mapping the colors of each region
	map<string, Color32 > colors = getColorsFromFile(colorFiles);

	//vector<Shape> areas;
	map<string, Shape> areas;

	Point Pmin = {0, 0};
	Point Pmax = {framebuffer.width, framebuffer.height};
	Point Pcenter = {framebuffer.width/2, framebuffer.height/2};
	//Shape res = Pclip(shape3, Pmin, Pmax);

	for(map<string, vector<Point>>::iterator it=points.begin(); it!=points.end(); it++){
		vector<Point> Pol = it->second;
		string str = it->first;
	
		Shape s(Pol);
		s.setCentroid(Pcenter);
		Shape sclip = Pclip(s, Pmin, Pmax);
		//s.draw(&framebuffer, WHITE);
		sclip.draw(&framebuffer, WHITE);
		sclip.fill(colors[it->first], &framebuffer, windowBorder);
		//areas.push_back(s); // add new area
		areas[str] = s;
		//areas[str] = sclip;
	}
	printf("area size %d\n", areas.size());	

	// fill areas
	// for(int i=0; i<areas.size(); i++){
	// 	//areas[i].fill(WHITE, &framebuffer, windowBorder);
	// }
	framebuffer.SwapBuffers();

	map<string, Shape>::iterator it2=areas.begin();
	map<string, int>::iterator mapPopulation = populations.begin();

	it2->second.fill(getAreaColour(mapPopulation->second), &framebuffer, windowBorder);
	int x = (it2->second.xmax + it2->second.xmin) / 2;
	int y = (it2->second.ymax + it2->second.ymin) / 2;
	framebuffer.DrawString("X", x, y, 1, BLACK);
	printLabel(it2->first, to_string(mapPopulation->second) + " penduduk");

	framebuffer.SwapBuffers();

	int dx = 10;
	int dy = 10;
	float sf = 0.1; // scaling factor
	float deg = 15.0; // degree of rotation
	bool debugMode = false;

	while(1){
		if(kbhit()){
			// cout << "area highlighted before : " << it2->first << endl;
			char c = getch();

			if(c == 'h'){ //fill next area
				if (next(it2) != areas.end()) {
					removeLabel(it2->first, to_string(mapPopulation->second) + " penduduk");
					
					it2->second.unfill(colors[it2->first], &framebuffer, windowBorder);
					it2->second.draw(&framebuffer, WHITE);
					it2++; mapPopulation++;
					it2->second.fill(getAreaColour(mapPopulation->second), &framebuffer, windowBorder);
					x = (it2->second.xmax + it2->second.xmin) / 2;
					y = (it2->second.ymax + it2->second.ymin) / 2;
					framebuffer.DrawString("X", x, y, 1, BLACK);
					printLabel(it2->first, to_string(mapPopulation->second) + " penduduk");
					framebuffer.SwapBuffers();
				}
			} 
			else if(c == 'g'){ //fill previous area
//.........这里部分代码省略.........
开发者ID:edwinwijaya94,项目名称:uts-grafika,代码行数:101,代码来源:main.cpp


注:本文中的Framebuffer::ClearScreen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。