Пример #1
0
void Window::paintEvent(QPaintEvent * event)
{
	
	QPainter painter(this);
	painter.setBrush(Qt::lightGray);
	painter.drawRect(0, 0, size().width(), size().height());
       
	game.GetData(gamedata);
	
	for (int x = 20+MenuBarSize; x <= N*20+MenuBarSize; x += 20)
	{
		painter.drawLine(x, 20+MenuBarSize, x, N*20+MenuBarSize); 
	}
	for (int y = 20+MenuBarSize; y <= N*20+MenuBarSize; y += 20)
	{
		painter.drawLine(20+MenuBarSize, y, N*20+MenuBarSize, y);
	}
	
	for (int x = 0; x < N; x++)
	{
		for (int y = 0; y < N; y++)
		{
			if (gamedata[x][y] == 1) 
			{
				QPainter blackPainter(this);
					blackPainter.setBrush(QBrush("#004fc5"));
					blackPainter.drawEllipse((x+1)*20-10+MenuBarSize, 
						(y+1)*20-10+MenuBarSize, 20, 20);
			}
			else if (gamedata[x][y] == 2) 
			{
					QPainter whitePainter(this);
					whitePainter.setBrush(QBrush("#4c4c4c"));
					whitePainter.drawEllipse((x+1)*20-10+MenuBarSize,
						(y+1)*20-10+MenuBarSize, 20, 20);
			}
		}
	}

	QMainWindow::paintEvent(event);
}
Пример #2
0
FontOverlay::FontOverlay() {
  textLines = QMap<string,string>();
  QList<string> attributes = QList<string>();
  attributes.push_back("uv");
  shader = new VertFragProgram("Texture/texture",attributes);
  mesh = Geometry::plane(attributes, QRectF(0.5,0,0.5,1));
  attributes.clear();
//  attributes.~QList();

  screenSize = QSize(480,600);
  textBox = QRectF(0,0,screenSize.width(), screenSize.height());
  image = QImage(screenSize, QImage::Format_ARGB32);

  //clean alpha channel
  black = QImage(screenSize, QImage::Format_Mono);
  QPainter blackPainter(&black);
  blackPainter.fillRect ( textBox, Qt::black );
  blackPainter.end();

  clear();
  drawBox = QRectF(50,200,screenSize.width()-100, screenSize.height()-100);

  texture = nullptr;
}