Пример #1
0
void QBadgeLabel::drawBadge(QPainter *painter, qreal x, qreal y)
{
	QString text = QString::number(m_counter);

	int pointSize = painter->font().pointSize();
	int weight    = (pointSize < 8) ? QFont::Normal : QFont::Bold;

	if (m_radius - 4 < painter->fontMetrics().width(text)) {
		// Text not fully contained
		text = "!";
	}

	painter->setFont(QFont(painter->font().family(), pointSize, weight));

	// Draw Badge Shadow
        fillEllipse(painter, x + 1, y, m_radius, m_shadowColor);
        fillEllipse(painter, x - 1, y, m_radius, m_shadowColor);
        fillEllipse(painter, x, y + 1, m_radius, m_shadowColor);
        fillEllipse(painter, x, y - 1, m_radius, m_shadowColor);

	// Draw Badge
        painter->setPen(QPen(m_foreground, 2));
        fillEllipse(painter, x, y, m_radius - 3, m_background);
        painter->drawEllipse(x, y, m_radius - 3, m_radius - 3);

	// Draw Badge Counter Text
        painter->setPen(QPen(m_foreground, 1));
        painter->drawText(x, y,	m_radius - 2, m_radius - 2, Qt::AlignCenter, text);
}
Пример #2
0
main (void)
{
  initGraph ();

  /* 背景 */
  floodFill (320, 240, BLACK, LIGHTBLUE);
  waitButtonPress ();

  /* 頭 */
  fillEllipse (320, 250, 230, 160, WHITE);

  /* 耳 */
  fillTriangle (130, 40, 90, 250, 250, 92, WHITE);
  fillTriangle (530, 40, 530, 250, 390, 92, WHITE);
  waitButtonPress ();

  /* 目 */
  fillEllipse (200, 290, 15, 20, BLACK);
  fillEllipse (195, 282, 8, 6, WHITE);
  fillEllipse (440, 290, 15, 20, BLACK);
  fillEllipse (435, 282, 8, 6, WHITE);
  waitButtonPress ();

  /* 鼻 */
  fillEllipse (320, 330, 24, 15, YELLOW);
  fillEllipse (315, 322, 9, 6, WHITE);
  waitButtonPress ();

  /* ひげ */
  drawLine (125, 280, 40, 275, BLACK);
  drawLine (130, 300, 50, 305, BLACK);
  drawLine (140, 320, 40, 335, BLACK);

  drawLine (515, 280, 600, 275, BLACK);
  drawLine (510, 300, 590, 305, BLACK);
  drawLine (500, 320, 600, 335, BLACK);
  waitButtonPress ();

  /* リボン */
  fillTriangle (465, 160, 415, 70, 365, 160, RED);
  fillTriangle (465, 160, 515, 250, 565, 160, RED);
  fillCircle (465, 160, 20, RED);
  waitButtonPress ();

  closeGraph ();
}
Пример #3
0
void paint()
{
	int width = getWindowWidth();
	int height = getWindowHeight();

	int radius = min(width, height) / 2;

	setFill(colorYellow);
	fillCircle(width / 2, height / 2, radius);
	setStroke(colorGreen, 10);
	drawCircle(width / 2, height / 2, radius);

	setFill(colorYellow);
	fillEllipse(200, 200, 350, 250);
	setStroke(colorGreen, 10);
	drawEllipse(200, 200, 350, 250);

	setStroke(colorBlue, 2);

	drawLine(10, 10, _mouseX, _mouseY);

	if(_pressedChar != 0)
	{
		char str[2] = {0};
		str[0] = _pressedChar;

		drawText(100, 100, str, 10, colorWhite, colorBlue);
	}

	char str[256] = {0};
	sprintf(str, "%d - HELLO COMPUTER", _secondElapsed);

	drawText(100, 200, str, 70, colorYellow, colorBlue);

	setFill((_secondElapsed % 2) == 0 ? colorBlue : colorRed);
	fillRectangle(200, 200, 100, 100);
	setStroke(colorGreen, 2);
	drawRectangle(200, 200, 100, 100);
}
Пример #4
0
main (void)
{
  initGraph ();

  /* 背景 */
  floodFill (320, 240, BLACK, LIGHTBLUE);
  waitButtonPress ();

  /* 頭 */
  fillEllipse (320, 240, 240, 180, WHITE);

  /* 耳 */
  fillEllipse (480, 140, 60, 80, WHITE);
  fillEllipse (160, 140, 60, 80, WHITE);
  waitButtonPress ();

  /* 目 */
  fillEllipse (200, 300, 15, 20, BLACK);
  fillEllipse (440, 300, 15, 20, BLACK);
  waitButtonPress ();

  /* 鼻 */
  fillEllipse (320, 340, 10, 14, YELLOW);
  setLineWidth (2);
  waitButtonPress ();

  /* ひげ */
  drawLine (125, 300, 40, 305, BLACK);
  drawLine (130, 320, 50, 330, BLACK);
  drawLine (140, 340, 40, 355, BLACK);

  drawLine (515, 300, 600, 305, BLACK);
  drawLine (510, 320, 590, 330, BLACK);
  drawLine (500, 340, 600, 355, BLACK);
  waitButtonPress ();

  /* リボン */
  fillTriangle (480, 160, 430, 70, 380, 160, RED);
  fillTriangle (480, 160, 530, 250, 580, 160, RED);
  fillCircle (480, 160, 20, RED);
  waitButtonPress ();

  closeGraph ();
}
//==============================================================================
void Graphics::fillEllipse (const Rectangle<float>& area) const
{
    fillEllipse (area.getX(), area.getY(), area.getWidth(), area.getHeight());
}
Пример #6
0
 void fillCircle(double cx, double cy, double r, const double rgb[3])
 { fillEllipse(cx, cy, r, r, 0., rgb); }
Пример #7
0
void fillCircle(int xCenter, int yCenter, int radius)
{
	fillEllipse(xCenter - radius, yCenter - radius, radius * 2, radius * 2);
}
void Graphics::fillEllipse (float x, float y, float w, float h) const
{
    fillEllipse (Rectangle<float> (x, y, w, h));
}
Пример #9
0
void Graphics::fillEllipse (float x, float y, float w, float h) const
{
    fillEllipse (coordsToRectangle (x, y, w, h));
}